[PATCH] D155610: [Clang][Sema] Fix display of characters on static assertion failure

Hubert Tong via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 14 13:17:48 PDT 2023


hubert.reinterpretcast added inline comments.


================
Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16876
+  // other types.
+  if (CodePoint <= UCHAR_MAX) {
+    StringRef Escaped = escapeCStyle<EscapeChar::Single>(CodePoint);
----------------
cor3ntin wrote:
> hubert.reinterpretcast wrote:
> > For types other than `Char_S`, `Char_U`, and `Char8`, this fails to treat the C1 Controls and Latin-1 Supplement characters as Unicode code points. It looks like test coverage for these cases are missing.
> `escapeCStyle` is one of the things that assume ASCII / UTF, but yes, we might as well reduce to 0x7F just to avoid unnecessary work
> `escapeCStyle` is one of the things that assume ASCII / UTF, but yes, we might as well reduce to 0x7F just to avoid unnecessary work

I meant (with a `signed char` type to trigger the assertion):
```
<stdin>:1:28: note: expression evaluates to ''<A2>' (0xA2) == '<A2>' (0xA2)'
    1 | static_assert(u"\u00a2"[0] == '<A2>');
      |               ~~~~~~~~~~~~~^~~~~~~~~
```

should be:
```
<stdin>:1:28: note: expression evaluates to ''ยข' (0xA2) == '<A2>' (0xA2)'
    1 | static_assert(u"\u00a2"[0] == '<A2>');
      |               ~~~~~~~~~~~~~^~~~~~~~~
```



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

https://reviews.llvm.org/D155610



More information about the cfe-commits mailing list