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/Sema/Sema.cpp b/Sema/Sema.cpp
index 5b7a309..d854919 100644
--- a/Sema/Sema.cpp
+++ b/Sema/Sema.cpp
@@ -59,15 +59,16 @@
TUScope->AddDecl(IDecl);
// Synthesize "typedef struct objc_selector *SEL;"
- RecordDecl *SelTag = new RecordDecl(Decl::Struct, SourceLocation(),
- &Context.Idents.get("objc_selector"), 0);
+ RecordDecl *SelTag = RecordDecl::Create(Decl::Struct, SourceLocation(),
+ &Context.Idents.get("objc_selector"),
+ 0, Context);
SelTag->getIdentifier()->setFETokenInfo(SelTag);
TUScope->AddDecl(SelTag);
QualType SelT = Context.getPointerType(Context.getTagDeclType(SelTag));
- TypedefDecl *SelTypedef = new TypedefDecl(SourceLocation(),
- &Context.Idents.get("SEL"),
- SelT, 0);
+ TypedefDecl *SelTypedef = TypedefDecl::Create(SourceLocation(),
+ &Context.Idents.get("SEL"),
+ SelT, 0, Context);
SelTypedef->getIdentifier()->setFETokenInfo(SelTypedef);
TUScope->AddDecl(SelTypedef);
Context.setObjCSelType(SelTypedef);
@@ -96,12 +97,12 @@
// and make sure the decls get inserted into TUScope!
if (PP.getLangOptions().ObjC1) {
// Synthesize "typedef struct objc_class *Class;"
- RecordDecl *ClassTag = new RecordDecl(Decl::Struct, SourceLocation(),
- &IT.get("objc_class"), 0);
+ RecordDecl *ClassTag = RecordDecl::Create(Decl::Struct, SourceLocation(),
+ &IT.get("objc_class"), 0,Context);
QualType ClassT = Context.getPointerType(Context.getTagDeclType(ClassTag));
- TypedefDecl *ClassTypedef = new TypedefDecl(SourceLocation(),
- &Context.Idents.get("Class"),
- ClassT, 0);
+ TypedefDecl *ClassTypedef =
+ TypedefDecl::Create(SourceLocation(), &Context.Idents.get("Class"),
+ ClassT, 0, Context);
Context.setObjCClassType(ClassTypedef);
// Synthesize "@class Protocol;
@@ -110,15 +111,16 @@
Context.setObjCProtoType(Context.getObjCInterfaceType(ProtocolDecl));
// Synthesize "typedef struct objc_object { Class isa; } *id;"
- RecordDecl *ObjectTag = new RecordDecl(Decl::Struct, SourceLocation(),
- &IT.get("objc_object"), 0);
+ RecordDecl *ObjectTag =
+ RecordDecl::Create(Decl::Struct, SourceLocation(), &IT.get("objc_object"),
+ 0, Context);
FieldDecl *IsaDecl = new FieldDecl(SourceLocation(), 0,
Context.getObjCClassType());
ObjectTag->defineBody(&IsaDecl, 1);
QualType ObjT = Context.getPointerType(Context.getTagDeclType(ObjectTag));
- TypedefDecl *IdTypedef = new TypedefDecl(SourceLocation(),
- &Context.Idents.get("id"),
- ObjT, 0);
+ TypedefDecl *IdTypedef = TypedefDecl::Create(SourceLocation(),
+ &Context.Idents.get("id"),
+ ObjT, 0, Context);
Context.setObjCIdType(IdTypedef);
}
TUScope = 0;
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 300a382..90f9133 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -1175,8 +1175,9 @@
assert(!T.isNull() && "GetTypeForDeclarator() returned null type");
// Scope manipulation handled by caller.
- TypedefDecl *NewTD = new TypedefDecl(D.getIdentifierLoc(), D.getIdentifier(),
- T, LastDeclarator);
+ TypedefDecl *NewTD = TypedefDecl::Create(D.getIdentifierLoc(),
+ D.getIdentifier(),
+ T, LastDeclarator, Context);
if (D.getInvalidType())
NewTD->setInvalidDecl();
return NewTD;
@@ -1255,7 +1256,7 @@
case Decl::Enum:
// FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.:
// enum X { A, B, C } D; D should chain to X.
- New = new EnumDecl(Loc, Name, 0);
+ New = EnumDecl::Create(Loc, Name, 0, Context);
// If this is an undefined enum, warn.
if (TK != TK_Definition) Diag(Loc, diag::ext_forward_ref_enum);
break;
@@ -1264,7 +1265,7 @@
case Decl::Class:
// FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.:
// struct X { int A; } D; D should chain to X.
- New = new RecordDecl(Kind, Loc, Name, 0);
+ New = RecordDecl::Create(Kind, Loc, Name, 0, Context);
break;
}
@@ -1577,8 +1578,9 @@
}
}
- EnumConstantDecl *New = new EnumConstantDecl(IdLoc, Id, EltTy, Val, EnumVal,
- LastEnumConst);
+ EnumConstantDecl *New =
+ EnumConstantDecl::Create(IdLoc, Id, EltTy, Val, EnumVal, LastEnumConst,
+ Context);
// Register this decl in the current scope stack.
New->setNext(Id->getFETokenInfo<ScopedDecl>());