Add some side-effect free Create methods for TypeDecl subclasses and use them for PCH reading.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107468 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index 187b88d..da7ad1d 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -1993,6 +1993,7 @@
   static EnumDecl *Create(ASTContext &C, DeclContext *DC,
                           SourceLocation L, IdentifierInfo *Id,
                           SourceLocation TKL, EnumDecl *PrevDecl);
+  static EnumDecl *Create(ASTContext &C, EmptyShell Empty);
 
   virtual void Destroy(ASTContext& C);
 
@@ -2110,6 +2111,7 @@
                             SourceLocation L, IdentifierInfo *Id,
                             SourceLocation TKL = SourceLocation(),
                             RecordDecl* PrevDecl = 0);
+  static RecordDecl *Create(ASTContext &C, EmptyShell Empty);
 
   virtual void Destroy(ASTContext& C);
 
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index a543cf0..6300291 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -427,6 +427,7 @@
                                SourceLocation TKL = SourceLocation(),
                                CXXRecordDecl* PrevDecl=0,
                                bool DelayTypeCreation = false);
+  static CXXRecordDecl *Create(ASTContext &C, EmptyShell Empty);
 
   virtual void Destroy(ASTContext& C);
 
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h
index 05bad93..84e7553 100644
--- a/include/clang/AST/DeclTemplate.h
+++ b/include/clang/AST/DeclTemplate.h
@@ -703,6 +703,7 @@
                                       SourceLocation L, unsigned D, unsigned P,
                                       IdentifierInfo *Id, bool Typename,
                                       bool ParameterPack);
+  static TemplateTypeParmDecl *Create(ASTContext &C, EmptyShell Empty);
 
   /// \brief Whether this template type parameter was declared with
   /// the 'typename' keyword. If not, it was declared with the 'class'
@@ -980,8 +981,8 @@
          ClassTemplateDecl *SpecializedTemplate,
          TemplateArgumentListBuilder &Builder,
          ClassTemplateSpecializationDecl *PrevDecl);
-
-  static ClassTemplateSpecializationDecl *CreateEmpty(ASTContext &Context);
+  static ClassTemplateSpecializationDecl *
+  Create(ASTContext &Context, EmptyShell Empty);
 
   virtual void Destroy(ASTContext& C);
 
@@ -1230,7 +1231,7 @@
          unsigned SequenceNumber);
 
   static ClassTemplatePartialSpecializationDecl *
-  CreateEmpty(ASTContext &Context);
+  Create(ASTContext &Context, EmptyShell Empty);
 
   /// Get the list of template parameters
   TemplateParameterList *getTemplateParameters() const {
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 267c19f..c3c30f9 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -1638,6 +1638,10 @@
   return Enum;
 }
 
+EnumDecl *EnumDecl::Create(ASTContext &C, EmptyShell Empty) {
+  return new (C) EnumDecl(0, SourceLocation(), 0, 0, SourceLocation());
+}
+
 void EnumDecl::Destroy(ASTContext& C) {
   TagDecl::Destroy(C);
 }
@@ -1677,6 +1681,11 @@
   return R;
 }
 
+RecordDecl *RecordDecl::Create(ASTContext &C, EmptyShell Empty) {
+  return new (C) RecordDecl(Record, TTK_Struct, 0, SourceLocation(), 0, 0,
+                            SourceLocation());
+}
+
 RecordDecl::~RecordDecl() {
 }
 
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 9ab44b6..a77c1c8 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -58,6 +58,11 @@
   return R;
 }
 
+CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, EmptyShell Empty) {
+  return new (C) CXXRecordDecl(CXXRecord, TTK_Struct, 0, SourceLocation(), 0, 0,
+                               SourceLocation());
+}
+
 CXXRecordDecl::~CXXRecordDecl() {
 }
 
diff --git a/lib/AST/DeclTemplate.cpp b/lib/AST/DeclTemplate.cpp
index 5984eaa..9a7bc91 100644
--- a/lib/AST/DeclTemplate.cpp
+++ b/lib/AST/DeclTemplate.cpp
@@ -266,6 +266,12 @@
   return new (C) TemplateTypeParmDecl(DC, L, Id, Typename, Type, ParameterPack);
 }
 
