https://github.com/AaronBallman commented:

Thank you for working on this!

I think there may be a way we can implement this by updating the handling of 
`%diff` in `FormatDiagnostic()` in `Diagnostic.cpp`. That syntax only accepts 
two `QualType` objects and is used when we're going to report a diagnostic 
about a type mismatch between the two. So any such diagnostic could plausibly 
be handed two VLA types and run into the same sort of confusing output for the 
user. 

I can think of two ways to do this (other ways may exist).

1) We could add new syntax for `%diff` to let the diagnostic author pick a 
custom string when the two types would print identical output. e.g., 
`%diff{assigning $ to a variable of type $|assigning with different 
types|assigning with different VLA types $}0,1`
2) We could be clever and generate text when formatting the diagnostic. e.g., 
notice that the output of the types would be identical and append `; VLA types 
differ despite using the same array size expression` or something along those 
lines.

I worry that #2 will wind up with awkward diagnostic wording that seems magical 
to diagnostic authors because it won't be immediately clear where the wording 
comes from. I worry that #1 doesn't scale well and forces everyone to think 
about VLAs when it may not be clear to them how to work such a diagnostic. So 
my idea may be a terrible one, and if so, feel free to tell me. ;-)

https://github.com/llvm/llvm-project/pull/101261
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to