[PATCH] D135366: [clang][Interp] Implement String- and CharacterLiterals

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 8 00:22:47 PDT 2022


tbaeder added inline comments.


================
Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:446
+  if (Optional<PrimType> T = classify(LitType)) {
+    APInt Val(getIntWidth(LitType), E->getValue());
+    return this->emitConst(*T, 0, Val, E);
----------------
aaron.ballman wrote:
> Should this be concerned about the sign of the promoted literal?
Switched to `emitConst()` that takes into account signedness.


================
Comment at: clang/test/AST/Interp/arrays.cpp:135
+  static_assert(u32[1] == U'b', "");
+};
+
----------------
aaron.ballman wrote:
> I think you need a more coverage for character literals. Some test cases that are interesting: multichar literals (`'abcd'`), character literals with UCNs (`'\uFFFF'`), character literals with numeric escapes (`'\xFF'`). I'm especially interested in seeing whether we handle integer promotions properly, especially when promoting to `unsigned int`.
I added two more test cases but I'm generally not that familiar with character  literal edge cases and integer promotion, so if you have concrete test cases in mind, that would be great :)


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

https://reviews.llvm.org/D135366



More information about the cfe-commits mailing list