[cfe-commits] r159412 - in /cfe/trunk: lib/AST/TypePrinter.cpp test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp

Axel Naumann Axel.Naumann at cern.ch
Fri Jun 29 00:30:34 PDT 2012


Author: axel
Date: Fri Jun 29 02:30:33 2012
New Revision: 159412

URL: http://llvm.org/viewvc/llvm-project?rev=159412&view=rev
Log:
>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.

Modified:
    cfe/trunk/lib/AST/TypePrinter.cpp
    cfe/trunk/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp

Modified: cfe/trunk/lib/AST/TypePrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypePrinter.cpp?rev=159412&r1=159411&r2=159412&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TypePrinter.cpp (original)
+++ cfe/trunk/lib/AST/TypePrinter.cpp Fri Jun 29 02:30:33 2012
@@ -449,12 +449,12 @@
     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 @@
   if (!SkipBrackets)
     OS << '<';
   
+  bool needSpace = false;
   for (unsigned Arg = 0; Arg < NumArgs; ++Arg) {
     if (Arg > 0)
       OS << ", ";
@@ -1270,10 +1271,18 @@
     // 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 @@
                           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 @@
     // 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 @@
         OS << ' ';
       addSpace = true;
     }
-    
+
     switch (lifetime) {
     case Qualifiers::OCL_None: llvm_unreachable("none but true");
     case Qualifiers::OCL_ExplicitNone: OS << "__unsafe_unretained"; break;

Modified: cfe/trunk/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp?rev=159412&r1=159411&r2=159412&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp Fri Jun 29 02:30:33 2012
@@ -13,9 +13,9 @@
 
 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;





More information about the cfe-commits mailing list