aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAxel Naumann <Axel.Naumann@cern.ch>2012-06-29 07:30:33 +0000
committerAxel Naumann <Axel.Naumann@cern.ch>2012-06-29 07:30:33 +0000
commit16d0078d2a4b1024cbeca8e1ebe7c0ed45554f11 (patch)
tree9de4e208e7c59d1044257c28db4b2f66eac91bae
parent56c045ed5e148d3eff9b344001370b80ec14d43b (diff)
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
-rw-r--r--lib/AST/TypePrinter.cpp29
-rw-r--r--test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp6
2 files changed, 27 insertions, 8 deletions
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 <class T1, class T2, int N = 17> struct E;
eval<A<int>> eA;
eval<B<int, float>> eB;
-eval<C<17>> eC; // expected-error{{implicit instantiation of undefined template 'eval<C<17>>'}}
-eval<D<int, 17>> eD; // expected-error{{implicit instantiation of undefined template 'eval<D<int, 17>>'}}
-eval<E<int, float>> eE; // expected-error{{implicit instantiation of undefined template 'eval<E<int, float, 17>>}}
+eval<C<17>> eC; // expected-error{{implicit instantiation of undefined template 'eval<C<17> >'}}
+eval<D<int, 17>> eD; // expected-error{{implicit instantiation of undefined template 'eval<D<int, 17> >'}}
+eval<E<int, float>> eE; // expected-error{{implicit instantiation of undefined template 'eval<E<int, float, 17> >}}
template<template <int ...N> class TT> struct X0 { }; // expected-note{{previous non-type template parameter with type 'int' is here}}
template<int I, int J, int ...Rest> struct X0a;