This is an archive of the discontinued LLVM Phabricator instance.

Fix printing signed character literals
Needs ReviewPublic

Authored by nick.sumner on Jan 21 2016, 3:28 PM.

Details

Reviewers
bkramer
rsmith
Summary

Allow 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.

Diff Detail

Event Timeline

nick.sumner retitled this revision from to Fix printing signed character literals.
nick.sumner updated this object.
nick.sumner added reviewers: bkramer, rsmith.
nick.sumner added a subscriber: cfe-commits.