Improve the representation of template names in the AST. This
representation handles the various ways in which one can name a
template, including unqualified references ("vector"), qualified
references ("std::vector"), and dependent template names
("MetaFun::template apply").

One immediate effect of this change is that the representation of
nested-name-specifiers in type names for class template
specializations (e.g., std::vector<int>) is more accurate. Rather than
representing std::vector<int> as

  std::(vector<int>)

we represent it as

  (std::vector)<int>

which more closely follows the C++ grammar. 

Additionally, templates are no longer represented as declarations
(DeclPtrTy) in Parse-Sema interactions. Instead, I've introduced a new
OpaquePtr type (TemplateTy) that holds the representation of a
TemplateName. This will simplify the handling of dependent
template-names, once we get there.






git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68074 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/ParseTemplate.cpp b/lib/Parse/ParseTemplate.cpp
index b962cbf..8eda694 100644
--- a/lib/Parse/ParseTemplate.cpp
+++ b/lib/Parse/ParseTemplate.cpp
@@ -406,7 +406,7 @@
 /// last token in the stream (e.g., so that it can be replaced with an
 /// annotation token).
 bool 
-Parser::ParseTemplateIdAfterTemplateName(DeclPtrTy Template,
+Parser::ParseTemplateIdAfterTemplateName(TemplateTy Template,
                                          SourceLocation TemplateNameLoc, 
                                          const CXXScopeSpec *SS,
                                          bool ConsumeLastToken,
@@ -499,7 +499,7 @@
 /// replaced with a type annotation token. Otherwise, the
 /// simple-template-id is always replaced with a template-id
 /// annotation token.
-void Parser::AnnotateTemplateIdToken(DeclPtrTy Template, TemplateNameKind TNK,
+void Parser::AnnotateTemplateIdToken(TemplateTy Template, TemplateNameKind TNK,
                                      const CXXScopeSpec *SS, 
                                      SourceLocation TemplateKWLoc,
                                      bool AllowTypeAnnotation) {
@@ -531,12 +531,13 @@
     return; 
 
   // Build the annotation token.
+  // FIXME: Not just for class templates!
   if (TNK == TNK_Class_template && AllowTypeAnnotation) {
     Action::TypeResult Type 
-      = Actions.ActOnClassTemplateId(Template, TemplateNameLoc,
-                                     LAngleLoc, TemplateArgsPtr,
-                                     &TemplateArgLocations[0],
-                                     RAngleLoc, SS);
+      = Actions.ActOnTemplateIdType(Template, TemplateNameLoc,
+                                    LAngleLoc, TemplateArgsPtr,
+                                    &TemplateArgLocations[0],
+                                    RAngleLoc);
     if (Type.isInvalid()) // FIXME: better recovery?
       return;
 
@@ -603,12 +604,12 @@
                                      TemplateId->NumArgs);
 
   Action::TypeResult Type 
-    = Actions.ActOnClassTemplateId(DeclPtrTy::make(TemplateId->Template),
-                                   TemplateId->TemplateNameLoc,
-                                   TemplateId->LAngleLoc, 
-                                   TemplateArgsPtr,
-                                   TemplateId->getTemplateArgLocations(),
-                                   TemplateId->RAngleLoc, SS);
+    = Actions.ActOnTemplateIdType(TemplateTy::make(TemplateId->Template),
+                                  TemplateId->TemplateNameLoc,
+                                  TemplateId->LAngleLoc, 
+                                  TemplateArgsPtr,
+                                  TemplateId->getTemplateArgLocations(),
+                                  TemplateId->RAngleLoc);
   if (Type.isInvalid()) {
     // FIXME: better recovery?
     ConsumeToken();