diff options
Diffstat (limited to 'clang/lib/AST/DeclCXX.cpp')
-rw-r--r-- | clang/lib/AST/DeclCXX.cpp | 169 |
1 files changed, 83 insertions, 86 deletions
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) { |