This is an archive of the discontinued LLVM Phabricator instance.

Fix AST printing of ascii char literals above 127.
ClosedPublic

Authored by steven_watanabe on Feb 12 2016, 11:32 AM.

Details

Summary

Currently literals like '\xff' may be sign extended, resulting in output like '\Uffffffff', which is not valid.

Diff Detail

Event Timeline

steven_watanabe retitled this revision from to Fix AST printing of ascii char literals above 127..
steven_watanabe updated this object.
steven_watanabe added a reviewer: rsmith.
steven_watanabe added a subscriber: cfe-commits.
rsmith accepted this revision.Feb 12 2016, 1:28 PM
rsmith edited edge metadata.

LGTM

lib/AST/StmtPrinter.cpp
1253–1256

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?

This revision is now accepted and ready to land.Feb 12 2016, 1:28 PM
This revision was automatically updated to reflect the committed changes.