[cfe-commits] r122888 - /cfe/trunk/lib/Parse/ParseTemplate.cpp

Douglas Gregor dgregor at apple.com
Wed Jan 5 09:33:50 PST 2011


Author: dgregor
Date: Wed Jan  5 11:33:50 2011
New Revision: 122888

URL: http://llvm.org/viewvc/llvm-project?rev=122888&view=rev
Log:
Parse template template argument pack expansions. They're still not
implemented, however.

Modified:
    cfe/trunk/lib/Parse/ParseTemplate.cpp

Modified: cfe/trunk/lib/Parse/ParseTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTemplate.cpp?rev=122888&r1=122887&r2=122888&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTemplate.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp Wed Jan  5 11:33:50 2011
@@ -907,7 +907,7 @@
   // We parse an id-expression that refers to a class template or template
   // alias. The grammar we parse is:
   //
-  //   nested-name-specifier[opt] template[opt] identifier
+  //   nested-name-specifier[opt] template[opt] identifier ...[opt]
   //
   // followed by a token that terminates a template argument, such as ',', 
   // '>', or (in some cases) '>>'.
@@ -915,6 +915,8 @@
   ParseOptionalCXXScopeSpecifier(SS, ParsedType(),
                                  /*EnteringContext=*/false);
   
+  ParsedTemplateArgument Result;
+  SourceLocation EllipsisLoc;
   if (SS.isSet() && Tok.is(tok::kw_template)) {
     // Parse the optional 'template' keyword following the 
     // nested-name-specifier.
@@ -926,6 +928,10 @@
       Name.setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
       ConsumeToken(); // the identifier
       
+      // Parse the ellipsis.
+      if (Tok.is(tok::ellipsis))
+        EllipsisLoc = ConsumeToken();
+      
       // If the next token signals the end of a template argument,
       // then we have a dependent template name that could be a template
       // template argument.
@@ -936,7 +942,7 @@
                                              /*ObjectType=*/ ParsedType(),
                                              /*EnteringContext=*/false,
                                              Template))
-        return ParsedTemplateArgument(SS, Template, Name.StartLocation);
+        Result = ParsedTemplateArgument(SS, Template, Name.StartLocation);
     }
   } else if (Tok.is(tok::identifier)) {
     // We may have a (non-dependent) template name.
@@ -945,6 +951,10 @@
     Name.setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
     ConsumeToken(); // the identifier
     
+    // Parse the ellipsis.
+    if (Tok.is(tok::ellipsis))
+      EllipsisLoc = ConsumeToken();
+
     if (isEndOfTemplateArgument(Tok)) {
       bool MemberOfUnknownSpecialization;
       TemplateNameKind TNK = Actions.isTemplateName(getCurScope(), SS,
@@ -957,13 +967,16 @@
       if (TNK == TNK_Dependent_template_name || TNK == TNK_Type_template) {
         // We have an id-expression that refers to a class template or
         // (C++0x) template alias. 
-        return ParsedTemplateArgument(SS, Template, Name.StartLocation);
+        Result = ParsedTemplateArgument(SS, Template, Name.StartLocation);
       }
     }
   }
   
-  // We don't have a template template argument.  
-  return ParsedTemplateArgument();
+  // If this is a pack expansion, build it as such.
+  if (EllipsisLoc.isValid() && !Result.isInvalid())
+    Result = Actions.ActOnPackExpansion(Result, EllipsisLoc);
+  
+  return Result;
 }
 
 /// ParseTemplateArgument - Parse a C++ template argument (C++ [temp.names]).





More information about the cfe-commits mailing list