start switching decls over to using an allocator controlled by ASTContext.  
Right now only some ctors are switched over.  I need to switch them all
over so I can change the dtor over.

This lets us experiment with region allocation and other things in the 
future.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@48390 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp
index 3d312fa..ad54010 100644
--- a/AST/ASTContext.cpp
+++ b/AST/ASTContext.cpp
@@ -1047,9 +1047,9 @@
 // getCFConstantStringType - Return the type used for constant CFStrings. 
 QualType ASTContext::getCFConstantStringType() {
   if (!CFConstantStringTypeDecl) {
-    CFConstantStringTypeDecl = new RecordDecl(Decl::Struct, SourceLocation(), 
-                                              &Idents.get("NSConstantString"),
-                                              0);
+    CFConstantStringTypeDecl = 
+      RecordDecl::Create(Decl::Struct, SourceLocation(), 
+                         &Idents.get("NSConstantString"), 0, *this);
     QualType FieldTypes[4];
   
     // const int *isa;
diff --git a/AST/Decl.cpp b/AST/Decl.cpp
index 32ca419..aad8f21 100644
--- a/AST/Decl.cpp
+++ b/AST/Decl.cpp
@@ -13,6 +13,7 @@
 
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclObjC.h"
+#include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
 #include "clang/Basic/IdentifierTable.h"
 #include "llvm/ADT/DenseMap.h"
@@ -201,6 +202,37 @@
 }
 
 //===----------------------------------------------------------------------===//
+// Decl Allocation/Deallocation Method Implementations
+//===----------------------------------------------------------------------===//
+
+EnumConstantDecl *EnumConstantDecl::Create(SourceLocation L, IdentifierInfo *Id,
+                                           QualType T, Expr *E, 
+                                           const llvm::APSInt &V, 
+                                           ScopedDecl *PrevDecl, ASTContext &C){
+  void *Mem = C.getAllocator().Allocate<EnumConstantDecl>();
+  return new (Mem) EnumConstantDecl(L, Id, T, E, V, PrevDecl);
+}
+
+TypedefDecl *TypedefDecl::Create(SourceLocation L, IdentifierInfo *Id,
+                                 QualType T, ScopedDecl *PD, ASTContext &C) {
+  void *Mem = C.getAllocator().Allocate<TypedefDecl>();
+  return new (Mem) TypedefDecl(L, Id, T, PD);
+}
+
+EnumDecl *EnumDecl::Create(SourceLocation L, IdentifierInfo *Id,
+                           ScopedDecl *PrevDecl, ASTContext &C) {
+  void *Mem = C.getAllocator().Allocate<EnumDecl>();
+  return new (Mem) EnumDecl(L, Id, PrevDecl);
+}
+
+RecordDecl *RecordDecl::Create(Kind DK, SourceLocation L, IdentifierInfo *Id, 
+                               ScopedDecl *PrevDecl, ASTContext &C) {
+  void *Mem = C.getAllocator().Allocate<RecordDecl>();
+  return new (Mem) RecordDecl(DK, L, Id, PrevDecl);
+}
+
+
+//===----------------------------------------------------------------------===//
 // Decl Implementation
 //===----------------------------------------------------------------------===//
 
@@ -292,7 +324,6 @@
   return 0;
 }
 
-
 //===----------------------------------------------------------------------===//
 // Objective-C Decl Implementation
 //===----------------------------------------------------------------------===//