Eliminate TemplateArg so that we only have a single kind of
representation for template arguments. Also simplifies the interface
for ActOnClassTemplateSpecialization and eliminates some annoying
allocations of TemplateArgs.

My attempt at smart pointers for template arguments lists is
relatively lame. We can improve it once we're sure that we have the
right representation for template arguments.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64154 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 6b6a501..740198b 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -231,15 +231,6 @@
                                        (Decl**)Params, NumParams, RAngleLoc);
 }
 
-Sema::OwningTemplateArgResult Sema::ActOnTypeTemplateArgument(TypeTy *Type) {
-  return Owned(new (Context) TemplateArg(QualType::getFromOpaquePtr(Type)));
-}
-
-Sema::OwningTemplateArgResult 
-Sema::ActOnExprTemplateArgument(ExprArg Value) {
-  return Owned(new (Context) TemplateArg(static_cast<Expr *>(Value.release())));
-}
-
 Sema::DeclTy *
 Sema::ActOnClassTemplate(Scope *S, unsigned TagSpec, TagKind TK,
                          SourceLocation KWLoc, const CXXScopeSpec &SS,
@@ -368,37 +359,21 @@
 Action::TypeTy * 
 Sema::ActOnClassTemplateSpecialization(DeclTy *TemplateD,
                                        SourceLocation LAngleLoc,
-                                       MultiTemplateArgsArg TemplateArgsIn,
+                                       ASTTemplateArgsPtr TemplateArgs,
                                        SourceLocation RAngleLoc,
                                        const CXXScopeSpec *SS) {
   TemplateDecl *Template = cast<TemplateDecl>(static_cast<Decl *>(TemplateD));
 
-  // FIXME: Not happy about this. We should teach the parser to pass
-  // us opaque pointers + bools for template argument lists.
-  // FIXME: Also not happy about the fact that we leak these
-  // TemplateArg structures. Fixing the above will fix this, too.
-  llvm::SmallVector<uintptr_t, 16> Args;
-  llvm::SmallVector<bool, 16> ArgIsType;
-  unsigned NumArgs = TemplateArgsIn.size();
-  TemplateArg **TemplateArgs 
-    = reinterpret_cast<TemplateArg **>(TemplateArgsIn.release());
-  for (unsigned Arg = 0; Arg < NumArgs; ++Arg) {
-    if (Expr *ExprArg = TemplateArgs[Arg]->getAsExpr()) {
-      Args.push_back(reinterpret_cast<uintptr_t>(ExprArg));
-      ArgIsType.push_back(false);
-    } else {
-      QualType T = TemplateArgs[Arg]->getAsType();
-      Args.push_back(reinterpret_cast<uintptr_t>(T.getAsOpaquePtr()));
-      ArgIsType.push_back(true);
-    }
-  }
-
   // Yes, all class template specializations are just silly sugar for
   // 'int'. Gotta problem wit dat?
-  return Context.getClassTemplateSpecializationType(Template, NumArgs,
-                                                    &Args[0], &ArgIsType[0],
-                                                    Context.IntTy)
-    .getAsOpaquePtr();
+  QualType Result
+    = Context.getClassTemplateSpecializationType(Template, 
+                                                 TemplateArgs.size(),
+                    reinterpret_cast<uintptr_t *>(TemplateArgs.getArgs()), 
+                                                 TemplateArgs.getArgIsType(),
+                                                 Context.IntTy);
+  TemplateArgs.release();
+  return Result.getAsOpaquePtr();
 }
 
 /// \brief Determine whether the given template parameter lists are