+TemplateTypeParmDecl *
+TemplateTypeParmDecl::Create(ASTContext &C, EmptyShell Empty) {
+  return new (C) TemplateTypeParmDecl(0, SourceLocation(), 0, false,
+                                      QualType(), false);
+}
+
 SourceLocation TemplateTypeParmDecl::getDefaultArgumentLoc() const {
   return DefaultArgument->getTypeLoc().getSourceRange().getBegin();
 }
@@ -476,7 +482,7 @@
 }
 
 ClassTemplateSpecializationDecl *
-ClassTemplateSpecializationDecl::CreateEmpty(ASTContext &Context) {
+ClassTemplateSpecializationDecl::Create(ASTContext &Context, EmptyShell Empty) {
   return
     new (Context)ClassTemplateSpecializationDecl(ClassTemplateSpecialization);
 }
@@ -545,7 +551,8 @@
 }
 
 ClassTemplatePartialSpecializationDecl *
-ClassTemplatePartialSpecializationDecl::CreateEmpty(ASTContext &Context) {
+ClassTemplatePartialSpecializationDecl::Create(ASTContext &Context,
+                                               EmptyShell Empty) {
   return new (Context)ClassTemplatePartialSpecializationDecl();
 }
 
diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp
index 120596b..2bdf166 100644
--- a/lib/Frontend/PCHReaderDecl.cpp
+++ b/lib/Frontend/PCHReaderDecl.cpp
@@ -1145,11 +1145,10 @@
     D = TypedefDecl::Create(*Context, 0, SourceLocation(), 0, 0);
     break;
   case pch::DECL_ENUM:
-    D = EnumDecl::Create(*Context, 0, SourceLocation(), 0, SourceLocation(), 0);
+    D = EnumDecl::Create(*Context, Decl::EmptyShell());
     break;
   case pch::DECL_RECORD:
-    D = RecordDecl::Create(*Context, TTK_Struct, 0, SourceLocation(),
-                           0, SourceLocation(), 0);
+    D = RecordDecl::Create(*Context, Decl::EmptyShell());
     break;
   case pch::DECL_ENUM_CONSTANT:
     D = EnumConstantDecl::Create(*Context, 0, SourceLocation(), 0, QualType(),
@@ -1196,8 +1195,7 @@
                                             DeclarationName());
     break;
   case pch::DECL_CXX_RECORD:
-    D = CXXRecordDecl::Create(*Context, TTK_Struct, 0,
-                              SourceLocation(), 0, SourceLocation(), 0);
+    D = CXXRecordDecl::Create(*Context, Decl::EmptyShell());
     break;
   case pch::DECL_CXX_METHOD:
     D = CXXMethodDecl::Create(*Context, 0, SourceLocation(), DeclarationName(),
@@ -1227,17 +1225,18 @@
                                   DeclarationName(), 0, 0, 0);
     break;
   case pch::DECL_CLASS_TEMPLATE_SPECIALIZATION:
-    D = ClassTemplateSpecializationDecl::CreateEmpty(*Context);
+    D = ClassTemplateSpecializationDecl::Create(*Context, Decl::EmptyShell());
     break;
   case pch::DECL_CLASS_TEMPLATE_PARTIAL_SPECIALIZATION:
-    D = ClassTemplatePartialSpecializationDecl::CreateEmpty(*Context);
+    D = ClassTemplatePartialSpecializationDecl::Create(*Context,
+                                                            Decl::EmptyShell());
     break;
   case pch::DECL_FUNCTION_TEMPLATE:
     D = FunctionTemplateDecl::Create(*Context, 0, SourceLocation(),
                                      DeclarationName(), 0, 0);
     break;
   case pch::DECL_TEMPLATE_TYPE_PARM:
-    D = TemplateTypeParmDecl::Create(*Context, 0, SourceLocation(), 0,0,0,0,0);
+    D = TemplateTypeParmDecl::Create(*Context, Decl::EmptyShell());
     break;
   case pch::DECL_NON_TYPE_TEMPLATE_PARM:
     D = NonTypeTemplateParmDecl::Create(*Context, 0, SourceLocation(), 0,0,0,