]> granicus.if.org Git - clang/commitdiff
From Philippe Canal:
authorAxel Naumann <Axel.Naumann@cern.ch>
Fri, 29 Jun 2012 07:30:33 +0000 (07:30 +0000)
committerAxel Naumann <Axel.Naumann@cern.ch>
Fri, 29 Jun 2012 07:30:33 +0000 (07:30 +0000)
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

lib/AST/TypePrinter.cpp
test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp

index 111fee9d8820d5ab10849801b0ad29b160f3cfa2..84adad7b13727aaabe19c73d27324df3f76c4737 100644 (file)
@@ -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;
index 0c555b53f95e63ddb341ad4a47d0aed1ceab8f48..1c13bffa212f7c2f11f4f181135ca81612e5434e 100644 (file)
@@ -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;