[PATCH] D17206: Fix AST printing of ascii char literals above 127.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 12 13:28:58 PST 2016
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.
LGTM
================
Comment at: lib/AST/StmtPrinter.cpp:1253-1256
@@ -1252,2 +1252,6 @@
default:
+ // A character literal might be sign-extended, which
+ // would result in an invalid \U escape sequence.
+ if ((value & ~0xFFu) == ~0xFFu && Node->getKind() == CharacterLiteral::Ascii)
+ value &= 0xFFu;
if (value < 256 && isPrintable((unsigned char)value))
----------------
Hmm, this is not correct for multicharacter `char` literals:
auto n = '\xff\xff\xff\xff';
Here, the value of the literal is -1, but printing it as '\xff' would give a literal of a different type. However, we get that case wrong here in general (printing invalid \U... escapes), so this is no worse than today. Can you add a FIXME?
http://reviews.llvm.org/D17206
More information about the cfe-commits
mailing list