[cfe-commits] r152303 - in /cfe/trunk: lib/AST/StmtPrinter.cpp test/SemaCXX/cxx11-ast-print.cpp

Richard Smith richard-llvm at metafoo.co.uk
Thu Mar 8 01:02:38 PST 2012


Author: rsmith
Date: Thu Mar  8 03:02:38 2012
New Revision: 152303

URL: http://llvm.org/viewvc/llvm-project?rev=152303&view=rev
Log:
Ensure we don't print 123ULL_foo when printing a user-defined integer literal.

Modified:
    cfe/trunk/lib/AST/StmtPrinter.cpp
    cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp

Modified: cfe/trunk/lib/AST/StmtPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtPrinter.cpp?rev=152303&r1=152302&r2=152303&view=diff
==============================================================================
--- cfe/trunk/lib/AST/StmtPrinter.cpp (original)
+++ cfe/trunk/lib/AST/StmtPrinter.cpp Thu Mar  8 03:02:38 2012
@@ -1237,7 +1237,12 @@
     }
     break;
   }
-  case UserDefinedLiteral::LOK_Integer:
+  case UserDefinedLiteral::LOK_Integer: {
+    // Print integer literal without suffix.
+    IntegerLiteral *Int = cast<IntegerLiteral>(Node->getCookedLiteral());
+    OS << Int->getValue().toString(10, /*isSigned*/false);
+    break;
+  }
   case UserDefinedLiteral::LOK_Floating:
   case UserDefinedLiteral::LOK_String:
   case UserDefinedLiteral::LOK_Character:

Modified: cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp?rev=152303&r1=152302&r2=152303&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx11-ast-print.cpp Thu Mar  8 03:02:38 2012
@@ -4,9 +4,19 @@
 // CHECK: decltype(nullptr) operator "" _foo(const char *p, decltype(sizeof(int)));
 auto operator"" _foo(const char *p, decltype(sizeof(int))) -> decltype(nullptr);
 
+// CHECK: decltype(""_foo) operator "" _bar(unsigned long long);
+decltype(""_foo) operator"" _bar(unsigned long long);
+
+// CHECK: decltype(42_bar) operator "" _baz(long double);
+decltype(42_bar) operator"" _baz(long double);
+
 // CHECK: const char *p1 = "bar1"_foo;
 const char *p1 = "bar1"_foo;
 // CHECK: const char *p2 = "bar2"_foo;
 const char *p2 = R"x(bar2)x"_foo;
 // CHECK: const char *p3 = u8"bar3"_foo;
 const char *p3 = u8"bar3"_foo;
+// CHECK: const char *p4 = 297_bar;
+const char *p4 = 0x129_bar;
+// CHECK: const char *p5 = 1.0E+12_baz;
+const char *p5 = 1e12_baz;





More information about the cfe-commits mailing list