diff options
author | Chris Lattner <sabre@nondot.org> | 2008-03-16 00:16:02 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-03-16 00:16:02 +0000 |
commit | ee1284a6e20097fe1fe0fa1f16ab95c596bcea4a (patch) | |
tree | 5a4c72dc49dcce3dfe6c35cbb2912c897a714d19 /clang/lib | |
parent | 7a51313d8a0a358bb92eb5dbf8fd846b7c48e7fe (diff) | |
download | bcm5719-llvm-ee1284a6e20097fe1fe0fa1f16ab95c596bcea4a.tar.gz bcm5719-llvm-ee1284a6e20097fe1fe0fa1f16ab95c596bcea4a.zip |
switch the rest of the C decl classes to do their
allocation through ASTContext.
llvm-svn: 48403
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/ASTContext.cpp | 3 | ||||
-rw-r--r-- | clang/lib/AST/Decl.cpp | 17 | ||||
-rw-r--r-- | clang/lib/AST/DeclSerialization.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/Sema.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 6 |
5 files changed, 25 insertions, 7 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index db4d53aa481..902f422dacb 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -1064,7 +1064,8 @@ QualType ASTContext::getCFConstantStringType() { FieldDecl *FieldDecls[4]; for (unsigned i = 0; i < 4; ++i) - FieldDecls[i] = new FieldDecl(SourceLocation(), 0, FieldTypes[i]); + FieldDecls[i] = FieldDecl::Create(*this, SourceLocation(), 0, + FieldTypes[i]); CFConstantStringTypeDecl->defineBody(FieldDecls, 4); } diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index 7fa679cbc08..4ce6fa8f3c4 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -235,6 +235,12 @@ FunctionDecl *FunctionDecl::Create(ASTContext &C, SourceLocation L, return new (Mem) FunctionDecl(L, Id, T, S, isInline, PrevDecl); } +FieldDecl *FieldDecl::Create(ASTContext &C, SourceLocation L, + IdentifierInfo *Id, QualType T, Expr *BW) { + void *Mem = C.getAllocator().Allocate<FieldDecl>(); + return new (Mem) FieldDecl(L, Id, T, BW); +} + EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, SourceLocation L, IdentifierInfo *Id, QualType T, @@ -263,6 +269,17 @@ RecordDecl *RecordDecl::Create(ASTContext &C, Kind DK, SourceLocation L, return new (Mem) RecordDecl(DK, L, Id, PrevDecl); } +FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C, SourceLocation L, + StringLiteral *Str) { + void *Mem = C.getAllocator().Allocate<FileScopeAsmDecl>(); + return new (Mem) FileScopeAsmDecl(L, Str); +} + +LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C, SourceLocation L, + LanguageIDs Lang, Decl *D) { + void *Mem = C.getAllocator().Allocate<LinkageSpecDecl>(); + return new (Mem) LinkageSpecDecl(L, Lang, D); +} //===----------------------------------------------------------------------===// // Decl Implementation diff --git a/clang/lib/AST/DeclSerialization.cpp b/clang/lib/AST/DeclSerialization.cpp index a7eaed5b2ef..fe2ccefdce2 100644 --- a/clang/lib/AST/DeclSerialization.cpp +++ b/clang/lib/AST/DeclSerialization.cpp @@ -302,7 +302,7 @@ void FieldDecl::EmitImpl(Serializer& S) const { } FieldDecl* FieldDecl::CreateImpl(Deserializer& D) { - FieldDecl* decl = new FieldDecl(SourceLocation(),NULL,QualType()); + FieldDecl* decl = new FieldDecl(SourceLocation(), NULL, QualType(), 0); decl->DeclType.ReadBackpatch(D); decl->ReadInRec(D); decl->BitWidth = D.ReadOwnedPtr<Expr>(); diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index 4bd04e3a1a5..f4c271cdcb1 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -116,8 +116,8 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer) RecordDecl *ObjectTag = RecordDecl::Create(Context, Decl::Struct, SourceLocation(), &IT.get("objc_object"), 0); - FieldDecl *IsaDecl = new FieldDecl(SourceLocation(), 0, - Context.getObjCClassType()); + FieldDecl *IsaDecl = FieldDecl::Create(Context, SourceLocation(), 0, + Context.getObjCClassType()); ObjectTag->defineBody(&IsaDecl, 1); QualType ObjT = Context.getPointerType(Context.getTagDeclType(ObjectTag)); TypedefDecl *IdTypedef = TypedefDecl::Create(Context, SourceLocation(), diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 7914e865741..28b396a8f0d 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -1332,7 +1332,7 @@ Sema::DeclTy *Sema::ActOnField(Scope *S, DeclTy *TagDecl, FieldDecl *NewFD; if (isa<RecordDecl>(static_cast<Decl *>(TagDecl))) - NewFD = new FieldDecl(Loc, II, T, BitWidth); + NewFD = FieldDecl::Create(Context, Loc, II, T, BitWidth); else if (isa<ObjCInterfaceDecl>(static_cast<Decl *>(TagDecl)) || isa<ObjCImplementationDecl>(static_cast<Decl *>(TagDecl)) || isa<ObjCCategoryDecl>(static_cast<Decl *>(TagDecl)) || @@ -1750,7 +1750,7 @@ Sema::DeclTy *Sema::ActOnFileScopeAsmDecl(SourceLocation Loc, ExprTy *expr) { StringLiteral *AsmString = cast<StringLiteral>((Expr*)expr); - return new FileScopeAsmDecl(Loc, AsmString); + return FileScopeAsmDecl::Create(Context, Loc, AsmString); } Sema::DeclTy* Sema::ActOnLinkageSpec(SourceLocation Loc, @@ -1771,7 +1771,7 @@ Sema::DeclTy* Sema::ActOnLinkageSpec(SourceLocation Loc, } // FIXME: Add all the various semantics of linkage specifications - return new LinkageSpecDecl(Loc, Language, dcl); + return LinkageSpecDecl::Create(Context, Loc, Language, dcl); } void Sema::HandleDeclAttribute(Decl *New, AttributeList *Attr) { |