[PATCH] Fix printing signed character literals

Nick Sumner nick.sumner at gmail.com
Thu May 28 21:45:33 PDT 2015


Hi all,

The attached patch allows StmtPrinter to print signed character
literals. Given the code:
char c = '\200';

The character literal is presently printed as:
char c = '\Uffffff80';

The original literal has the signed value -128 (or unsigned value 128)
and only has any meaning when clamped to the extended ASCII range.
'\Uffffff80' isn't a valid character.

With the patch, the literal is printed as:
char c = '\x80';

As a side note, this doesn't handle multicharacter literals, but I
don't think there is enough information in the AST to make that
possible. They are implementation defined, anyway.

Best
Nick
-------------- next part --------------
A non-text attachment was scrubbed...
Name: printSignedChars.patch
Type: text/x-patch
Size: 984 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150528/f799b5db/attachment.bin>


More information about the cfe-commits mailing list