forked from OSchip/llvm-project
Fix statement printing for raw and template user-defined literals.
llvm-svn: 152401
This commit is contained in:
parent
f32638d77c
commit
29e9595bd7
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue