When creating declarations that are deserialized from an module file,
go through a central allocation routine
Decl::AllocateDeserializedDecl(). No actual functionality change (yet).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147614 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 59bfdc6..b0aeabf 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -409,6 +409,12 @@
                                 HasRelatedResultType);
 }
 
+ObjCMethodDecl *ObjCMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
+  void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCMethodDecl));
+  return new (Mem) ObjCMethodDecl(SourceLocation(), SourceLocation(), 
+                                  Selector(), QualType(), 0, 0);
+}
+
 void ObjCMethodDecl::setAsRedeclaration(const ObjCMethodDecl *PrevMethod) {
   assert(PrevMethod);
   getASTContext().setObjCMethodRedeclaration(PrevMethod, this);
@@ -692,9 +698,11 @@
   return Result;
 }
 
-ObjCInterfaceDecl *ObjCInterfaceDecl::CreateEmpty(ASTContext &C) {
-  return new (C) ObjCInterfaceDecl(0, SourceLocation(), 0, SourceLocation(),
-                                   0, false);
+ObjCInterfaceDecl *ObjCInterfaceDecl::CreateDeserialized(ASTContext &C, 
+                                                         unsigned ID) {
+  void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCInterfaceDecl));
+  return new (Mem) ObjCInterfaceDecl(0, SourceLocation(), 0, SourceLocation(),
+                                     0, false);
 }
 
 ObjCInterfaceDecl::
@@ -924,6 +932,12 @@
                               ac, BW, synthesized);
 }
 
+ObjCIvarDecl *ObjCIvarDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
+  void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCIvarDecl));
+  return new (Mem) ObjCIvarDecl(0, SourceLocation(), SourceLocation(), 0,
+                                QualType(), 0, ObjCIvarDecl::None, 0, false);
+}
+
 const ObjCInterfaceDecl *ObjCIvarDecl::getContainingInterface() const {
   const ObjCContainerDecl *DC = cast<ObjCContainerDecl>(getDeclContext());
 
@@ -961,6 +975,13 @@
   return new (C) ObjCAtDefsFieldDecl(DC, StartLoc, IdLoc, Id, T, BW);
 }
 
+ObjCAtDefsFieldDecl *ObjCAtDefsFieldDecl::CreateDeserialized(ASTContext &C, 
+                                                             unsigned ID) {
+  void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCAtDefsFieldDecl));
+  return new (Mem) ObjCAtDefsFieldDecl(0, SourceLocation(), SourceLocation(),
+                                       0, QualType(), 0);
+}
+
 //===----------------------------------------------------------------------===//
 // ObjCProtocolDecl
 //===----------------------------------------------------------------------===//
@@ -989,6 +1010,13 @@
   return Result;
 }
 
+ObjCProtocolDecl *ObjCProtocolDecl::CreateDeserialized(ASTContext &C, 
+                                                       unsigned ID) {
+  void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCProtocolDecl));
+  return new (Mem) ObjCProtocolDecl(0, 0, SourceLocation(), SourceLocation(),
+                                    0);
+}
+
 ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) {
   ObjCProtocolDecl *PDecl = this;
 
@@ -1063,9 +1091,11 @@
   return CatDecl;
 }
 
-ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, EmptyShell Empty) {
-  return new (C) ObjCCategoryDecl(0, SourceLocation(), SourceLocation(),
-                                  SourceLocation(), 0, 0);
+ObjCCategoryDecl *ObjCCategoryDecl::CreateDeserialized(ASTContext &C, 
+                                                       unsigned ID) {
+  void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCCategoryDecl));
+  return new (Mem) ObjCCategoryDecl(0, SourceLocation(), SourceLocation(),
+                                    SourceLocation(), 0, 0);
 }
 
 ObjCCategoryImplDecl *ObjCCategoryDecl::getImplementation() const {
@@ -1097,6 +1127,13 @@
                                       nameLoc, atStartLoc, CategoryNameLoc);
 }
 
+ObjCCategoryImplDecl *ObjCCategoryImplDecl::CreateDeserialized(ASTContext &C, 
+                                                               unsigned ID) {
+  void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCCategoryImplDecl));
+  return new (Mem) ObjCCategoryImplDecl(0, 0, 0, SourceLocation(), 
+                                        SourceLocation(), SourceLocation());
+}
+
 ObjCCategoryDecl *ObjCCategoryImplDecl::getCategoryDecl() const {
   // The class interface might be NULL if we are working with invalid code.
   if (const ObjCInterfaceDecl *ID = getClassInterface())
@@ -1183,6 +1220,13 @@
                                         nameLoc, atStartLoc);
 }
 
+ObjCImplementationDecl *
+ObjCImplementationDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
+  void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCImplementationDecl));
+  return new (Mem) ObjCImplementationDecl(0, 0, 0, SourceLocation(), 
+                                          SourceLocation());
+}
+
 void ObjCImplementationDecl::setIvarInitializers(ASTContext &C,
                                              CXXCtorInitializer ** initializers,
                                                  unsigned numInitializers) {
@@ -1216,6 +1260,12 @@
   return new (C) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass);
 }
 
+ObjCCompatibleAliasDecl *
+ObjCCompatibleAliasDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
+  void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCCompatibleAliasDecl));
+  return new (Mem) ObjCCompatibleAliasDecl(0, SourceLocation(), 0, 0);
+}
+
 //===----------------------------------------------------------------------===//
 // ObjCPropertyDecl
 //===----------------------------------------------------------------------===//
@@ -1231,6 +1281,13 @@
   return new (C) ObjCPropertyDecl(DC, L, Id, AtLoc, T);
 }
 
+ObjCPropertyDecl *ObjCPropertyDecl::CreateDeserialized(ASTContext &C, 
+                                                       unsigned ID) {
+  void * Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCPropertyDecl));
+  return new (Mem) ObjCPropertyDecl(0, SourceLocation(), 0, SourceLocation(),
+                                    0);
+}
+
 //===----------------------------------------------------------------------===//
 // ObjCPropertyImplDecl
 //===----------------------------------------------------------------------===//
@@ -1247,6 +1304,13 @@
                                       ivarLoc);
 }
 
+ObjCPropertyImplDecl *ObjCPropertyImplDecl::CreateDeserialized(ASTContext &C, 
+                                                               unsigned ID) {
+  void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCPropertyImplDecl));
+  return new (Mem) ObjCPropertyImplDecl(0, SourceLocation(), SourceLocation(),
+                                        0, Dynamic, 0, SourceLocation());
+}
+
 SourceRange ObjCPropertyImplDecl::getSourceRange() const {
   SourceLocation EndLoc = getLocation();
   if (IvarLoc.isValid())