mirror of
https://github.com/intel/llvm.git
synced 2026-02-03 19:18:13 +08:00
Remove many references to ASTContext::getAllocator(), replacing them with calls to the recently added placement new (which uses ASTContext's allocator for memory). Also added ASTContext::Deallocate().
This will simplify runtime replacement of ASTContext's allocator. Keeping the allocator private (and removing getAllocator() entirely) is also goodness. llvm-svn: 63135
This commit is contained in:
@@ -129,6 +129,8 @@ public:
|
||||
|
||||
SourceManager& getSourceManager() { return SourceMgr; }
|
||||
llvm::MallocAllocator &getAllocator() { return Allocator; }
|
||||
void Deallocate(void *Ptr) { Allocator.Deallocate(Ptr); }
|
||||
|
||||
const LangOptions& getLangOptions() const { return LangOpts; }
|
||||
|
||||
FullSourceLoc getFullLoc(SourceLocation Loc) const {
|
||||
@@ -567,7 +569,7 @@ private:
|
||||
FieldDecl *Field,
|
||||
bool OutermostType = false,
|
||||
bool EncodingProperty = false) const;
|
||||
|
||||
|
||||
};
|
||||
|
||||
} // end namespace clang
|
||||
|
||||
@@ -24,14 +24,12 @@ using namespace clang;
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
TranslationUnitDecl *TranslationUnitDecl::Create(ASTContext &C) {
|
||||
void *Mem = C.getAllocator().Allocate<TranslationUnitDecl>();
|
||||
return new (Mem) TranslationUnitDecl();
|
||||
return new (C) TranslationUnitDecl();
|
||||
}
|
||||
|
||||
NamespaceDecl *NamespaceDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L, IdentifierInfo *Id) {
|
||||
void *Mem = C.getAllocator().Allocate<NamespaceDecl>();
|
||||
return new (Mem) NamespaceDecl(DC, L, Id);
|
||||
return new (C) NamespaceDecl(DC, L, Id);
|
||||
}
|
||||
|
||||
void NamespaceDecl::Destroy(ASTContext& C) {
|
||||
@@ -39,22 +37,20 @@ void NamespaceDecl::Destroy(ASTContext& C) {
|
||||
// together. They are all top-level Decls.
|
||||
|
||||
this->~NamespaceDecl();
|
||||
C.getAllocator().Deallocate((void *)this);
|
||||
C.Deallocate((void *)this);
|
||||
}
|
||||
|
||||
|
||||
ImplicitParamDecl *ImplicitParamDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L, IdentifierInfo *Id, QualType T) {
|
||||
void *Mem = C.getAllocator().Allocate<ImplicitParamDecl>();
|
||||
return new (Mem) ImplicitParamDecl(ImplicitParam, DC, L, Id, T);
|
||||
return new (C) ImplicitParamDecl(ImplicitParam, DC, L, Id, T);
|
||||
}
|
||||
|
||||
ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L, IdentifierInfo *Id,
|
||||
QualType T, StorageClass S,
|
||||
Expr *DefArg) {
|
||||
void *Mem = C.getAllocator().Allocate<ParmVarDecl>();
|
||||
return new (Mem) ParmVarDecl(ParmVar, DC, L, Id, T, S, DefArg);
|
||||
return new (C) ParmVarDecl(ParmVar, DC, L, Id, T, S, DefArg);
|
||||
}
|
||||
|
||||
QualType ParmVarDecl::getOriginalType() const {
|
||||
@@ -69,8 +65,7 @@ ParmVarWithOriginalTypeDecl *ParmVarWithOriginalTypeDecl::Create(
|
||||
SourceLocation L, IdentifierInfo *Id,
|
||||
QualType T, QualType OT, StorageClass S,
|
||||
Expr *DefArg) {
|
||||
void *Mem = C.getAllocator().Allocate<ParmVarWithOriginalTypeDecl>();
|
||||
return new (Mem) ParmVarWithOriginalTypeDecl(DC, L, Id, T, OT, S, DefArg);
|
||||
return new (C) ParmVarWithOriginalTypeDecl(DC, L, Id, T, OT, S, DefArg);
|
||||
}
|
||||
|
||||
FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
@@ -78,21 +73,18 @@ FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
DeclarationName N, QualType T,
|
||||
StorageClass S, bool isInline,
|
||||
SourceLocation TypeSpecStartLoc) {
|
||||
void *Mem = C.getAllocator().Allocate<FunctionDecl>();
|
||||
return new (Mem) FunctionDecl(Function, DC, L, N, T, S, isInline,
|
||||
return new (C) FunctionDecl(Function, DC, L, N, T, S, isInline,
|
||||
TypeSpecStartLoc);
|
||||
}
|
||||
|
||||
BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) {
|
||||
void *Mem = C.getAllocator().Allocate<BlockDecl>();
|
||||
return new (Mem) BlockDecl(DC, L);
|
||||
return new (C) BlockDecl(DC, L);
|
||||
}
|
||||
|
||||
FieldDecl *FieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
|
||||
IdentifierInfo *Id, QualType T, Expr *BW,
|
||||
bool Mutable) {
|
||||
void *Mem = C.getAllocator().Allocate<FieldDecl>();
|
||||
return new (Mem) FieldDecl(Decl::Field, DC, L, Id, T, BW, Mutable);
|
||||
return new (C) FieldDecl(Decl::Field, DC, L, Id, T, BW, Mutable);
|
||||
}
|
||||
|
||||
bool FieldDecl::isAnonymousStructOrUnion() const {
|
||||
@@ -109,8 +101,7 @@ EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, EnumDecl *CD,
|
||||
SourceLocation L,
|
||||
IdentifierInfo *Id, QualType T,
|
||||
Expr *E, const llvm::APSInt &V) {
|
||||
void *Mem = C.getAllocator().Allocate<EnumConstantDecl>();
|
||||
return new (Mem) EnumConstantDecl(CD, L, Id, T, E, V);
|
||||
return new (C) EnumConstantDecl(CD, L, Id, T, E, V);
|
||||
}
|
||||
|
||||
void EnumConstantDecl::Destroy(ASTContext& C) {
|
||||
@@ -121,8 +112,7 @@ void EnumConstantDecl::Destroy(ASTContext& C) {
|
||||
TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L,
|
||||
IdentifierInfo *Id, QualType T) {
|
||||
void *Mem = C.getAllocator().Allocate<TypedefDecl>();
|
||||
return new (Mem) TypedefDecl(DC, L, Id, T);
|
||||
return new (C) TypedefDecl(DC, L, Id, T);
|
||||
}
|
||||
|
||||
EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
|
||||
@@ -147,8 +137,7 @@ void EnumDecl::completeDefinition(ASTContext &C, QualType NewType) {
|
||||
FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L,
|
||||
StringLiteral *Str) {
|
||||
void *Mem = C.getAllocator().Allocate<FileScopeAsmDecl>();
|
||||
return new (Mem) FileScopeAsmDecl(DC, L, Str);
|
||||
return new (C) FileScopeAsmDecl(DC, L, Str);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -176,13 +165,12 @@ bool NamedDecl::declarationReplaces(NamedDecl *OldD) const {
|
||||
VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
|
||||
IdentifierInfo *Id, QualType T, StorageClass S,
|
||||
SourceLocation TypeSpecStartLoc) {
|
||||
void *Mem = C.getAllocator().Allocate<VarDecl>();
|
||||
return new (Mem) VarDecl(Var, DC, L, Id, T, S, TypeSpecStartLoc);
|
||||
return new (C) VarDecl(Var, DC, L, Id, T, S, TypeSpecStartLoc);
|
||||
}
|
||||
|
||||
void VarDecl::Destroy(ASTContext& C) {
|
||||
this->~VarDecl();
|
||||
C.getAllocator().Deallocate((void *)this);
|
||||
C.Deallocate((void *)this);
|
||||
}
|
||||
|
||||
VarDecl::~VarDecl() {
|
||||
@@ -200,7 +188,7 @@ void FunctionDecl::Destroy(ASTContext& C) {
|
||||
for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
|
||||
(*I)->Destroy(C);
|
||||
|
||||
C.getAllocator().Deallocate(ParamInfo);
|
||||
C.Deallocate(ParamInfo);
|
||||
|
||||
Decl::Destroy(C);
|
||||
}
|
||||
@@ -309,8 +297,7 @@ RecordDecl *RecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
|
||||
SourceLocation L, IdentifierInfo *Id,
|
||||
RecordDecl* PrevDecl) {
|
||||
|
||||
void *Mem = C.getAllocator().Allocate<RecordDecl>();
|
||||
RecordDecl* R = new (Mem) RecordDecl(Record, TK, DC, L, Id);
|
||||
RecordDecl* R = new (C) RecordDecl(Record, TK, DC, L, Id);
|
||||
C.getTypeDeclType(R, PrevDecl);
|
||||
return R;
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ void Decl::Destroy(ASTContext& C) {
|
||||
}
|
||||
|
||||
this->~Decl();
|
||||
C.getAllocator().Deallocate((void *)this);
|
||||
C.Deallocate((void *)this);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -25,16 +25,14 @@ TemplateTypeParmDecl *
|
||||
TemplateTypeParmDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L, IdentifierInfo *Id,
|
||||
bool Typename) {
|
||||
void *Mem = C.getAllocator().Allocate<TemplateTypeParmDecl>();
|
||||
return new (Mem) TemplateTypeParmDecl(DC, L, Id, Typename);
|
||||
return new (C) TemplateTypeParmDecl(DC, L, Id, Typename);
|
||||
}
|
||||
|
||||
NonTypeTemplateParmDecl *
|
||||
NonTypeTemplateParmDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L, IdentifierInfo *Id,
|
||||
QualType T, SourceLocation TypeSpecStartLoc) {
|
||||
void *Mem = C.getAllocator().Allocate<NonTypeTemplateParmDecl>();
|
||||
return new (Mem) NonTypeTemplateParmDecl(DC, L, Id, T, TypeSpecStartLoc);
|
||||
return new (C) NonTypeTemplateParmDecl(DC, L, Id, T, TypeSpecStartLoc);
|
||||
}
|
||||
|
||||
TemplateParameterList::TemplateParameterList(Decl **Params, unsigned NumParams)
|
||||
@@ -46,6 +44,7 @@ TemplateParameterList::TemplateParameterList(Decl **Params, unsigned NumParams)
|
||||
TemplateParameterList *
|
||||
TemplateParameterList::Create(ASTContext &C, Decl **Params,
|
||||
unsigned NumParams) {
|
||||
// FIXME: how do I pass in Size to ASTContext::new?
|
||||
unsigned Size = sizeof(TemplateParameterList) + sizeof(Decl *) * NumParams;
|
||||
unsigned Align = llvm::AlignOf<TemplateParameterList>::Alignment;
|
||||
void *Mem = C.getAllocator().Allocate(Size, Align);
|
||||
@@ -63,8 +62,7 @@ CXXRecordDecl::CXXRecordDecl(TagKind TK, DeclContext *DC,
|
||||
CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
|
||||
SourceLocation L, IdentifierInfo *Id,
|
||||
CXXRecordDecl* PrevDecl) {
|
||||
void *Mem = C.getAllocator().Allocate<CXXRecordDecl>();
|
||||
CXXRecordDecl* R = new (Mem) CXXRecordDecl(TK, DC, L, Id);
|
||||
CXXRecordDecl* R = new (C) CXXRecordDecl(TK, DC, L, Id);
|
||||
C.getTypeDeclType(R, PrevDecl);
|
||||
return R;
|
||||
}
|
||||
@@ -211,8 +209,7 @@ CXXMethodDecl *
|
||||
CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD,
|
||||
SourceLocation L, DeclarationName N,
|
||||
QualType T, bool isStatic, bool isInline) {
|
||||
void *Mem = C.getAllocator().Allocate<CXXMethodDecl>();
|
||||
return new (Mem) CXXMethodDecl(CXXMethod, RD, L, N, T, isStatic, isInline);
|
||||
return new (C) CXXMethodDecl(CXXMethod, RD, L, N, T, isStatic, isInline);
|
||||
}
|
||||
|
||||
QualType CXXMethodDecl::getThisType(ASTContext &C) const {
|
||||
@@ -268,8 +265,7 @@ CXXConstructorDecl::Create(ASTContext &C, CXXRecordDecl *RD,
|
||||
bool isInline, bool isImplicitlyDeclared) {
|
||||
assert(N.getNameKind() == DeclarationName::CXXConstructorName &&
|
||||
"Name must refer to a constructor");
|
||||
void *Mem = C.getAllocator().Allocate<CXXConstructorDecl>();
|
||||
return new (Mem) CXXConstructorDecl(RD, L, N, T, isExplicit, isInline,
|
||||
return new (C) CXXConstructorDecl(RD, L, N, T, isExplicit, isInline,
|
||||
isImplicitlyDeclared);
|
||||
}
|
||||
|
||||
@@ -336,9 +332,8 @@ CXXDestructorDecl::Create(ASTContext &C, CXXRecordDecl *RD,
|
||||
bool isImplicitlyDeclared) {
|
||||
assert(N.getNameKind() == DeclarationName::CXXDestructorName &&
|
||||
"Name must refer to a destructor");
|
||||
void *Mem = C.getAllocator().Allocate<CXXDestructorDecl>();
|
||||
return new (Mem) CXXDestructorDecl(RD, L, N, T, isInline,
|
||||
isImplicitlyDeclared);
|
||||
return new (C) CXXDestructorDecl(RD, L, N, T, isInline,
|
||||
isImplicitlyDeclared);
|
||||
}
|
||||
|
||||
CXXConversionDecl *
|
||||
@@ -347,28 +342,24 @@ CXXConversionDecl::Create(ASTContext &C, CXXRecordDecl *RD,
|
||||
QualType T, bool isInline, bool isExplicit) {
|
||||
assert(N.getNameKind() == DeclarationName::CXXConversionFunctionName &&
|
||||
"Name must refer to a conversion function");
|
||||
void *Mem = C.getAllocator().Allocate<CXXConversionDecl>();
|
||||
return new (Mem) CXXConversionDecl(RD, L, N, T, isInline, isExplicit);
|
||||
return new (C) CXXConversionDecl(RD, L, N, T, isInline, isExplicit);
|
||||
}
|
||||
|
||||
CXXClassVarDecl *CXXClassVarDecl::Create(ASTContext &C, CXXRecordDecl *RD,
|
||||
SourceLocation L, IdentifierInfo *Id,
|
||||
QualType T) {
|
||||
void *Mem = C.getAllocator().Allocate<CXXClassVarDecl>();
|
||||
return new (Mem) CXXClassVarDecl(RD, L, Id, T);
|
||||
return new (C) CXXClassVarDecl(RD, L, Id, T);
|
||||
}
|
||||
|
||||
OverloadedFunctionDecl *
|
||||
OverloadedFunctionDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
DeclarationName N) {
|
||||
void *Mem = C.getAllocator().Allocate<OverloadedFunctionDecl>();
|
||||
return new (Mem) OverloadedFunctionDecl(DC, N);
|
||||
return new (C) OverloadedFunctionDecl(DC, N);
|
||||
}
|
||||
|
||||
LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C,
|
||||
DeclContext *DC,
|
||||
SourceLocation L,
|
||||
LanguageIDs Lang, bool Braces) {
|
||||
void *Mem = C.getAllocator().Allocate<LinkageSpecDecl>();
|
||||
return new (Mem) LinkageSpecDecl(DC, L, Lang, Braces);
|
||||
return new (C) LinkageSpecDecl(DC, L, Lang, Braces);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ void DeclGroup::Destroy(ASTContext& C) {
|
||||
Decls[i]->Destroy(C);
|
||||
|
||||
this->~DeclGroup();
|
||||
C.getAllocator().Deallocate((void*) this);
|
||||
C.Deallocate((void*) this);
|
||||
}
|
||||
|
||||
DeclGroupOwningRef::~DeclGroupOwningRef() {
|
||||
|
||||
@@ -29,8 +29,7 @@ ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C,
|
||||
bool isVariadic,
|
||||
bool isSynthesized,
|
||||
ImplementationControl impControl) {
|
||||
void *Mem = C.getAllocator().Allocate<ObjCMethodDecl>();
|
||||
return new (Mem) ObjCMethodDecl(beginLoc, endLoc,
|
||||
return new (C) ObjCMethodDecl(beginLoc, endLoc,
|
||||
SelInfo, T, contextDecl,
|
||||
isInstance,
|
||||
isVariadic, isSynthesized, impControl);
|
||||
@@ -56,8 +55,7 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::Create(ASTContext &C,
|
||||
IdentifierInfo *Id,
|
||||
SourceLocation ClassLoc,
|
||||
bool ForwardDecl, bool isInternal){
|
||||
void *Mem = C.getAllocator().Allocate<ObjCInterfaceDecl>();
|
||||
return new (Mem) ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, ForwardDecl,
|
||||
return new (C) ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, ForwardDecl,
|
||||
isInternal);
|
||||
}
|
||||
|
||||
@@ -83,28 +81,25 @@ void ObjCInterfaceDecl::Destroy(ASTContext& C) {
|
||||
ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, SourceLocation L,
|
||||
IdentifierInfo *Id, QualType T,
|
||||
AccessControl ac, Expr *BW) {
|
||||
void *Mem = C.getAllocator().Allocate<ObjCIvarDecl>();
|
||||
return new (Mem) ObjCIvarDecl(L, Id, T, ac, BW);
|
||||
return new (C) ObjCIvarDecl(L, Id, T, ac, BW);
|
||||
}
|
||||
|
||||
|
||||
ObjCAtDefsFieldDecl
|
||||
*ObjCAtDefsFieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
|
||||
IdentifierInfo *Id, QualType T, Expr *BW) {
|
||||
void *Mem = C.getAllocator().Allocate<ObjCAtDefsFieldDecl>();
|
||||
return new (Mem) ObjCAtDefsFieldDecl(DC, L, Id, T, BW);
|
||||
return new (C) ObjCAtDefsFieldDecl(DC, L, Id, T, BW);
|
||||
}
|
||||
|
||||
void ObjCAtDefsFieldDecl::Destroy(ASTContext& C) {
|
||||
this->~ObjCAtDefsFieldDecl();
|
||||
C.getAllocator().Deallocate((void *)this);
|
||||
C.Deallocate((void *)this);
|
||||
}
|
||||
|
||||
ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L,
|
||||
IdentifierInfo *Id) {
|
||||
void *Mem = C.getAllocator().Allocate<ObjCProtocolDecl>();
|
||||
return new (Mem) ObjCProtocolDecl(DC, L, Id);
|
||||
return new (C) ObjCProtocolDecl(DC, L, Id);
|
||||
}
|
||||
|
||||
ObjCProtocolDecl::~ObjCProtocolDecl() {
|
||||
@@ -115,8 +110,7 @@ ObjCProtocolDecl::~ObjCProtocolDecl() {
|
||||
ObjCClassDecl *ObjCClassDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L,
|
||||
ObjCInterfaceDecl **Elts, unsigned nElts) {
|
||||
void *Mem = C.getAllocator().Allocate<ObjCClassDecl>();
|
||||
return new (Mem) ObjCClassDecl(DC, L, Elts, nElts);
|
||||
return new (C) ObjCClassDecl(DC, L, Elts, nElts);
|
||||
}
|
||||
|
||||
ObjCClassDecl::~ObjCClassDecl() {
|
||||
@@ -140,8 +134,7 @@ ObjCForwardProtocolDecl *
|
||||
ObjCForwardProtocolDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L,
|
||||
ObjCProtocolDecl **Elts, unsigned NumElts) {
|
||||
void *Mem = C.getAllocator().Allocate<ObjCForwardProtocolDecl>();
|
||||
return new (Mem) ObjCForwardProtocolDecl(DC, L, Elts, NumElts);
|
||||
return new (C) ObjCForwardProtocolDecl(DC, L, Elts, NumElts);
|
||||
}
|
||||
|
||||
ObjCForwardProtocolDecl::~ObjCForwardProtocolDecl() {
|
||||
@@ -151,16 +144,14 @@ ObjCForwardProtocolDecl::~ObjCForwardProtocolDecl() {
|
||||
ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L,
|
||||
IdentifierInfo *Id) {
|
||||
void *Mem = C.getAllocator().Allocate<ObjCCategoryDecl>();
|
||||
return new (Mem) ObjCCategoryDecl(DC, L, Id);
|
||||
return new (C) ObjCCategoryDecl(DC, L, Id);
|
||||
}
|
||||
|
||||
ObjCCategoryImplDecl *
|
||||
ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L,IdentifierInfo *Id,
|
||||
ObjCInterfaceDecl *ClassInterface) {
|
||||
void *Mem = C.getAllocator().Allocate<ObjCCategoryImplDecl>();
|
||||
return new (Mem) ObjCCategoryImplDecl(DC, L, Id, ClassInterface);
|
||||
return new (C) ObjCCategoryImplDecl(DC, L, Id, ClassInterface);
|
||||
}
|
||||
|
||||
ObjCImplementationDecl *
|
||||
@@ -168,8 +159,7 @@ ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L,
|
||||
ObjCInterfaceDecl *ClassInterface,
|
||||
ObjCInterfaceDecl *SuperDecl) {
|
||||
void *Mem = C.getAllocator().Allocate<ObjCImplementationDecl>();
|
||||
return new (Mem) ObjCImplementationDecl(DC, L, ClassInterface, SuperDecl);
|
||||
return new (C) ObjCImplementationDecl(DC, L, ClassInterface, SuperDecl);
|
||||
}
|
||||
|
||||
ObjCCompatibleAliasDecl *
|
||||
@@ -177,8 +167,7 @@ ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L,
|
||||
IdentifierInfo *Id,
|
||||
ObjCInterfaceDecl* AliasedClass) {
|
||||
void *Mem = C.getAllocator().Allocate<ObjCCompatibleAliasDecl>();
|
||||
return new (Mem) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass);
|
||||
return new (C) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass);
|
||||
}
|
||||
|
||||
ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
@@ -186,8 +175,7 @@ ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
IdentifierInfo *Id,
|
||||
QualType T,
|
||||
PropertyControl propControl) {
|
||||
void *Mem = C.getAllocator().Allocate<ObjCPropertyDecl>();
|
||||
return new (Mem) ObjCPropertyDecl(DC, L, Id, T);
|
||||
return new (C) ObjCPropertyDecl(DC, L, Id, T);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -638,8 +626,7 @@ ObjCPropertyImplDecl *ObjCPropertyImplDecl::Create(ASTContext &C,
|
||||
ObjCPropertyDecl *property,
|
||||
Kind PK,
|
||||
ObjCIvarDecl *ivar) {
|
||||
void *Mem = C.getAllocator().Allocate<ObjCPropertyImplDecl>();
|
||||
return new (Mem) ObjCPropertyImplDecl(DC, atLoc, L, property, PK, ivar);
|
||||
return new (C) ObjCPropertyImplDecl(DC, atLoc, L, property, PK, ivar);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -303,10 +303,7 @@ void TranslationUnitDecl::EmitImpl(llvm::Serializer& S) const
|
||||
|
||||
TranslationUnitDecl* TranslationUnitDecl::CreateImpl(Deserializer& D,
|
||||
ASTContext& C) {
|
||||
void *Mem = C.getAllocator().Allocate<TranslationUnitDecl>();
|
||||
TranslationUnitDecl* decl = new (Mem) TranslationUnitDecl();
|
||||
|
||||
return decl;
|
||||
return new (C) TranslationUnitDecl();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -321,8 +318,7 @@ void NamespaceDecl::EmitImpl(llvm::Serializer& S) const
|
||||
}
|
||||
|
||||
NamespaceDecl* NamespaceDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
||||
void *Mem = C.getAllocator().Allocate<NamespaceDecl>();
|
||||
NamespaceDecl* decl = new (Mem) NamespaceDecl(0, SourceLocation(), 0);
|
||||
NamespaceDecl* decl = new (C) NamespaceDecl(0, SourceLocation(), 0);
|
||||
|
||||
decl->NamedDecl::ReadInRec(D, C);
|
||||
decl->LBracLoc = SourceLocation::ReadVal(D);
|
||||
@@ -336,9 +332,8 @@ NamespaceDecl* NamespaceDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
VarDecl* VarDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
||||
void *Mem = C.getAllocator().Allocate<VarDecl>();
|
||||
VarDecl* decl =
|
||||
new (Mem) VarDecl(Var, 0, SourceLocation(), NULL, QualType(), None);
|
||||
new (C) VarDecl(Var, 0, SourceLocation(), NULL, QualType(), None);
|
||||
|
||||
decl->VarDecl::ReadImpl(D, C);
|
||||
return decl;
|
||||
@@ -355,8 +350,7 @@ void ParmVarDecl::EmitImpl(llvm::Serializer& S) const {
|
||||
}
|
||||
|
||||
ParmVarDecl* ParmVarDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
||||
void *Mem = C.getAllocator().Allocate<ParmVarDecl>();
|
||||
ParmVarDecl* decl = new (Mem)
|
||||
ParmVarDecl* decl = new (C)
|
||||
ParmVarDecl(ParmVar,
|
||||
0, SourceLocation(), NULL, QualType(), None, NULL);
|
||||
|
||||
@@ -377,8 +371,7 @@ void ParmVarWithOriginalTypeDecl::EmitImpl(llvm::Serializer& S) const {
|
||||
|
||||
ParmVarWithOriginalTypeDecl* ParmVarWithOriginalTypeDecl::CreateImpl(
|
||||
Deserializer& D, ASTContext& C) {
|
||||
void *Mem = C.getAllocator().Allocate<ParmVarWithOriginalTypeDecl>();
|
||||
ParmVarWithOriginalTypeDecl* decl = new (Mem)
|
||||
ParmVarWithOriginalTypeDecl* decl = new (C)
|
||||
ParmVarWithOriginalTypeDecl(0, SourceLocation(), NULL, QualType(),
|
||||
QualType(), None, NULL);
|
||||
|
||||
@@ -397,8 +390,7 @@ void EnumDecl::EmitImpl(Serializer& S) const {
|
||||
}
|
||||
|
||||
EnumDecl* EnumDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
||||
void *Mem = C.getAllocator().Allocate<EnumDecl>();
|
||||
EnumDecl* decl = new (Mem) EnumDecl(0, SourceLocation(), NULL);
|
||||
EnumDecl* decl = new (C) EnumDecl(0, SourceLocation(), NULL);
|
||||
|
||||
decl->NamedDecl::ReadInRec(D, C);
|
||||
decl->setDefinition(D.ReadBool());
|
||||
@@ -421,8 +413,7 @@ EnumConstantDecl* EnumConstantDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
||||
llvm::APSInt val(1);
|
||||
D.Read(val);
|
||||
|
||||
void *Mem = C.getAllocator().Allocate<EnumConstantDecl>();
|
||||
EnumConstantDecl* decl = new (Mem)
|
||||
EnumConstantDecl* decl = new (C)
|
||||
EnumConstantDecl(0, SourceLocation(), NULL, QualType(), NULL, val);
|
||||
|
||||
decl->ValueDecl::ReadInRec(D, C);
|
||||
@@ -442,8 +433,7 @@ void FieldDecl::EmitImpl(Serializer& S) const {
|
||||
}
|
||||
|
||||
FieldDecl* FieldDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
||||
void *Mem = C.getAllocator().Allocate<FieldDecl>();
|
||||
FieldDecl* decl = new (Mem) FieldDecl(Field, 0, SourceLocation(), NULL,
|
||||
FieldDecl* decl = new (C) FieldDecl(Field, 0, SourceLocation(), NULL,
|
||||
QualType(), 0, false);
|
||||
decl->Mutable = D.ReadBool();
|
||||
decl->DeclType.ReadBackpatch(D);
|
||||
@@ -480,8 +470,7 @@ FunctionDecl* FunctionDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
||||
StorageClass SClass = static_cast<StorageClass>(D.ReadInt());
|
||||
bool IsInline = D.ReadBool();
|
||||
|
||||
void *Mem = C.getAllocator().Allocate<FunctionDecl>();
|
||||
FunctionDecl* decl = new (Mem)
|
||||
FunctionDecl* decl = new (C)
|
||||
FunctionDecl(Function, 0, SourceLocation(), DeclarationName(),
|
||||
QualType(), SClass, IsInline);
|
||||
|
||||
@@ -537,8 +526,7 @@ void OverloadedFunctionDecl::EmitImpl(Serializer& S) const {
|
||||
|
||||
OverloadedFunctionDecl *
|
||||
OverloadedFunctionDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
||||
void *Mem = C.getAllocator().Allocate<OverloadedFunctionDecl>();
|
||||
OverloadedFunctionDecl* decl = new (Mem)
|
||||
OverloadedFunctionDecl* decl = new (C)
|
||||
OverloadedFunctionDecl(0, DeclarationName());
|
||||
|
||||
decl->NamedDecl::ReadInRec(D, C);
|
||||
@@ -567,8 +555,7 @@ void RecordDecl::EmitImpl(Serializer& S) const {
|
||||
RecordDecl* RecordDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
||||
TagKind TK = TagKind(D.ReadInt());
|
||||
|
||||
void *Mem = C.getAllocator().Allocate<RecordDecl>();
|
||||
RecordDecl* decl = new (Mem) RecordDecl(Record, TK, 0, SourceLocation(), NULL);
|
||||
RecordDecl* decl = new (C) RecordDecl(Record, TK, 0, SourceLocation(), NULL);
|
||||
|
||||
decl->NamedDecl::ReadInRec(D, C);
|
||||
decl->setDefinition(D.ReadBool());
|
||||
@@ -590,8 +577,7 @@ void TypedefDecl::EmitImpl(Serializer& S) const {
|
||||
TypedefDecl* TypedefDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
||||
QualType T = QualType::ReadVal(D);
|
||||
|
||||
void *Mem = C.getAllocator().Allocate<TypedefDecl>();
|
||||
TypedefDecl* decl = new (Mem) TypedefDecl(0, SourceLocation(), NULL, T);
|
||||
TypedefDecl* decl = new (C) TypedefDecl(0, SourceLocation(), NULL, T);
|
||||
|
||||
decl->NamedDecl::ReadInRec(D, C);
|
||||
|
||||
@@ -610,9 +596,8 @@ void TemplateTypeParmDecl::EmitImpl(Serializer& S) const {
|
||||
TemplateTypeParmDecl *
|
||||
TemplateTypeParmDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
||||
bool Typename = D.ReadBool();
|
||||
void *Mem = C.getAllocator().Allocate<TemplateTypeParmDecl>();
|
||||
TemplateTypeParmDecl *decl
|
||||
= new (Mem) TemplateTypeParmDecl(0, SourceLocation(), NULL, Typename);
|
||||
= new (C) TemplateTypeParmDecl(0, SourceLocation(), NULL, Typename);
|
||||
decl->NamedDecl::ReadInRec(D, C);
|
||||
return decl;
|
||||
}
|
||||
@@ -641,8 +626,7 @@ void FileScopeAsmDecl::EmitImpl(llvm::Serializer& S) const
|
||||
}
|
||||
|
||||
FileScopeAsmDecl* FileScopeAsmDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
||||
void *Mem = C.getAllocator().Allocate<FileScopeAsmDecl>();
|
||||
FileScopeAsmDecl* decl = new (Mem) FileScopeAsmDecl(0, SourceLocation(), 0);
|
||||
FileScopeAsmDecl* decl = new (C) FileScopeAsmDecl(0, SourceLocation(), 0);
|
||||
|
||||
decl->AsmString = cast<StringLiteral>(D.ReadOwnedPtr<Expr>(C));
|
||||
// D.ReadOwnedPtr(D.ReadOwnedPtr<StringLiteral>())<#T * * Ptr#>, <#bool AutoRegister#>)(decl->AsmString);
|
||||
|
||||
@@ -32,19 +32,19 @@ bool QualType::isConstant(ASTContext &Ctx) const {
|
||||
|
||||
void Type::Destroy(ASTContext& C) {
|
||||
this->~Type();
|
||||
C.getAllocator().Deallocate(this);
|
||||
C.Deallocate(this);
|
||||
}
|
||||
|
||||
void VariableArrayType::Destroy(ASTContext& C) {
|
||||
SizeExpr->Destroy(C);
|
||||
this->~VariableArrayType();
|
||||
C.getAllocator().Deallocate(this);
|
||||
C.Deallocate(this);
|
||||
}
|
||||
|
||||
void DependentSizedArrayType::Destroy(ASTContext& C) {
|
||||
SizeExpr->Destroy(C);
|
||||
this->~DependentSizedArrayType();
|
||||
C.getAllocator().Deallocate(this);
|
||||
C.Deallocate(this);
|
||||
}
|
||||
|
||||
/// getArrayElementTypeNoTypeQual - If this is an array type, return the
|
||||
|
||||
Reference in New Issue
Block a user