[clang] [clang] consistently quote expressions in diagnostics (PR #134769)

Henrik G. Olsson via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 22 12:07:19 PDT 2025


hnrklssn wrote:

@mizvekov 
We got some downstream failures from this. I was wondering about the case when the expression sometimes is a character literal, but not always. Previously we would get diagnostics like this:
```
lorem 0 ipsum
lorem 'X' ipsum
```
while with this change we get:
```
lorem '0' ipsum
lorem ''X'' ipsum
``` 
Is this something we want? The `'0'` can now be confused for the character literal of the digit 0 instead of the null character code, and the double single quotes can be confused for double quotes (although this should be less of a problem in any monospace font, but it still looks weird).

I'm less interested in changing anyone's stance on this: I'm quite happy with this change overall. I'm more interested in establishing a clear style guide for these cases, so that we can be consistent with the upstream style.

https://github.com/llvm/llvm-project/pull/134769


More information about the cfe-commits mailing list