diff options
Diffstat (limited to 'clang/AST')
-rw-r--r-- | clang/AST/ASTContext.cpp | 6 | ||||
-rw-r--r-- | clang/AST/Decl.cpp | 33 |
2 files changed, 35 insertions, 4 deletions
diff --git a/clang/AST/ASTContext.cpp b/clang/AST/ASTContext.cpp index 3d312fa4a80..ad54010c500 100644 --- a/clang/AST/ASTContext.cpp +++ b/clang/AST/ASTContext.cpp @@ -1047,9 +1047,9 @@ QualType ASTContext::maxIntegerType(QualType lhs, QualType rhs) { // 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/clang/AST/Decl.cpp b/clang/AST/Decl.cpp index 32ca4198f56..aad8f212bfe 100644 --- a/clang/AST/Decl.cpp +++ b/clang/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 @@ void Decl::addDeclKind(Kind k) { } //===----------------------------------------------------------------------===// +// 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 @@ FieldDecl* RecordDecl::getMember(IdentifierInfo *name) { return 0; } - //===----------------------------------------------------------------------===// // Objective-C Decl Implementation //===----------------------------------------------------------------------===// |