Initial support for reading templates from PCH.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106392 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp
index 85b7960..1fcf923 100644
--- a/lib/AST/DeclTemplate.cpp
+++ b/lib/AST/DeclTemplate.cpp
@@ -155,6 +155,21 @@
   return Template;
 }
 
+void ClassTemplateDecl::initPreviousDeclaration(ASTContext &C,
+                                                ClassTemplateDecl *PrevDecl) {
+  assert(PreviousDeclaration == 0 && "PreviousDeclaration already set!");
+  assert(CommonPtr == 0 && "initPreviousDeclaration already called!");
+
+  PreviousDeclaration = PrevDecl;
+
+  if (PrevDecl)
+    CommonPtr = PrevDecl->CommonPtr;
+  else {
+    CommonPtr = new (C) Common;
+    C.AddDeallocation(DeallocateCommon, CommonPtr);
+  }
+}
+
 ClassTemplateDecl *ClassTemplateDecl::Create(ASTContext &C,
                                              DeclContext *DC,
                                              SourceLocation L,
@@ -162,16 +177,9 @@
                                              TemplateParameterList *Params,
                                              NamedDecl *Decl,
                                              ClassTemplateDecl *PrevDecl) {
-  Common *CommonPtr;
-  if (PrevDecl)
-    CommonPtr = PrevDecl->CommonPtr;
-  else {
-    CommonPtr = new (C) Common;
-    C.AddDeallocation(DeallocateCommon, CommonPtr);
-  }
-
-  return new (C) ClassTemplateDecl(DC, L, Name, Params, Decl, PrevDecl,
-                                   CommonPtr);
+  ClassTemplateDecl *New = new (C) ClassTemplateDecl(DC, L, Name, Params, Decl);
+  New->initPreviousDeclaration(C, PrevDecl);
+  return New;
 }
 
 ClassTemplateDecl::~ClassTemplateDecl() {