diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-09 10:10:02 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-09 10:10:02 +0000 |
commit | ef9f29804fa8932282a17b414ef0dde2ea4eec03 (patch) | |
tree | 7cedd7f7dae748597ee599b16cc84863da3d8098 | |
parent | 9c1dda7d7b6336506764ce1b03baf4c03ed9ff92 (diff) |
Fix statement printing for raw and template user-defined literals.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152401 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/StmtPrinter.cpp | 15 | ||||
-rw-r--r-- | test/SemaCXX/cxx11-ast-print.cpp | 19 |
2 files changed, 28 insertions, 6 deletions
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index d2233e094b..d5e53a69d4 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -1225,14 +1225,17 @@ void StmtPrinter::VisitCXXUuidofExpr(CXXUuidofExpr *Node) { void StmtPrinter::VisitUserDefinedLiteral(UserDefinedLiteral *Node) { switch (Node->getLiteralOperatorKind()) { case UserDefinedLiteral::LOK_Raw: - OS << cast<StringLiteral>(Node->getArg(0))->getString(); + OS << cast<StringLiteral>(Node->getArg(0)->IgnoreImpCasts())->getString(); break; case UserDefinedLiteral::LOK_Template: { - DeclRefExpr *DRE = cast<DeclRefExpr>(Node->getCallee()); - assert(DRE->hasExplicitTemplateArgs()); - const TemplateArgumentLoc *Args = DRE->getTemplateArgs(); - for (unsigned i = 0, e = DRE->getNumTemplateArgs(); i != e; ++i) { - char C = (char)Args[i].getArgument().getAsIntegral()->getZExtValue(); + DeclRefExpr *DRE = cast<DeclRefExpr>(Node->getCallee()->IgnoreImpCasts()); + const TemplateArgumentList *Args = + cast<FunctionDecl>(DRE->getDecl())->getTemplateSpecializationArgs(); + assert(Args); + const TemplateArgument &Pack = Args->get(0); + for (TemplateArgument::pack_iterator I = Pack.pack_begin(), + E = Pack.pack_end(); I != E; ++I) { + char C = (char)I->getAsIntegral()->getZExtValue(); OS << C; } break; diff --git a/test/SemaCXX/cxx11-ast-print.cpp b/test/SemaCXX/cxx11-ast-print.cpp index 33684ceb4c..afabf88bd5 100644 --- a/test/SemaCXX/cxx11-ast-print.cpp +++ b/test/SemaCXX/cxx11-ast-print.cpp @@ -10,6 +10,15 @@ decltype(""_foo) operator"" _bar(unsigned long long); // CHECK: decltype(42_bar) operator "" _baz(long double); decltype(42_bar) operator"" _baz(long double); +// CHECK: decltype(4.5_baz) operator "" _baz(char); +decltype(4.5_baz) operator"" _baz(char); + +// CHECK: const char *operator "" _quux(const char *); +const char *operator"" _quux(const char *); + +// CHECK: template <char...> const char *operator "" _fritz(); +template<char...> const char *operator"" _fritz(); + // CHECK: const char *p1 = "bar1"_foo; const char *p1 = "bar1"_foo; // CHECK: const char *p2 = "bar2"_foo; @@ -20,3 +29,13 @@ const char *p3 = u8"bar3"_foo; const char *p4 = 0x129_bar; // CHECK: const char *p5 = 1.0E+12_baz; const char *p5 = 1e12_baz; +// CHECK: const char *p6 = 'x'_baz; +const char *p6 = 'x'_baz; +// CHECK: const char *p7 = 123_quux; +const char *p7 = 123_quux; +// CHECK: const char *p8 = 4.9_quux; +const char *p8 = 4.9_quux; +// CHECK: const char *p9 = 0x42e3F_fritz; +const char *p9 = 0x42e3F_fritz; +// CHECK: const char *p10 = 3.300e+15_fritz; +const char *p10 = 3.300e+15_fritz; |