[PATCH] D155610: [Clang][ExprConstant] Print integer instead of character on static assertion failure

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 18 10:13:58 PDT 2023


aaron.ballman added reviewers: cor3ntin, tahonermann.
aaron.ballman added a comment.

I wonder if we want to see whether the character is printable before deciding whether to show the numeric value for it or show a character value? For whitespace characters, printing the character leads to odd diagnostics: https://godbolt.org/z/d3TW6Ee8s and for non-character data (e.g., uses through `uint8_t`, `unsigned char`, or `signed char`) we probably never want to print as a character to begin with because there's no reason to assume the data is textual.

Adding in some other reviewers for a wider selection of opinions.



================
Comment at: clang/test/Lexer/cxx1z-trigraphs.cpp:24
 // expected-error at 11 {{}} expected-warning at 11 {{trigraph ignored}}
-// expected-error at 13 {{failed}} expected-warning at 13 {{trigraph ignored}} expected-note at 13 {{evaluates to ''?' == '#''}}
+// expected-error at 13 {{failed}} expected-warning at 13 {{trigraph ignored}} expected-note at 13 {{evaluates to '63 == 35'}}
 // expected-error at 16 {{}}
----------------
I think the original diagnostic was actually more understandable as it relates more closely to what's written in the static assertion. I could imagine something like `evaluates to '?' (63) == '#' (35)` would also be reasonable.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155610/new/

https://reviews.llvm.org/D155610



More information about the cfe-commits mailing list