Allocate template parameter lists for out-of-line definitions via the
ASTContext rather than via the normal heap.

llvm-svn: 106008
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 4593c6f..25687e1 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -567,7 +567,8 @@
 }
 
 void
-QualifierInfo::setTemplateParameterListsInfo(unsigned NumTPLists,
+QualifierInfo::setTemplateParameterListsInfo(ASTContext &Context,
+                                             unsigned NumTPLists,
                                              TemplateParameterList **TPLists) {
   assert((NumTPLists == 0 || TPLists != 0) &&
          "Empty array of template parameters with positive size!");
@@ -576,19 +577,25 @@
 
   // Free previous template parameters (if any).
   if (NumTemplParamLists > 0) {
-    delete[] TemplParamLists;
+    Context.Deallocate(TemplParamLists);
     TemplParamLists = 0;
     NumTemplParamLists = 0;
   }
   // Set info on matched template parameter lists (if any).
   if (NumTPLists > 0) {
-    TemplParamLists = new TemplateParameterList*[NumTPLists];
+    TemplParamLists = new (Context) TemplateParameterList*[NumTPLists];
     NumTemplParamLists = NumTPLists;
     for (unsigned i = NumTPLists; i-- > 0; )
       TemplParamLists[i] = TPLists[i];
   }
 }
 
+void QualifierInfo::Destroy(ASTContext &Context) {
+  // FIXME: Deallocate template parameter lists themselves!
+  if (TemplParamLists)
+    Context.Deallocate(TemplParamLists);
+}
+
 //===----------------------------------------------------------------------===//
 // VarDecl Implementation
 //===----------------------------------------------------------------------===//