Fix the ASTPrinter output for ascii char literals >127.

Differential Revision: http://reviews.llvm.org/D17206

llvm-svn: 260795
This commit is contained in:
Steven Watanabe 2016-02-13 02:31:28 +00:00
parent 22cc5e2375
commit e43ae19b31
2 changed files with 9 additions and 0 deletions

View File

@ -1250,6 +1250,12 @@ void StmtPrinter::VisitCharacterLiteral(CharacterLiteral *Node) {
OS << "'\\v'";
break;
default:
// A character literal might be sign-extended, which
// would result in an invalid \U escape sequence.
// FIXME: multicharacter literals such as '\xFF\xFF\xFF\xFF'
// are not correctly handled.
if ((value & ~0xFFu) == ~0xFFu && Node->getKind() == CharacterLiteral::Ascii)
value &= 0xFFu;
if (value < 256 && isPrintable((unsigned char)value))
OS << "'" << (char)value << "'";
else if (value < 256)

View File

@ -13,6 +13,8 @@ void i() {
h<u8'2'>();
}
char j = '\xFF';
// CHECK: char c = u8'1';
// CHECK-NEXT: char d = '1';
// CHECK-NEXT: char e = U'1';
@ -22,3 +24,4 @@ void i() {
// CHECK: template <char c = u8'1'>
// CHECK: h<u8'2'>();
// CHECK: char j = '\xff';