diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/AST/Decl.cpp | 158 | ||||
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 21 | ||||
-rw-r--r-- | clang/lib/AST/DeclCXX.cpp | 169 | ||||
-rw-r--r-- | clang/lib/AST/DeclFriend.cpp | 14 | ||||
-rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 120 | ||||
-rw-r--r-- | clang/lib/AST/DeclOpenMP.cpp | 15 | ||||
-rw-r--r-- | clang/lib/AST/DeclTemplate.cpp | 162 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 8 |
9 files changed, 289 insertions, 384 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp index fe6f5fa5f42..75fa27bed60 100644 --- a/clang/lib/AST/Decl.cpp +++ b/clang/lib/AST/Decl.cpp @@ -1624,13 +1624,12 @@ VarDecl *VarDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation StartL, SourceLocation IdL, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S) { - return new (C) VarDecl(Var, DC, StartL, IdL, Id, T, TInfo, S); + return new (C, DC) VarDecl(Var, DC, StartL, IdL, Id, T, TInfo, S); } VarDecl *VarDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(VarDecl)); - return new (Mem) VarDecl(Var, 0, SourceLocation(), SourceLocation(), 0, - QualType(), 0, SC_None); + return new (C, ID) VarDecl(Var, 0, SourceLocation(), SourceLocation(), 0, + QualType(), 0, SC_None); } void VarDecl::setStorageClass(StorageClass SC) { @@ -2097,8 +2096,8 @@ ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg) { - return new (C) ParmVarDecl(ParmVar, DC, StartLoc, IdLoc, Id, T, TInfo, - S, DefArg); + return new (C, DC) ParmVarDecl(ParmVar, DC, StartLoc, IdLoc, Id, T, TInfo, + S, DefArg); } QualType ParmVarDecl::getOriginalType() const { @@ -2110,9 +2109,8 @@ QualType ParmVarDecl::getOriginalType() const { } ParmVarDecl *ParmVarDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ParmVarDecl)); - return new (Mem) ParmVarDecl(ParmVar, 0, SourceLocation(), SourceLocation(), - 0, QualType(), 0, SC_None, 0); + return new (C, ID) ParmVarDecl(ParmVar, 0, SourceLocation(), SourceLocation(), + 0, QualType(), 0, SC_None, 0); } SourceRange ParmVarDecl::getSourceRange() const { @@ -3090,14 +3088,13 @@ FieldDecl *FieldDecl::Create(const ASTContext &C, DeclContext *DC, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle) { - return new (C) FieldDecl(Decl::Field, DC, StartLoc, IdLoc, Id, T, TInfo, - BW, Mutable, InitStyle); + return new (C, DC) FieldDecl(Decl::Field, DC, StartLoc, IdLoc, Id, T, TInfo, + BW, Mutable, InitStyle); } FieldDecl *FieldDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(FieldDecl)); - return new (Mem) FieldDecl(Field, 0, SourceLocation(), SourceLocation(), - 0, QualType(), 0, 0, false, ICIS_NoInit); + return new (C, ID) FieldDecl(Field, 0, SourceLocation(), SourceLocation(), + 0, QualType(), 0, 0, false, ICIS_NoInit); } bool FieldDecl::isAnonymousStructOrUnion() const { @@ -3264,17 +3261,17 @@ EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed) { - EnumDecl *Enum = new (C) EnumDecl(DC, StartLoc, IdLoc, Id, PrevDecl, - IsScoped, IsScopedUsingClassTag, IsFixed); + EnumDecl *Enum = new (C, DC) EnumDecl(DC, StartLoc, IdLoc, Id, PrevDecl, + IsScoped, IsScopedUsingClassTag, + IsFixed); Enum->MayHaveOutOfDateDef = C.getLangOpts().Modules; C.getTypeDeclType(Enum, PrevDecl); return Enum; } EnumDecl *EnumDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(EnumDecl)); - EnumDecl *Enum = new (Mem) EnumDecl(0, SourceLocation(), SourceLocation(), - 0, 0, false, false, false); + EnumDecl *Enum = new (C, ID) EnumDecl(0, SourceLocation(), SourceLocation(), + 0, 0, false, false, false); Enum->MayHaveOutOfDateDef = C.getLangOpts().Modules; return Enum; } @@ -3342,8 +3339,8 @@ RecordDecl::RecordDecl(Kind DK, TagKind TK, DeclContext *DC, RecordDecl *RecordDecl::Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl* PrevDecl) { - RecordDecl* R = new (C) RecordDecl(Record, TK, DC, StartLoc, IdLoc, Id, - PrevDecl); + RecordDecl* R = new (C, DC) RecordDecl(Record, TK, DC, StartLoc, IdLoc, Id, + PrevDecl); R->MayHaveOutOfDateDef = C.getLangOpts().Modules; C.getTypeDeclType(R, PrevDecl); @@ -3351,9 +3348,8 @@ RecordDecl *RecordDecl::Create(const ASTContext &C, TagKind TK, DeclContext *DC, } RecordDecl *RecordDecl::CreateDeserialized(const ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(RecordDecl)); - RecordDecl *R = new (Mem) RecordDecl(Record, TTK_Struct, 0, SourceLocation(), - SourceLocation(), 0, 0); + RecordDecl *R = new (C, ID) RecordDecl(Record, TTK_Struct, 0, SourceLocation(), + SourceLocation(), 0, 0); R->MayHaveOutOfDateDef = C.getLangOpts().Modules; return R; } @@ -3478,26 +3474,25 @@ SourceRange BlockDecl::getSourceRange() const { void TranslationUnitDecl::anchor() { } TranslationUnitDecl *TranslationUnitDecl::Create(ASTContext &C) { - return new (C) TranslationUnitDecl(C); + return new (C, (DeclContext*)0) TranslationUnitDecl(C); } void LabelDecl::anchor() { } LabelDecl *LabelDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II) { - return new (C) LabelDecl(DC, IdentL, II, 0, IdentL); + return new (C, DC) LabelDecl(DC, IdentL, II, 0, IdentL); } LabelDecl *LabelDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II, SourceLocation GnuLabelL) { assert(GnuLabelL != IdentL && "Use this only for GNU local labels"); - return new (C) LabelDecl(DC, IdentL, II, 0, GnuLabelL); + return new (C, DC) LabelDecl(DC, IdentL, II, 0, GnuLabelL); } LabelDecl *LabelDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(LabelDecl)); - return new (Mem) LabelDecl(0, SourceLocation(), 0, 0, SourceLocation()); + return new (C, ID) LabelDecl(0, SourceLocation(), 0, 0, SourceLocation()); } void ValueDecl::anchor() { } @@ -3516,13 +3511,12 @@ ImplicitParamDecl *ImplicitParamDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation IdLoc, IdentifierInfo *Id, QualType Type) { - return new (C) ImplicitParamDecl(DC, IdLoc, Id, Type); + return new (C, DC) ImplicitParamDecl(DC, IdLoc, Id, Type); } -ImplicitParamDecl *ImplicitParamDecl::CreateDeserialized(ASTContext &C, +ImplicitParamDecl *ImplicitParamDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ImplicitParamDecl)); - return new (Mem) ImplicitParamDecl(0, SourceLocation(), 0, QualType()); + return new (C, ID) ImplicitParamDecl(0, SourceLocation(), 0, QualType()); } FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC, @@ -3530,66 +3524,53 @@ FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, - bool isInlineSpecified, + bool isInlineSpecified, bool hasWrittenPrototype, bool isConstexprSpecified) { - FunctionDecl *New = new (C) FunctionDecl(Function, DC, StartLoc, NameInfo, - T, TInfo, SC, - isInlineSpecified, - isConstexprSpecified); + FunctionDecl *New = + new (C, DC) FunctionDecl(Function, DC, StartLoc, NameInfo, T, TInfo, SC, + isInlineSpecified, isConstexprSpecified); New->HasWrittenPrototype = hasWrittenPrototype; return New; } FunctionDecl *FunctionDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(FunctionDecl)); - return new (Mem) FunctionDecl(Function, 0, SourceLocation(), - DeclarationNameInfo(), QualType(), 0, - SC_None, false, false); + return new (C, ID) FunctionDecl(Function, 0, SourceLocation(), + DeclarationNameInfo(), QualType(), 0, + SC_None, false, false); } BlockDecl *BlockDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) { - return new (C) BlockDecl(DC, L); + return new (C, DC) BlockDecl(DC, L); } BlockDecl *BlockDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(BlockDecl)); - return new (Mem) BlockDecl(0, SourceLocation()); -} - -MSPropertyDecl *MSPropertyDecl::CreateDeserialized(ASTContext &C, - unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(MSPropertyDecl)); - return new (Mem) MSPropertyDecl(0, SourceLocation(), DeclarationName(), - QualType(), 0, SourceLocation(), - 0, 0); + return new (C, ID) BlockDecl(0, SourceLocation()); } CapturedDecl *CapturedDecl::Create(ASTContext &C, DeclContext *DC, unsigned NumParams) { - unsigned Size = sizeof(CapturedDecl) + NumParams * sizeof(ImplicitParamDecl*); - return new (C.Allocate(Size)) CapturedDecl(DC, NumParams); + return new (C, DC, NumParams * sizeof(ImplicitParamDecl *)) + CapturedDecl(DC, NumParams); } CapturedDecl *CapturedDecl::CreateDeserialized(ASTContext &C, unsigned ID, - unsigned NumParams) { - unsigned Size = sizeof(CapturedDecl) + NumParams * sizeof(ImplicitParamDecl*); - void *Mem = AllocateDeserializedDecl(C, ID, Size); - return new (Mem) CapturedDecl(0, NumParams); + unsigned NumParams) { + return new (C, ID, NumParams * sizeof(ImplicitParamDecl *)) + CapturedDecl(0, NumParams); } EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, EnumDecl *CD, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V) { - return new (C) EnumConstantDecl(CD, L, Id, T, E, V); + return new (C, CD) EnumConstantDecl(CD, L, Id, T, E, V); } EnumConstantDecl * EnumConstantDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(EnumConstantDecl)); - return new (Mem) EnumConstantDecl(0, SourceLocation(), 0, QualType(), 0, - llvm::APSInt()); + return new (C, ID) EnumConstantDecl(0, SourceLocation(), 0, QualType(), 0, + llvm::APSInt()); } void IndirectFieldDecl::anchor() { } @@ -3598,14 +3579,13 @@ IndirectFieldDecl * IndirectFieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, NamedDecl **CH, unsigned CHS) { - return new (C) IndirectFieldDecl(DC, L, Id, T, CH, CHS); + return new (C, DC) IndirectFieldDecl(DC, L, Id, T, CH, CHS); } IndirectFieldDecl *IndirectFieldDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(IndirectFieldDecl)); - return new (Mem) IndirectFieldDecl(0, SourceLocation(), DeclarationName(), - QualType(), 0, 0); + return new (C, ID) IndirectFieldDecl(0, SourceLocation(), DeclarationName(), + QualType(), 0, 0); } SourceRange EnumConstantDecl::getSourceRange() const { @@ -3620,26 +3600,24 @@ void TypeDecl::anchor() { } TypedefDecl *TypedefDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo) { - return new (C) TypedefDecl(DC, StartLoc, IdLoc, Id, TInfo); + return new (C, DC) TypedefDecl(DC, StartLoc, IdLoc, Id, TInfo); } void TypedefNameDecl::anchor() { } TypedefDecl *TypedefDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(TypedefDecl)); - return new (Mem) TypedefDecl(0, SourceLocation(), SourceLocation(), 0, 0); + return new (C, ID) TypedefDecl(0, SourceLocation(), SourceLocation(), 0, 0); } TypeAliasDecl *TypeAliasDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo) { - return new (C) TypeAliasDecl(DC, StartLoc, IdLoc, Id, TInfo); + return new (C, DC) TypeAliasDecl(DC, StartLoc, IdLoc, Id, TInfo); } TypeAliasDecl *TypeAliasDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(TypeAliasDecl)); - return new (Mem) TypeAliasDecl(0, SourceLocation(), SourceLocation(), 0, 0); + return new (C, ID) TypeAliasDecl(0, SourceLocation(), SourceLocation(), 0, 0); } SourceRange TypedefDecl::getSourceRange() const { @@ -3664,24 +3642,22 @@ FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C, DeclContext *DC, StringLiteral *Str, SourceLocation AsmLoc, SourceLocation RParenLoc) { - return new (C) FileScopeAsmDecl(DC, Str, AsmLoc, RParenLoc); + return new (C, DC) FileScopeAsmDecl(DC, Str, AsmLoc, RParenLoc); } -FileScopeAsmDecl *FileScopeAsmDecl::CreateDeserialized(ASTContext &C, +FileScopeAsmDecl *FileScopeAsmDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(FileScopeAsmDecl)); - return new (Mem) FileScopeAsmDecl(0, 0, SourceLocation(), SourceLocation()); + return new (C, ID) FileScopeAsmDecl(0, 0, SourceLocation(), SourceLocation()); } void EmptyDecl::anchor() {} EmptyDecl *EmptyDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L) { - return new (C) EmptyDecl(DC, L); + return new (C, DC) EmptyDecl(DC, L); } EmptyDecl *EmptyDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(EmptyDecl)); - return new (Mem) EmptyDecl(0, SourceLocation()); + return new (C, ID) EmptyDecl(0, SourceLocation()); } //===----------------------------------------------------------------------===// @@ -3719,30 +3695,28 @@ ImportDecl::ImportDecl(DeclContext *DC, SourceLocation StartLoc, *reinterpret_cast<SourceLocation *>(this + 1) = EndLoc; } -ImportDecl *ImportDecl::Create(ASTContext &C, DeclContext *DC, +ImportDecl *ImportDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, ArrayRef<SourceLocation> IdentifierLocs) { - void *Mem = C.Allocate(sizeof(ImportDecl) + - IdentifierLocs.size() * sizeof(SourceLocation)); - return new (Mem) ImportDecl(DC, StartLoc, Imported, IdentifierLocs); + return new (C, DC, IdentifierLocs.size() * sizeof(SourceLocation)) + ImportDecl(DC, StartLoc, Imported, IdentifierLocs); } -ImportDecl *ImportDecl::CreateImplicit(ASTContext &C, DeclContext *DC, +ImportDecl *ImportDecl::CreateImplicit(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, - Module *Imported, + Module *Imported, SourceLocation EndLoc) { - void *Mem = C.Allocate(sizeof(ImportDecl) + sizeof(SourceLocation)); - ImportDecl *Import = new (Mem) ImportDecl(DC, StartLoc, Imported, EndLoc); + ImportDecl *Import = + new (C, DC, sizeof(SourceLocation)) ImportDecl(DC, StartLoc, + Imported, EndLoc); Import->setImplicit(); return Import; } ImportDecl *ImportDecl::CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumLocations) { - void *Mem = AllocateDeserializedDecl(C, ID, - (sizeof(ImportDecl) + - NumLocations * sizeof(SourceLocation))); - return new (Mem) ImportDecl(EmptyShell()); + return new (C, ID, NumLocations * sizeof(SourceLocation)) + ImportDecl(EmptyShell()); } ArrayRef<SourceLocation> ImportDecl::getIdentifierLocs() const { diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 121c5a671a2..7dc4493943a 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -45,25 +45,30 @@ void Decl::updateOutOfDate(IdentifierInfo &II) const { getASTContext().getExternalSource()->updateOutOfDateIdentifier(II); } -void *Decl::AllocateDeserializedDecl(const ASTContext &Context, - unsigned ID, - unsigned Size) { +void *Decl::operator new(std::size_t Size, const ASTContext &Context, + unsigned ID, std::size_t Extra) { // Allocate an extra 8 bytes worth of storage, which ensures that the // resulting pointer will still be 8-byte aligned. - void *Start = Context.Allocate(Size + 8); + void *Start = Context.Allocate(Size + Extra + 8); void *Result = (char*)Start + 8; - + unsigned *PrefixPtr = (unsigned *)Result - 2; - + // Zero out the first 4 bytes; this is used to store the owning module ID. PrefixPtr[0] = 0; - + // Store the global declaration ID in the second 4 bytes. PrefixPtr[1] = ID; - + return Result; } +void *Decl::operator new(std::size_t Size, const ASTContext &Ctx, + DeclContext *Parent, std::size_t Extra) { + assert(!Parent || &Parent->getParentASTContext() == &Ctx); + return ::operator new(Size + Extra, Ctx); +} + Module *Decl::getOwningModuleSlow() const { assert(isFromASTFile() && "Not from AST file?"); return getASTContext().getExternalSource()->getModule(getOwningModuleID()); diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index b7f0fab3976..c880e2812c3 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -31,8 +31,7 @@ using namespace clang; void AccessSpecDecl::anchor() { } AccessSpecDecl *AccessSpecDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(AccessSpecDecl)); - return new (Mem) AccessSpecDecl(EmptyShell()); + return new (C, ID) AccessSpecDecl(EmptyShell()); } void LazyASTUnresolvedSet::getFromExternalSource(ASTContext &C) const { @@ -95,8 +94,8 @@ CXXRecordDecl *CXXRecordDecl::Create(const ASTContext &C, TagKind TK, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl* PrevDecl, bool DelayTypeCreation) { - CXXRecordDecl* R = new (C) CXXRecordDecl(CXXRecord, TK, DC, StartLoc, IdLoc, - Id, PrevDecl); + CXXRecordDecl *R = new (C, DC) CXXRecordDecl(CXXRecord, TK, DC, StartLoc, + IdLoc, Id, PrevDecl); R->MayHaveOutOfDateDef = C.getLangOpts().Modules; // FIXME: DelayTypeCreation seems like such a hack @@ -109,8 +108,8 @@ CXXRecordDecl *CXXRecordDecl::CreateLambda(const ASTContext &C, DeclContext *DC, TypeSourceInfo *Info, SourceLocation Loc, bool Dependent, bool IsGeneric, LambdaCaptureDefault CaptureDefault) { - CXXRecordDecl* R = new (C) CXXRecordDecl(CXXRecord, TTK_Class, DC, Loc, Loc, - 0, 0); + CXXRecordDecl *R = + new (C, DC) CXXRecordDecl(CXXRecord, TTK_Class, DC, Loc, Loc, 0, 0); R->IsBeingDefined = true; R->DefinitionData = new (C) struct LambdaDefinitionData(R, Info, Dependent, @@ -124,10 +123,8 @@ CXXRecordDecl *CXXRecordDecl::CreateLambda(const ASTContext &C, DeclContext *DC, CXXRecordDecl * CXXRecordDecl::CreateDeserialized(const ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(CXXRecordDecl)); - CXXRecordDecl *R = new (Mem) CXXRecordDecl(CXXRecord, TTK_Struct, 0, - SourceLocation(), SourceLocation(), - 0, 0); + CXXRecordDecl *R = new (C, ID) CXXRecordDecl( + CXXRecord, TTK_Struct, 0, SourceLocation(), SourceLocation(), 0, 0); R->MayHaveOutOfDateDef = false; return R; } @@ -1397,17 +1394,14 @@ CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, bool isConstexpr, SourceLocation EndLocation) { - return new (C) CXXMethodDecl(CXXMethod, RD, StartLoc, NameInfo, T, TInfo, - SC, isInline, isConstexpr, - EndLocation); + return new (C, RD) CXXMethodDecl(CXXMethod, RD, StartLoc, NameInfo, T, TInfo, + SC, isInline, isConstexpr, EndLocation); } CXXMethodDecl *CXXMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(CXXMethodDecl)); - return new (Mem) CXXMethodDecl(CXXMethod, 0, SourceLocation(), - DeclarationNameInfo(), QualType(), - 0, SC_None, false, false, - SourceLocation()); + return new (C, ID) CXXMethodDecl(CXXMethod, 0, SourceLocation(), + DeclarationNameInfo(), QualType(), 0, + SC_None, false, false, SourceLocation()); } bool CXXMethodDecl::isUsualDeallocationFunction() const { @@ -1670,9 +1664,9 @@ void CXXConstructorDecl::anchor() { } CXXConstructorDecl * CXXConstructorDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(CXXConstructorDecl)); - return new (Mem) CXXConstructorDecl(0, SourceLocation(),DeclarationNameInfo(), - QualType(), 0, false, false, false,false); + return new (C, ID) CXXConstructorDecl(0, SourceLocation(), + DeclarationNameInfo(), QualType(), + 0, false, false, false, false); } CXXConstructorDecl * @@ -1685,9 +1679,9 @@ CXXConstructorDecl::Create(ASTContext &C, CXXRecordDecl *RD, assert(NameInfo.getName().getNameKind() == DeclarationName::CXXConstructorName && "Name must refer to a constructor"); - return new (C) CXXConstructorDecl(RD, StartLoc, NameInfo, T, TInfo, - isExplicit, isInline, isImplicitlyDeclared, - isConstexpr); + return new (C, RD) CXXConstructorDecl(RD, StartLoc, NameInfo, T, TInfo, + isExplicit, isInline, + isImplicitlyDeclared, isConstexpr); } CXXConstructorDecl *CXXConstructorDecl::getTargetConstructor() const { @@ -1820,9 +1814,8 @@ void CXXDestructorDecl::anchor() { } CXXDestructorDecl * CXXDestructorDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(CXXDestructorDecl)); - return new (Mem) CXXDestructorDecl(0, SourceLocation(), DeclarationNameInfo(), - QualType(), 0, false, false); + return new (C, ID) CXXDestructorDecl( + 0, SourceLocation(), DeclarationNameInfo(), QualType(), 0, false, false); } CXXDestructorDecl * @@ -1834,18 +1827,18 @@ CXXDestructorDecl::Create(ASTContext &C, CXXRecordDecl *RD, assert(NameInfo.getName().getNameKind() == DeclarationName::CXXDestructorName && "Name must refer to a destructor"); - return new (C) CXXDestructorDecl(RD, StartLoc, NameInfo, T, TInfo, isInline, - isImplicitlyDeclared); + return new (C, RD) CXXDestructorDecl(RD, StartLoc, NameInfo, T, TInfo, + isInline, isImplicitlyDeclared); } void CXXConversionDecl::anchor() { } CXXConversionDecl * CXXConversionDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(CXXConversionDecl)); - return new (Mem) CXXConversionDecl(0, SourceLocation(), DeclarationNameInfo(), - QualType(), 0, false, false, false, - SourceLocation()); + return new (C, ID) CXXConversionDecl(0, SourceLocation(), + DeclarationNameInfo(), QualType(), + 0, false, false, false, + SourceLocation()); } CXXConversionDecl * @@ -1858,9 +1851,9 @@ CXXConversionDecl::Create(ASTContext &C, CXXRecordDecl *RD, assert(NameInfo.getName().getNameKind() == DeclarationName::CXXConversionFunctionName && "Name must refer to a conversion function"); - return new (C) CXXConversionDecl(RD, StartLoc, NameInfo, T, TInfo, - isInline, isExplicit, isConstexpr, - EndLocation); + return new (C, RD) CXXConversionDecl(RD, StartLoc, NameInfo, T, TInfo, + isInline, isExplicit, isConstexpr, + EndLocation); } bool CXXConversionDecl::isLambdaToBlockPointerConversion() const { @@ -1876,13 +1869,13 @@ LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces) { - return new (C) LinkageSpecDecl(DC, ExternLoc, LangLoc, Lang, HasBraces); + return new (C, DC) LinkageSpecDecl(DC, ExternLoc, LangLoc, Lang, HasBraces); } -LinkageSpecDecl *LinkageSpecDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(LinkageSpecDecl)); - return new (Mem) LinkageSpecDecl(0, SourceLocation(), SourceLocation(), - lang_c, false); +LinkageSpecDecl *LinkageSpecDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + return new (C, ID) LinkageSpecDecl(0, SourceLocation(), SourceLocation(), + lang_c, false); } void UsingDirectiveDecl::anchor() { } @@ -1896,16 +1889,15 @@ UsingDirectiveDecl *UsingDirectiveDecl::Create(ASTContext &C, DeclContext *DC, DeclContext *CommonAncestor) { if (NamespaceDecl *NS = dyn_cast_or_null<NamespaceDecl>(Used)) Used = NS->getOriginalNamespace(); - return new (C) UsingDirectiveDecl(DC, L, NamespaceLoc, QualifierLoc, - IdentLoc, Used, CommonAncestor); + return new (C, DC) UsingDirectiveDecl(DC, L, NamespaceLoc, QualifierLoc, + IdentLoc, Used, CommonAncestor); } -UsingDirectiveDecl * -UsingDirectiveDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(UsingDirectiveDecl)); - return new (Mem) UsingDirectiveDecl(0, SourceLocation(), SourceLocation(), - NestedNameSpecifierLoc(), - SourceLocation(), 0, 0); +UsingDirectiveDecl *UsingDirectiveDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + return new (C, ID) UsingDirectiveDecl(0, SourceLocation(), SourceLocation(), + NestedNameSpecifierLoc(), + SourceLocation(), 0, 0); } NamespaceDecl *UsingDirectiveDecl::getNominatedNamespace() { @@ -1934,13 +1926,12 @@ NamespaceDecl *NamespaceDecl::Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl) { - return new (C) NamespaceDecl(DC, Inline, StartLoc, IdLoc, Id, PrevDecl); + return new (C, DC) NamespaceDecl(DC, Inline, StartLoc, IdLoc, Id, PrevDecl); } NamespaceDecl *NamespaceDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(NamespaceDecl)); - return new (Mem) NamespaceDecl(0, false, SourceLocation(), SourceLocation(), - 0, 0); + return new (C, ID) NamespaceDecl(0, false, SourceLocation(), SourceLocation(), + 0, 0); } void NamespaceAliasDecl::anchor() { } @@ -1954,24 +1945,22 @@ NamespaceAliasDecl *NamespaceAliasDecl::Create(ASTContext &C, DeclContext *DC, NamedDecl *Namespace) { if (NamespaceDecl *NS = dyn_cast_or_null<NamespaceDecl>(Namespace)) Namespace = NS->getOriginalNamespace(); - return new (C) NamespaceAliasDecl(DC, UsingLoc, AliasLoc, Alias, - QualifierLoc, IdentLoc, Namespace); + return new (C, DC) NamespaceAliasDecl(DC, UsingLoc, AliasLoc, Alias, + QualifierLoc, IdentLoc, Namespace); } NamespaceAliasDecl * NamespaceAliasDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(NamespaceAliasDecl)); - return new (Mem) NamespaceAliasDecl(0, SourceLocation(), SourceLocation(), 0, - NestedNameSpecifierLoc(), - SourceLocation(), 0); + return new (C, ID) NamespaceAliasDecl(0, SourceLocation(), SourceLocation(), + 0, NestedNameSpecifierLoc(), + SourceLocation(), 0); } void UsingShadowDecl::anchor() { } UsingShadowDecl * UsingShadowDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(UsingShadowDecl)); - return new (Mem) UsingShadowDecl(0, SourceLocation(), 0, 0); + return new (C, ID) UsingShadowDecl(0, SourceLocation(), 0, 0); } UsingDecl *UsingShadowDecl::getUsingDecl() const { @@ -2019,13 +2008,12 @@ UsingDecl *UsingDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation UL, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool HasTypename) { - return new (C) UsingDecl(DC, UL, QualifierLoc, NameInfo, HasTypename); + return new (C, DC) UsingDecl(DC, UL, QualifierLoc, NameInfo, HasTypename); } UsingDecl *UsingDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(UsingDecl)); - return new (Mem) UsingDecl(0, SourceLocation(), NestedNameSpecifierLoc(), - DeclarationNameInfo(), false); + return new (C, ID) UsingDecl(0, SourceLocation(), NestedNameSpecifierLoc(), + DeclarationNameInfo(), false); } SourceRange UsingDecl::getSourceRange() const { @@ -2041,15 +2029,14 @@ UnresolvedUsingValueDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo) { - return new (C) UnresolvedUsingValueDecl(DC, C.DependentTy, UsingLoc, - QualifierLoc, NameInfo); + return new (C, DC) UnresolvedUsingValueDecl(DC, C.DependentTy, UsingLoc, + QualifierLoc, NameInfo); } UnresolvedUsingValueDecl * UnresolvedUsingValueDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(UnresolvedUsingValueDecl)); - return new (Mem) UnresolvedUsingValueDecl(0, QualType(), SourceLocation(), - NestedNameSpecifierLoc(), + return new (C, ID) UnresolvedUsingValueDecl(0, QualType(), SourceLocation(), + NestedNameSpecifierLoc(), DeclarationNameInfo()); } @@ -2068,20 +2055,16 @@ UnresolvedUsingTypenameDecl::Create(ASTContext &C, DeclContext *DC, NestedNameSpecifierLoc QualifierLoc, SourceLocation TargetNameLoc, DeclarationName TargetName) { - return new (C) UnresolvedUsingTypenameDecl(DC, UsingLoc, TypenameLoc, - QualifierLoc, TargetNameLoc, - TargetName.getAsIdentifierInfo()); + return new (C, DC) UnresolvedUsingTypenameDecl( + DC, UsingLoc, TypenameLoc, QualifierLoc, TargetNameLoc, + TargetName.getAsIdentifierInfo()); } UnresolvedUsingTypenameDecl * UnresolvedUsingTypenameDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, - sizeof(UnresolvedUsingTypenameDecl)); - return new (Mem) UnresolvedUsingTypenameDecl(0, SourceLocation(), - SourceLocation(), - NestedNameSpecifierLoc(), - SourceLocation(), - 0); + return new (C, ID) UnresolvedUsingTypenameDecl( + 0, SourceLocation(), SourceLocation(), NestedNameSpecifierLoc(), + SourceLocation(), 0); } void StaticAssertDecl::anchor() { } @@ -2092,15 +2075,29 @@ StaticAssertDecl *StaticAssertDecl::Create(ASTContext &C, DeclContext *DC, StringLiteral *Message, SourceLocation RParenLoc, bool Failed) { - return new (C) StaticAssertDecl(DC, StaticAssertLoc, AssertExpr, Message, - RParenLoc, Failed); + return new (C, DC) StaticAssertDecl(DC, StaticAssertLoc, AssertExpr, Message, + RParenLoc, Failed); } -StaticAssertDecl *StaticAssertDecl::CreateDeserialized(ASTContext &C, +StaticAssertDecl *StaticAssertDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(StaticAssertDecl)); - return new (Mem) StaticAssertDecl(0, SourceLocation(), 0, 0, - SourceLocation(), false); + return new (C, ID) StaticAssertDecl(0, SourceLocation(), 0, 0, + SourceLocation(), false); +} + +MSPropertyDecl *MSPropertyDecl::Create(ASTContext &C, DeclContext *DC, + SourceLocation L, DeclarationName N, + QualType T, TypeSourceInfo *TInfo, + SourceLocation StartL, + IdentifierInfo *Getter, + IdentifierInfo *Setter) { + return new (C, DC) MSPropertyDecl(DC, L, N, T, TInfo, StartL, Getter, Setter); +} + +MSPropertyDecl *MSPropertyDecl::CreateDeserialized(ASTContext &C, + unsigned ID) { + return new (C, ID) MSPropertyDecl(0, SourceLocation(), DeclarationName(), + QualType(), 0, SourceLocation(), 0, 0); } static const char *getAccessName(AccessSpecifier AS) { diff --git a/clang/lib/AST/DeclFriend.cpp b/clang/lib/AST/DeclFriend.cpp index 1c639d676dc..02374c78b8a 100644 --- a/clang/lib/AST/DeclFriend.cpp +++ b/clang/lib/AST/DeclFriend.cpp @@ -46,21 +46,17 @@ FriendDecl *FriendDecl::Create(ASTContext &C, DeclContext *DC, } #endif - std::size_t Size = sizeof(FriendDecl) - + FriendTypeTPLists.size() * sizeof(TemplateParameterList*); - void *Mem = C.Allocate(Size); - FriendDecl *FD = new (Mem) FriendDecl(DC, L, Friend, FriendL, - FriendTypeTPLists); + std::size_t Extra = FriendTypeTPLists.size() * sizeof(TemplateParameterList*); + FriendDecl *FD = new (C, DC, Extra) FriendDecl(DC, L, Friend, FriendL, + FriendTypeTPLists); cast<CXXRecordDecl>(DC)->pushFriendDecl(FD); return FD; } FriendDecl *FriendDecl::CreateDeserialized(ASTContext &C, unsigned ID, unsigned FriendTypeNumTPLists) { - std::size_t Size = sizeof(FriendDecl) - + FriendTypeNumTPLists * sizeof(TemplateParameterList*); - void *Mem = AllocateDeserializedDecl(C, ID, Size); - return new (Mem) FriendDecl(EmptyShell(), FriendTypeNumTPLists); + std::size_t Extra = FriendTypeNumTPLists * sizeof(TemplateParameterList*); + return new (C, ID, Extra) FriendDecl(EmptyShell(), FriendTypeNumTPLists); } FriendDecl *CXXRecordDecl::getFirstFriend() const { diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index b2b5b70197b..28a651429c9 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -563,18 +563,15 @@ ObjCMethodDecl *ObjCMethodDecl::Create(ASTContext &C, bool isDefined, ImplementationControl impControl, bool HasRelatedResultType) { - return new (C) ObjCMethodDecl(beginLoc, endLoc, - SelInfo, T, ResultTInfo, contextDecl, - isInstance, isVariadic, isPropertyAccessor, - isImplicitlyDeclared, isDefined, - impControl, - HasRelatedResultType); + return new (C, contextDecl) ObjCMethodDecl( + beginLoc, endLoc, SelInfo, T, ResultTInfo, contextDecl, isInstance, + isVariadic, isPropertyAccessor, isImplicitlyDeclared, isDefined, + impControl, HasRelatedResultType); } ObjCMethodDecl *ObjCMethodDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCMethodDecl)); - return new (Mem) ObjCMethodDecl(SourceLocation(), SourceLocation(), - Selector(), QualType(), 0, 0); + return new (C, ID) ObjCMethodDecl(SourceLocation(), SourceLocation(), + Selector(), QualType(), 0, 0); } Stmt *ObjCMethodDecl::getBody() const { @@ -1055,19 +1052,18 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::Create(const ASTContext &C, ObjCInterfaceDecl *PrevDecl, SourceLocation ClassLoc, bool isInternal){ - ObjCInterfaceDecl *Result = new (C) ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, - PrevDecl, isInternal); + ObjCInterfaceDecl *Result = new (C, DC) + ObjCInterfaceDecl(DC, atLoc, Id, ClassLoc, PrevDecl, isInternal); Result->Data.setInt(!C.getLangOpts().Modules); C.getObjCInterfaceType(Result, PrevDecl); return Result; } -ObjCInterfaceDecl *ObjCInterfaceDecl::CreateDeserialized(ASTContext &C, +ObjCInterfaceDecl *ObjCInterfaceDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCInterfaceDecl)); - ObjCInterfaceDecl *Result = new (Mem) ObjCInterfaceDecl(0, SourceLocation(), - 0, SourceLocation(), - 0, false); + ObjCInterfaceDecl *Result = new (C, ID) ObjCInterfaceDecl(0, SourceLocation(), + 0, SourceLocation(), + 0, false); Result->Data.setInt(!C.getLangOpts().Modules); return Result; } @@ -1353,14 +1349,14 @@ ObjCIvarDecl *ObjCIvarDecl::Create(ASTContext &C, ObjCContainerDecl *DC, ID->setIvarList(0); } - return new (C) ObjCIvarDecl(DC, StartLoc, IdLoc, Id, T, TInfo, - ac, BW, synthesized, backingIvarReferencedInAccessor); + return new (C, DC) ObjCIvarDecl(DC, StartLoc, IdLoc, Id, T, TInfo, ac, BW, + synthesized, backingIvarReferencedInAccessor); } ObjCIvarDecl *ObjCIvarDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCIvarDecl)); - return new (Mem) ObjCIvarDecl(0, SourceLocation(), SourceLocation(), 0, - QualType(), 0, ObjCIvarDecl::None, 0, false, false); + return new (C, ID) ObjCIvarDecl(0, SourceLocation(), SourceLocation(), 0, + QualType(), 0, ObjCIvarDecl::None, 0, false, + false); } const ObjCInterfaceDecl *ObjCIvarDecl::getContainingInterface() const { @@ -1397,14 +1393,13 @@ ObjCAtDefsFieldDecl *ObjCAtDefsFieldDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, Expr *BW) { - return new (C) ObjCAtDefsFieldDecl(DC, StartLoc, IdLoc, Id, T, BW); + return new (C, DC) ObjCAtDefsFieldDecl(DC, StartLoc, IdLoc, Id, T, BW); } -ObjCAtDefsFieldDecl *ObjCAtDefsFieldDecl::CreateDeserialized(ASTContext &C, +ObjCAtDefsFieldDecl *ObjCAtDefsFieldDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCAtDefsFieldDecl)); - return new (Mem) ObjCAtDefsFieldDecl(0, SourceLocation(), SourceLocation(), - 0, QualType(), 0); + return new (C, ID) ObjCAtDefsFieldDecl(0, SourceLocation(), SourceLocation(), + 0, QualType(), 0); } //===----------------------------------------------------------------------===// @@ -1429,17 +1424,16 @@ ObjCProtocolDecl *ObjCProtocolDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation nameLoc, SourceLocation atStartLoc, ObjCProtocolDecl *PrevDecl) { - ObjCProtocolDecl *Result - = new (C) ObjCProtocolDecl(DC, Id, nameLoc, atStartLoc, PrevDecl); + ObjCProtocolDecl *Result = + new (C, DC) ObjCProtocolDecl(DC, Id, nameLoc, atStartLoc, PrevDecl); Result->Data.setInt(!C.getLangOpts().Modules); return Result; } -ObjCProtocolDecl *ObjCProtocolDecl::CreateDeserialized(ASTContext &C, +ObjCProtocolDecl *ObjCProtocolDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCProtocolDecl)); - ObjCProtocolDecl *Result = new (Mem) ObjCProtocolDecl(0, 0, SourceLocation(), - SourceLocation(), 0); + ObjCProtocolDecl *Result = + new (C, ID) ObjCProtocolDecl(0, 0, SourceLocation(), SourceLocation(), 0); Result->Data.setInt(!C.getLangOpts().Modules); return Result; } @@ -1543,17 +1537,16 @@ void ObjCProtocolDecl::collectInheritedProtocolProperties( void ObjCCategoryDecl::anchor() { } ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, DeclContext *DC, - SourceLocation AtLoc, + SourceLocation AtLoc, SourceLocation ClassNameLoc, SourceLocation CategoryNameLoc, IdentifierInfo *Id, ObjCInterfaceDecl *IDecl, SourceLocation IvarLBraceLoc, SourceLocation IvarRBraceLoc) { - ObjCCategoryDecl *CatDecl = new (C) ObjCCategoryDecl(DC, AtLoc, ClassNameLoc, - CategoryNameLoc, Id, - IDecl, - IvarLBraceLoc, IvarRBraceLoc); + ObjCCategoryDecl *CatDecl = + new (C, DC) ObjCCategoryDecl(DC, AtLoc, ClassNameLoc, CategoryNameLoc, Id, + IDecl, IvarLBraceLoc, IvarRBraceLoc); if (IDecl) { // Link this category into its class's category list. CatDecl->NextClassCategory = IDecl->getCategoryListRaw(); @@ -1567,11 +1560,10 @@ ObjCCategoryDecl *ObjCCategoryDecl::Create(ASTContext &C, DeclContext *DC, return CatDecl; } -ObjCCategoryDecl *ObjCCategoryDecl::CreateDeserialized(ASTContext &C, +ObjCCategoryDecl *ObjCCategoryDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCCategoryDecl)); - return new (Mem) ObjCCategoryDecl(0, SourceLocation(), SourceLocation(), - SourceLocation(), 0, 0); + return new (C, ID) ObjCCategoryDecl(0, SourceLocation(), SourceLocation(), + SourceLocation(), 0, 0); } ObjCCategoryImplDecl *ObjCCategoryDecl::getImplementation() const { @@ -1599,15 +1591,14 @@ ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation CategoryNameLoc) { if (ClassInterface && ClassInterface->hasDefinition()) ClassInterface = ClassInterface->getDefinition(); - return new (C) ObjCCategoryImplDecl(DC, Id, ClassInterface, - nameLoc, atStartLoc, CategoryNameLoc); + return new (C, DC) ObjCCategoryImplDecl(DC, Id, ClassInterface, nameLoc, + atStartLoc, CategoryNameLoc); } ObjCCategoryImplDecl *ObjCCategoryImplDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCCategoryImplDecl)); - return new (Mem) ObjCCategoryImplDecl(0, 0, 0, SourceLocation(), - SourceLocation(), SourceLocation()); + return new (C, ID) ObjCCategoryImplDecl(0, 0, 0, SourceLocation(), + SourceLocation(), SourceLocation()); } ObjCCategoryDecl *ObjCCategoryImplDecl::getCategoryDecl() const { @@ -1695,16 +1686,15 @@ ObjCImplementationDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation IvarRBraceLoc) { if (ClassInterface && ClassInterface->hasDefinition()) ClassInterface = ClassInterface->getDefinition(); - return new (C) ObjCImplementationDecl(DC, ClassInterface, SuperDecl, - nameLoc, atStartLoc, superLoc, - IvarLBraceLoc, IvarRBraceLoc); + return new (C, DC) ObjCImplementationDecl(DC, ClassInterface, SuperDecl, + nameLoc, atStartLoc, superLoc, + IvarLBraceLoc, IvarRBraceLoc); } ObjCImplementationDecl * ObjCImplementationDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCImplementationDecl)); - return new (Mem) ObjCImplementationDecl(0, 0, 0, SourceLocation(), - SourceLocation()); + return new (C, ID) ObjCImplementationDecl(0, 0, 0, SourceLocation(), + SourceLocation()); } void ObjCImplementationDecl::setIvarInitializers(ASTContext &C, @@ -1737,13 +1727,12 @@ ObjCCompatibleAliasDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, ObjCInterfaceDecl* AliasedClass) { - return new (C) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass); + return new (C, DC) ObjCCompatibleAliasDecl(DC, L, Id, AliasedClass); } ObjCCompatibleAliasDecl * ObjCCompatibleAliasDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCCompatibleAliasDecl)); - return new (Mem) ObjCCompatibleAliasDecl(0, SourceLocation(), 0, 0); + return new (C, ID) ObjCCompatibleAliasDecl(0, SourceLocation(), 0, 0); } //===----------------------------------------------------------------------===// @@ -1759,15 +1748,13 @@ ObjCPropertyDecl *ObjCPropertyDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation LParenLoc, TypeSourceInfo *T, PropertyControl propControl) { - return new (C) ObjCPropertyDecl(DC, L, Id, AtLoc, LParenLoc, T); + return new (C, DC) ObjCPropertyDecl(DC, L, Id, AtLoc, LParenLoc, T); } -ObjCPropertyDecl *ObjCPropertyDecl::CreateDeserialized(ASTContext &C, +ObjCPropertyDecl *ObjCPropertyDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void * Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCPropertyDecl)); - return new (Mem) ObjCPropertyDecl(0, SourceLocation(), 0, SourceLocation(), - SourceLocation(), - 0); + return new (C, ID) ObjCPropertyDecl(0, SourceLocation(), 0, SourceLocation(), + SourceLocation(), 0); } //===----------------------------------------------------------------------===// @@ -1782,15 +1769,14 @@ ObjCPropertyImplDecl *ObjCPropertyImplDecl::Create(ASTContext &C, Kind PK, ObjCIvarDecl *ivar, SourceLocation ivarLoc) { - return new (C) ObjCPropertyImplDecl(DC, atLoc, L, property, PK, ivar, - ivarLoc); + return new (C, DC) ObjCPropertyImplDecl(DC, atLoc, L, property, PK, ivar, + ivarLoc); } -ObjCPropertyImplDecl *ObjCPropertyImplDecl::CreateDeserialized(ASTContext &C, +ObjCPropertyImplDecl *ObjCPropertyImplDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ObjCPropertyImplDecl)); - return new (Mem) ObjCPropertyImplDecl(0, SourceLocation(), SourceLocation(), - 0, Dynamic, 0, SourceLocation()); + return new (C, ID) ObjCPropertyImplDecl(0, SourceLocation(), SourceLocation(), + 0, Dynamic, 0, SourceLocation()); } SourceRange ObjCPropertyImplDecl::getSourceRange() const { diff --git a/clang/lib/AST/DeclOpenMP.cpp b/clang/lib/AST/DeclOpenMP.cpp index 0d195f74623..8f454715d77 100644 --- a/clang/lib/AST/DeclOpenMP.cpp +++ b/clang/lib/AST/DeclOpenMP.cpp @@ -29,12 +29,8 @@ OMPThreadPrivateDecl *OMPThreadPrivateDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L, ArrayRef<Expr *> VL) { - unsigned Size = sizeof(OMPThreadPrivateDecl) + - (VL.size() * sizeof(Expr *)); - - void *Mem = C.Allocate(Size, llvm::alignOf<OMPThreadPrivateDecl>()); - OMPThreadPrivateDecl *D = new (Mem) OMPThreadPrivateDecl(OMPThreadPrivate, - DC, L); + OMPThreadPrivateDecl *D = new (C, DC, VL.size() * sizeof(Expr *)) + OMPThreadPrivateDecl(OMPThreadPrivate, DC, L); D->NumVars = VL.size(); D->setVars(VL); return D; @@ -43,11 +39,8 @@ OMPThreadPrivateDecl *OMPThreadPrivateDecl::Create(ASTContext &C, OMPThreadPrivateDecl *OMPThreadPrivateDecl::CreateDeserialized(ASTContext &C, unsigned ID, unsigned N) { - unsigned Size = sizeof(OMPThreadPrivateDecl) + (N * sizeof(Expr *)); - - void *Mem = AllocateDeserializedDecl(C, ID, Size); - OMPThreadPrivateDecl *D = new (Mem) OMPThreadPrivateDecl(OMPThreadPrivate, - 0, SourceLocation()); + OMPThreadPrivateDecl *D = new (C, ID, N * sizeof(Expr *)) + OMPThreadPrivateDecl(OMPThreadPrivate, 0, SourceLocation()); D->NumVars = N; return D; } diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp index 7172fb7b487..df4a888d9d0 100644 --- a/clang/lib/AST/DeclTemplate.cpp +++ b/clang/lib/AST/DeclTemplate.cpp @@ -229,14 +229,13 @@ FunctionTemplateDecl *FunctionTemplateDecl::Create(ASTContext &C, TemplateParameterList *Params, NamedDecl *Decl) { AdoptTemplateParameterList(Params, cast<DeclContext>(Decl)); - return new (C) FunctionTemplateDecl(DC, L, Name, Params, Decl); + return new (C, DC) FunctionTemplateDecl(DC, L, Name, Params, Decl); } FunctionTemplateDecl *FunctionTemplateDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(FunctionTemplateDecl)); - return new (Mem) FunctionTemplateDecl(0, SourceLocation(), DeclarationName(), - 0, 0); + return new (C, ID) FunctionTemplateDecl(0, SourceLocation(), DeclarationName(), + 0, 0); } RedeclarableTemplateDecl::CommonBase * @@ -308,15 +307,15 @@ ClassTemplateDecl *ClassTemplateDecl::Create(ASTContext &C, NamedDecl *Decl, ClassTemplateDecl *PrevDecl) { AdoptTemplateParameterList(Params, cast<DeclContext>(Decl)); - ClassTemplateDecl *New = new (C) ClassTemplateDecl(DC, L, Name, Params, Decl); + ClassTemplateDecl *New = + new (C, DC) ClassTemplateDecl(DC, L, Name, Params, Decl); New->setPreviousDecl(PrevDecl); return New; } ClassTemplateDecl *ClassTemplateDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(ClassTemplateDecl)); - return new (Mem) ClassTemplateDecl(EmptyShell()); + return new (C, ID) ClassTemplateDecl(EmptyShell()); } void ClassTemplateDecl::LoadLazySpecializations() const { @@ -471,7 +470,7 @@ TemplateTypeParmDecl::Create(const ASTContext &C, DeclContext *DC, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack) { TemplateTypeParmDecl *TTPDecl = - new (C) TemplateTypeParmDecl(DC, KeyLoc, NameLoc, Id, Typename); + new (C, DC) TemplateTypeParmDecl(DC, KeyLoc, NameLoc, Id, Typename); QualType TTPType = C.getTemplateTypeParmType(D, P, ParameterPack, TTPDecl); TTPDecl->TypeForDecl = TTPType.getTypePtr(); return TTPDecl; @@ -479,9 +478,8 @@ TemplateTypeParmDecl::Create(const ASTContext &C, DeclContext *DC, TemplateTypeParmDecl * TemplateTypeParmDecl::CreateDeserialized(const ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(TemplateTypeParmDecl)); - return new (Mem) TemplateTypeParmDecl(0, SourceLocation(), SourceLocation(), - 0, false); + return new (C, ID) TemplateTypeParmDecl(0, SourceLocation(), SourceLocation(), + 0, false); } SourceLocation TemplateTypeParmDecl::getDefaultArgumentLoc() const { @@ -544,8 +542,8 @@ NonTypeTemplateParmDecl::Create(const ASTContext &C, DeclContext *DC, unsigned D, unsigned P, IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo) { - return new (C) NonTypeTemplateParmDecl(DC, StartLoc, IdLoc, D, P, Id, - T, ParameterPack, TInfo); + return new (C, DC) NonTypeTemplateParmDecl(DC, StartLoc, IdLoc, D, P, Id, + T, ParameterPack, TInfo); } NonTypeTemplateParmDecl * @@ -557,34 +555,26 @@ NonTypeTemplateParmDecl::Create(const ASTContext &C, DeclContext *DC, const QualType *ExpandedTypes, unsigned NumExpandedTypes, TypeSourceInfo **ExpandedTInfos) { - unsigned Size = sizeof(NonTypeTemplateParmDecl) - + NumExpandedTypes * 2 * sizeof(void*); - void *Mem = C.Allocate(Size); - return new (Mem) NonTypeTemplateParmDecl(DC, StartLoc, IdLoc, - D, P, Id, T, TInfo, - ExpandedTypes, NumExpandedTypes, - ExpandedTInfos); + unsigned Extra = NumExpandedTypes * 2 * sizeof(void*); + return new (C, DC, Extra) NonTypeTemplateParmDecl( + DC, StartLoc, IdLoc, D, P, Id, T, TInfo, + ExpandedTypes, NumExpandedTypes, ExpandedTInfos); } NonTypeTemplateParmDecl * NonTypeTemplateParmDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(NonTypeTemplateParmDecl)); - return new (Mem) NonTypeTemplateParmDecl(0, SourceLocation(), - SourceLocation(), 0, 0, 0, - QualType(), false, 0); + return new (C, ID) NonTypeTemplateParmDecl(0, SourceLocation(), + SourceLocation(), 0, 0, 0, + QualType(), false, 0); } NonTypeTemplateParmDecl * NonTypeTemplateParmDecl::CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpandedTypes) { - unsigned Size = sizeof(NonTypeTemplateParmDecl) - + NumExpandedTypes * 2 * sizeof(void*); - - void *Mem = AllocateDeserializedDecl(C, ID, Size); - return new (Mem) NonTypeTemplateParmDecl(0, SourceLocation(), - SourceLocation(), 0, 0, 0, - QualType(), 0, 0, NumExpandedTypes, - 0); + unsigned Extra = NumExpandedTypes * 2 * sizeof(void*); + return new (C, ID, Extra) NonTypeTemplateParmDecl( + 0, SourceLocation(), SourceLocation(), 0, 0, 0, QualType(), 0, + 0, NumExpandedTypes, 0); } SourceRange NonTypeTemplateParmDecl::getSourceRange() const { @@ -624,8 +614,8 @@ TemplateTemplateParmDecl::Create(const ASTContext &C, DeclContext *DC, SourceLocation L, unsigned D, unsigned P, bool ParameterPack, IdentifierInfo *Id, TemplateParameterList *Params) { - return new (C) TemplateTemplateParmDecl(DC, L, D, P, ParameterPack, Id, - Params); + return new (C, DC) TemplateTemplateParmDecl(DC, L, D, P, ParameterPack, Id, + Params); } TemplateTemplateParmDecl * @@ -634,28 +624,23 @@ TemplateTemplateParmDecl::Create(const ASTContext &C, DeclContext *DC, IdentifierInfo *Id, TemplateParameterList *Params, ArrayRef<TemplateParameterList *> Expansions) { - void *Mem = C.Allocate(sizeof(TemplateTemplateParmDecl) + - sizeof(TemplateParameterList*) * Expansions.size()); - return new (Mem) TemplateTemplateParmDecl(DC, L, D, P, Id, Params, - Expansions.size(), - Expansions.data()); + return new (C, DC, sizeof(TemplateParameterList*) * Expansions.size()) + TemplateTemplateParmDecl(DC, L, D, P, Id, Params, + Expansions.size(), Expansions.data()); } TemplateTemplateParmDecl * TemplateTemplateParmDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(TemplateTemplateParmDecl)); - return new (Mem) TemplateTemplateParmDecl(0, SourceLocation(), 0, 0, false, - 0, 0); + return new (C, ID) TemplateTemplateParmDecl(0, SourceLocation(), 0, 0, false, + 0, 0); } TemplateTemplateParmDecl * TemplateTemplateParmDecl::CreateDeserialized(ASTContext &C, unsigned ID, unsigned NumExpansions) { - unsigned Size = sizeof(TemplateTemplateParmDecl) + - sizeof(TemplateParameterList*) * NumExpansions; - void *Mem = AllocateDeserializedDecl(C, ID, Size); - return new (Mem) TemplateTemplateParmDecl(0, SourceLocation(), 0, 0, 0, 0, - NumExpansions, 0); + return new (C, ID, sizeof(TemplateParameterList*) * NumExpansions) + TemplateTemplateParmDecl(0, SourceLocation(), 0, 0, 0, 0, + NumExpansions, 0); } //===----------------------------------------------------------------------===// @@ -734,13 +719,10 @@ ClassTemplateSpecializationDecl::Create(ASTContext &Context, TagKind TK, const TemplateArgument *Args, unsigned NumArgs, ClassTemplateSpecializationDecl *PrevDecl) { - ClassTemplateSpecializationDecl *Result - = new (Context)ClassTemplateSpecializationDecl(Context, - ClassTemplateSpecialization, - TK, DC, StartLoc, IdLoc, - SpecializedTemplate, - Args, NumArgs, - PrevDecl); + ClassTemplateSpecializationDecl *Result = + new (Context, DC) ClassTemplateSpecializationDecl( + Context, ClassTemplateSpecialization, TK, DC, StartLoc, IdLoc, + SpecializedTemplate, Args, NumArgs, PrevDecl); Result->MayHaveOutOfDateDef = false; Context.getTypeDeclType(Result, PrevDecl); @@ -748,12 +730,10 @@ ClassTemplateSpecializationDecl::Create(ASTContext &Context, TagKind TK, } ClassTemplateSpecializationDecl * -ClassTemplateSpecializationDecl::CreateDeserialized(ASTContext &C, +ClassTemplateSpecializationDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, - sizeof(ClassTemplateSpecializationDecl)); ClassTemplateSpecializationDecl *Result = - new (Mem) ClassTemplateSpecializationDecl(ClassTemplateSpecialization); + new (C, ID) ClassTemplateSpecializationDecl(ClassTemplateSpecialization); Result->MayHaveOutOfDateDef = false; return Result; } @@ -855,14 +835,10 @@ Create(ASTContext &Context, TagKind TK,DeclContext *DC, const ASTTemplateArgumentListInfo *ASTArgInfos = ASTTemplateArgumentListInfo::Create(Context, ArgInfos); - ClassTemplatePartialSpecializationDecl *Result - = new (Context)ClassTemplatePartialSpecializationDecl(Context, TK, DC, - StartLoc, IdLoc, - Params, - SpecializedTemplate, - Args, NumArgs, - ASTArgInfos, - PrevDecl); + ClassTemplatePartialSpecializationDecl *Result = new (Context, DC) + ClassTemplatePartialSpecializationDecl(Context, TK, DC, StartLoc, IdLoc, + Params, SpecializedTemplate, Args, + NumArgs, ASTArgInfos, PrevDecl); Result->setSpecializationKind(TSK_ExplicitSpecialization); Result->MayHaveOutOfDateDef = false; @@ -873,10 +849,8 @@ Create(ASTContext &Context, TagKind TK,DeclContext *DC, ClassTemplatePartialSpecializationDecl * ClassTemplatePartialSpecializationDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, - sizeof(ClassTemplatePartialSpecializationDecl)); - ClassTemplatePartialSpecializationDecl *Result - = new (Mem) ClassTemplatePartialSpecializationDecl(); + ClassTemplatePartialSpecializationDecl *Result = + new (C, ID) ClassTemplatePartialSpecializationDecl(); Result->MayHaveOutOfDateDef = false; return Result; } @@ -894,15 +868,13 @@ FriendTemplateDecl *FriendTemplateDecl::Create(ASTContext &Context, TemplateParameterList **Params, FriendUnion Friend, SourceLocation FLoc) { - FriendTemplateDecl *Result - = new (Context) FriendTemplateDecl(DC, L, NParams, Params, Friend, FLoc); - return Result; + return new (Context, DC) FriendTemplateDecl(DC, L, NParams, Params, + Friend, FLoc); } FriendTemplateDecl *FriendTemplateDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(FriendTemplateDecl)); - return new (Mem) FriendTemplateDecl(EmptyShell()); + return new (C, ID) FriendTemplateDecl(EmptyShell()); } //===----------------------------------------------------------------------===// @@ -916,14 +888,13 @@ TypeAliasTemplateDecl *TypeAliasTemplateDecl::Create(ASTContext &C, TemplateParameterList *Params, NamedDecl *Decl) { AdoptTemplateParameterList(Params, DC); - return new (C) TypeAliasTemplateDecl(DC, L, Name, Params, Decl); + return new (C, DC) TypeAliasTemplateDecl(DC, L, Name, Params, Decl); } TypeAliasTemplateDecl *TypeAliasTemplateDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(TypeAliasTemplateDecl)); - return new (Mem) TypeAliasTemplateDecl(0, SourceLocation(), DeclarationName(), - 0, 0); + return new (C, ID) TypeAliasTemplateDecl(0, SourceLocation(), DeclarationName(), + 0, 0); } void TypeAliasTemplateDecl::DeallocateCommon(void *Ptr) { @@ -945,10 +916,8 @@ void ClassScopeFunctionSpecializationDecl::anchor() { } ClassScopeFunctionSpecializationDecl * ClassScopeFunctionSpecializationDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, - sizeof(ClassScopeFunctionSpecializationDecl)); - return new (Mem) ClassScopeFunctionSpecializationDecl(0, SourceLocation(), 0, - false, TemplateArgumentListInfo()); + return new (C, ID) ClassScopeFunctionSpecializationDecl( + 0, SourceLocation(), 0, false, TemplateArgumentListInfo()); } //===----------------------------------------------------------------------===// @@ -974,15 +943,14 @@ VarTemplateDecl *VarTemplateDecl::Create(ASTContext &C, DeclContext *DC, TemplateParameterList *Params, NamedDecl *Decl, VarTemplateDecl *PrevDecl) { - VarTemplateDecl *New = new (C) VarTemplateDecl(DC, L, Name, Params, Decl); + VarTemplateDecl *New = new (C, DC) VarTemplateDecl(DC, L, Name, Params, Decl); New->setPreviousDecl(PrevDecl); return New; } VarTemplateDecl *VarTemplateDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl(C, ID, sizeof(VarTemplateDecl)); - return new (Mem) VarTemplateDecl(EmptyShell()); + return new (C, ID) VarTemplateDecl(EmptyShell()); } // TODO: Unify accross class, function and variable templates? @@ -1111,20 +1079,14 @@ VarTemplateSpecializationDecl *VarTemplateSpecializationDecl::Create( SourceLocation IdLoc, VarTemplateDecl *SpecializedTemplate, QualType T, TypeSourceInfo *TInfo, StorageClass S, const TemplateArgument *Args, unsigned NumArgs) { - VarTemplateSpecializationDecl *Result = new (Context) - VarTemplateSpecializationDecl(Context, VarTemplateSpecialization, DC, - StartLoc, IdLoc, SpecializedTemplate, T, - TInfo, S, Args, NumArgs); - return Result; + return new (Context, DC) VarTemplateSpecializationDecl( + Context, VarTemplateSpecialization, DC, StartLoc, IdLoc, + SpecializedTemplate, T, TInfo, S, Args, NumArgs); } VarTemplateSpecializationDecl * VarTemplateSpecializationDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = - AllocateDeserializedDecl(C, ID, sizeof(VarTemplateSpecializationDecl)); - VarTemplateSpecializationDecl *Result = - new (Mem) VarTemplateSpecializationDecl(VarTemplateSpecialization); - return Result; + return new (C, ID) VarTemplateSpecializationDecl(VarTemplateSpecialization); } void VarTemplateSpecializationDecl::getNameForDiagnostic( @@ -1183,7 +1145,7 @@ VarTemplatePartialSpecializationDecl::Create( = ASTTemplateArgumentListInfo::Create(Context, ArgInfos); VarTemplatePartialSpecializationDecl *Result = - new (Context) VarTemplatePartialSpecializationDecl( + new (Context, DC) VarTemplatePartialSpecializationDecl( Context, DC, StartLoc, IdLoc, Params, SpecializedTemplate, T, TInfo, S, Args, NumArgs, ASTArgInfos); Result->setSpecializationKind(TSK_ExplicitSpecialization); @@ -1193,9 +1155,5 @@ VarTemplatePartialSpecializationDecl::Create( VarTemplatePartialSpecializationDecl * VarTemplatePartialSpecializationDecl::CreateDeserialized(ASTContext &C, unsigned ID) { - void *Mem = AllocateDeserializedDecl( - C, ID, sizeof(VarTemplatePartialSpecializationDecl)); - VarTemplatePartialSpecializationDecl *Result = - new (Mem) VarTemplatePartialSpecializationDecl(); - return Result; + return new (C, ID) VarTemplatePartialSpecializationDecl(); } diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 1eec2318e2b..54eef40043b 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -12793,11 +12793,9 @@ MSPropertyDecl *Sema::HandleMSProperty(Scope *S, RecordDecl *Record, PrevDecl = 0; SourceLocation TSSL = D.getLocStart(); - MSPropertyDecl *NewPD; const AttributeList::PropertyData &Data = MSPropertyAttr->getPropertyData(); - NewPD = new (Context) MSPropertyDecl(Record, Loc, - II, T, TInfo, TSSL, - Data.GetterId, Data.SetterId); + MSPropertyDecl *NewPD = MSPropertyDecl::Create( + Context, Record, Loc, II, T, TInfo, TSSL, Data.GetterId, Data.SetterId); ProcessDeclAttributes(TUScope, NewPD, D); NewPD->setAccess(AS); diff --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp index f5c4c72cb34..a0af0329530 100644 --- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp @@ -488,11 +488,9 @@ Decl *TemplateDeclInstantiator::VisitMSPropertyDecl(MSPropertyDecl *D) { SemaRef.MarkDeclarationsReferencedInType(D->getLocation(), DI->getType()); } - MSPropertyDecl *Property = new (SemaRef.Context) - MSPropertyDecl(Owner, D->getLocation(), - D->getDeclName(), DI->getType(), DI, - D->getLocStart(), - D->getGetterId(), D->getSetterId()); + MSPropertyDecl *Property = MSPropertyDecl::Create( + SemaRef.Context, Owner, D->getLocation(), D->getDeclName(), DI->getType(), + DI, D->getLocStart(), D->getGetterId(), D->getSetterId()); SemaRef.InstantiateAttrs(TemplateArgs, D, Property, LateAttrs, StartingScope); |