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

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 18 23:31:57 PDT 2023


cor3ntin added a comment.

I agree with Aaron that in the current state, the common case diagnostics are made worse. But there is room for improvement!

I think what we want to do here is modify `ConvertAPValueToString` so that it applies the same escape logic to `char` as we do in `pushEscapedString` (in Diagnostics.cpp)
It would make sense that `signed`/`unsigned` are treated as integers (in which case they should not be quoted), but `char`, `wchar_t`, `charN_t` should try really hard to present a printable character to the user, unless it's not possible to do so.

So the best way to progress that might be:

- put `pushEscapedString` somewhere we can reuse
- make char/char8_t use this function in `ConvertAPValueToString` - it might be slightly more tricky for wchar_t, you would have to try to convert to utf-8 first.


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