From: Axel Naumann Date: Fri, 29 Jun 2012 07:30:33 +0000 (+0000) Subject: From Philippe Canal: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=16d0078d2a4b1024cbeca8e1ebe7c0ed45554f11;p=clang From Philippe Canal: Update the two function overloads void TemplateSpecializationType::PrintTemplateArgumentList(raw_ostream &OS,.... to behave like std::string TemplateSpecializationType::PrintTemplateArgumentList(const TemplateArgument *Args,... hence making sure that clang consistently adds a space between two '>' at the end of nested template arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159412 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/TypePrinter.cpp b/lib/AST/TypePrinter.cpp index 111fee9d88..84adad7b13 100644 --- a/lib/AST/TypePrinter.cpp +++ b/lib/AST/TypePrinter.cpp @@ -449,12 +449,12 @@ void TypePrinter::printVariableArrayAfter(const VariableArrayType *T, AppendTypeQualList(OS, T->getIndexTypeCVRQualifiers()); OS << ' '; } - + if (T->getSizeModifier() == VariableArrayType::Static) OS << "static"; else if (T->getSizeModifier() == VariableArrayType::Star) OS << '*'; - + if (T->getSizeExpr()) T->getSizeExpr()->printPretty(OS, 0, Policy); OS << ']'; @@ -1248,6 +1248,7 @@ TemplateSpecializationType::PrintTemplateArgumentList( if (!SkipBrackets) OS << '<'; + bool needSpace = false; for (unsigned Arg = 0; Arg < NumArgs; ++Arg) { if (Arg > 0) OS << ", "; @@ -1270,10 +1271,18 @@ TemplateSpecializationType::PrintTemplateArgumentList( // to avoid printing the diagraph '<:'. if (!Arg && !ArgString.empty() && ArgString[0] == ':') OS << ' '; - + OS << ArgString; + + needSpace = (!ArgString.empty() && ArgString.back() == '>'); } + // If the last character of our string is '>', add another space to + // keep the two '>''s separate tokens. We don't *have* to do this in + // C++0x, but it's still good hygiene. + if (needSpace) + OS << ' '; + if (!SkipBrackets) OS << '>'; } @@ -1284,6 +1293,8 @@ PrintTemplateArgumentList(raw_ostream &OS, const TemplateArgumentLoc *Args, unsigned NumArgs, const PrintingPolicy &Policy) { OS << '<'; + + bool needSpace = false; for (unsigned Arg = 0; Arg < NumArgs; ++Arg) { if (Arg > 0) OS << ", "; @@ -1306,10 +1317,18 @@ PrintTemplateArgumentList(raw_ostream &OS, // to avoid printing the diagraph '<:'. if (!Arg && !ArgString.empty() && ArgString[0] == ':') OS << ' '; - + OS << ArgString; + + needSpace = (!ArgString.empty() && ArgString.back() == '>'); } + // If the last character of our string is '>', add another space to + // keep the two '>''s separate tokens. We don't *have* to do this in + // C++0x, but it's still good hygiene. + if (needSpace) + OS << ' '; + OS << '>'; } @@ -1532,7 +1551,7 @@ void Qualifiers::print(raw_ostream &OS, const PrintingPolicy& Policy, OS << ' '; addSpace = true; } - + switch (lifetime) { case Qualifiers::OCL_None: llvm_unreachable("none but true"); case Qualifiers::OCL_ExplicitNone: OS << "__unsafe_unretained"; break; diff --git a/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp b/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp index 0c555b53f9..1c13bffa21 100644 --- a/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp +++ b/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp @@ -13,9 +13,9 @@ template struct E; eval> eA; eval> eB; -eval> eC; // expected-error{{implicit instantiation of undefined template 'eval>'}} -eval> eD; // expected-error{{implicit instantiation of undefined template 'eval>'}} -eval> eE; // expected-error{{implicit instantiation of undefined template 'eval>}} +eval> eC; // expected-error{{implicit instantiation of undefined template 'eval >'}} +eval> eD; // expected-error{{implicit instantiation of undefined template 'eval >'}} +eval> eE; // expected-error{{implicit instantiation of undefined template 'eval >}} template