https://github.com/usx95 commented:

Great work on implementing flow history tracing! This would significantly 
improves the diagnostics. A few suggestions for enhancement:

1. **Simplify source highlighting and improve wording**: Rather than 
highlighting both sides of each step in the flow chain, we should only 
highlight the destination (left-hand side). Additionally, make the diagnostic 
text configurable based on what we know: use `"variable 'x'"` when we have a 
named variable, `"function call result"` for call expressions, `"temporary 
object"` for temporaries, etc. (Apologies for not mentioning this in the 
original issue!)

    For example, given:

    The desired diagnostic output would be:

    For chained member/arrow operations, we should highlight each step in the 
chain (with distinct ranges):

    Would produce:

    Notice how:
    - We only highlight the destination (`a`, `b`, `e`, function call, `s`, 
`x`) in each step of the flow
    - Each note traces back to the original source (`tgt` or the temporary)
    - For chained operations, we highlight progressively longer prefixes 
showing the flow through the chain in a single statement.
    - Function calls and member accesses are described appropriately when they 
appear in the flow
    - All involved entities use distinct source ranges (avoiding duplicate 
reports for the same range)
2. **Extend to other error types**: This tracing mechanism would be valuable 
for:
    - Use-after-return errors
    - Lifetime annotation suggestions
    - Dangling field/global warnings

    Consider refactoring the tracing logic to be reusable across these 
different diagnostic paths.

The implementation looks solid overall. Will take a deeper look at the tracking 
logic after the functional changes.

Feel free to ask follow up questions.

https://github.com/llvm/llvm-project/pull/188467
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to