forked from OSchip/llvm-project
switch the rest of the C decl classes to do their
allocation through ASTContext. llvm-svn: 48403
This commit is contained in:
parent
7a51313d8a
commit
ee1284a6e2
|
@ -1805,7 +1805,8 @@ QualType RewriteTest::getSuperStructType() {
|
|||
FieldDecl *FieldDecls[2];
|
||||
|
||||
for (unsigned i = 0; i < 2; ++i)
|
||||
FieldDecls[i] = new FieldDecl(SourceLocation(), 0, FieldTypes[i]);
|
||||
FieldDecls[i] = FieldDecl::Create(*Context, SourceLocation(), 0,
|
||||
FieldTypes[i]);
|
||||
|
||||
SuperStructDecl->defineBody(FieldDecls, 4);
|
||||
}
|
||||
|
@ -1831,7 +1832,8 @@ QualType RewriteTest::getConstantStringStructType() {
|
|||
FieldDecl *FieldDecls[2];
|
||||
|
||||
for (unsigned i = 0; i < 4; ++i)
|
||||
FieldDecls[i] = new FieldDecl(SourceLocation(), 0, FieldTypes[i]);
|
||||
FieldDecls[i] = FieldDecl::Create(*Context, SourceLocation(), 0,
|
||||
FieldTypes[i]);
|
||||
|
||||
ConstantStringDecl->defineBody(FieldDecls, 4);
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@
|
|||
DE34621D0AFEB19B00DBC861 /* StmtPrinter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE34621C0AFEB19B00DBC861 /* StmtPrinter.cpp */; };
|
||||
DE3464220B03040900DBC861 /* Type.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE3464210B03040900DBC861 /* Type.h */; };
|
||||
DE38CD500D794D0100A273B6 /* CGObjCGNU.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE38CD4F0D794D0100A273B6 /* CGObjCGNU.cpp */; };
|
||||
DE38CF160D8C9DE000A273B6 /* DiagChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE38CF150D8C9DE000A273B6 /* DiagChecker.cpp */; };
|
||||
DE3985790CB8ADC800223765 /* ASTConsumers.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE3985780CB8ADC800223765 /* ASTConsumers.h */; };
|
||||
DE39857B0CB8ADCB00223765 /* ASTConsumers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DE39857A0CB8ADCB00223765 /* ASTConsumers.cpp */; };
|
||||
DE3986F00CB8D4B300223765 /* IdentifierTable.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DE3986EF0CB8D4B300223765 /* IdentifierTable.h */; };
|
||||
|
@ -119,7 +120,6 @@
|
|||
DEB0AEBB0C2087AB00718A22 /* TextDiagnostics.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEB0AEBA0C2087AB00718A22 /* TextDiagnostics.cpp */; };
|
||||
DEC63B1A0C7B940200DBF169 /* CFG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEC63B190C7B940200DBF169 /* CFG.cpp */; };
|
||||
DEC63B1C0C7B940600DBF169 /* CFG.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEC63B1B0C7B940600DBF169 /* CFG.h */; };
|
||||
DEC82DC40C32D50A00BAC245 /* DiagChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DEC82DC30C32D50A00BAC245 /* DiagChecker.cpp */; };
|
||||
DEC8D9910A9433CD00353FCA /* Decl.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEC8D9900A9433CD00353FCA /* Decl.h */; };
|
||||
DEC8D9A40A94346E00353FCA /* AST.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DEC8D9A30A94346E00353FCA /* AST.h */; };
|
||||
DED626C90AE0C065001E80A4 /* TargetInfo.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DED626C80AE0C065001E80A4 /* TargetInfo.cpp */; };
|
||||
|
@ -312,6 +312,7 @@
|
|||
DE3464210B03040900DBC861 /* Type.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Type.h; path = clang/AST/Type.h; sourceTree = "<group>"; };
|
||||
DE38CD4E0D794CF900A273B6 /* CGObjCRuntime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CGObjCRuntime.h; path = lib/CodeGen/CGObjCRuntime.h; sourceTree = "<group>"; };
|
||||
DE38CD4F0D794D0100A273B6 /* CGObjCGNU.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CGObjCGNU.cpp; path = lib/CodeGen/CGObjCGNU.cpp; sourceTree = "<group>"; };
|
||||
DE38CF150D8C9DE000A273B6 /* DiagChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DiagChecker.cpp; path = Driver/DiagChecker.cpp; sourceTree = "<group>"; };
|
||||
DE3985780CB8ADC800223765 /* ASTConsumers.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ASTConsumers.h; path = Driver/ASTConsumers.h; sourceTree = "<group>"; };
|
||||
DE39857A0CB8ADCB00223765 /* ASTConsumers.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ASTConsumers.cpp; path = Driver/ASTConsumers.cpp; sourceTree = "<group>"; };
|
||||
DE3986EF0CB8D4B300223765 /* IdentifierTable.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IdentifierTable.h; sourceTree = "<group>"; };
|
||||
|
@ -384,7 +385,6 @@
|
|||
DEB0AEBA0C2087AB00718A22 /* TextDiagnostics.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = TextDiagnostics.cpp; path = Driver/TextDiagnostics.cpp; sourceTree = "<group>"; };
|
||||
DEC63B190C7B940200DBF169 /* CFG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = CFG.cpp; path = lib/AST/CFG.cpp; sourceTree = "<group>"; };
|
||||
DEC63B1B0C7B940600DBF169 /* CFG.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = CFG.h; path = clang/AST/CFG.h; sourceTree = "<group>"; };
|
||||
DEC82DC30C32D50A00BAC245 /* DiagChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = DiagChecker.cpp; path = lib/Driver/DiagChecker.cpp; sourceTree = "<group>"; };
|
||||
DEC8D9900A9433CD00353FCA /* Decl.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = Decl.h; path = clang/AST/Decl.h; sourceTree = "<group>"; };
|
||||
DEC8D9A30A94346E00353FCA /* AST.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AST.h; path = clang/AST/AST.h; sourceTree = "<group>"; };
|
||||
DED626C80AE0C065001E80A4 /* TargetInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = TargetInfo.cpp; sourceTree = "<group>"; };
|
||||
|
@ -674,7 +674,7 @@
|
|||
DE5932CE0AD60FF400BC794C /* clang.h */,
|
||||
DE3985780CB8ADC800223765 /* ASTConsumers.h */,
|
||||
DE39857A0CB8ADCB00223765 /* ASTConsumers.cpp */,
|
||||
DEC82DC30C32D50A00BAC245 /* DiagChecker.cpp */,
|
||||
DE38CF150D8C9DE000A273B6 /* DiagChecker.cpp */,
|
||||
DE5932CF0AD60FF400BC794C /* PrintParserCallbacks.cpp */,
|
||||
DE5932D00AD60FF400BC794C /* PrintPreprocessedOutput.cpp */,
|
||||
DEA977890CBE87EB00F872F9 /* RewriteTest.cpp */,
|
||||
|
@ -946,7 +946,6 @@
|
|||
84D9A8880C1A57E100AC7ABC /* AttributeList.cpp in Sources */,
|
||||
DEB0AEBB0C2087AB00718A22 /* TextDiagnostics.cpp in Sources */,
|
||||
DEEBC3BC0C2363BC00A9FE82 /* CodeGenTypes.cpp in Sources */,
|
||||
DEC82DC40C32D50A00BAC245 /* DiagChecker.cpp in Sources */,
|
||||
DEEBCBE50C33703100A9FE82 /* TextDiagnosticBuffer.cpp in Sources */,
|
||||
DEF2EDA70C6A4252000C4259 /* StmtDumper.cpp in Sources */,
|
||||
DEF2EFF30C6CDD74000C4259 /* CGExprAgg.cpp in Sources */,
|
||||
|
@ -997,6 +996,7 @@
|
|||
DE85CDAC0D838C120070E26E /* PPMacroExpansion.cpp in Sources */,
|
||||
DE85CDB00D838C390070E26E /* PPDirectives.cpp in Sources */,
|
||||
DE85CDB60D839BAE0070E26E /* PPLexerChange.cpp in Sources */,
|
||||
DE38CF160D8C9DE000A273B6 /* DiagChecker.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
@ -434,6 +434,22 @@ public:
|
|||
None, Extern, Static, PrivateExtern
|
||||
};
|
||||
private:
|
||||
/// ParamInfo - new[]'d array of pointers to VarDecls for the formal
|
||||
/// parameters of this function. This is null if a prototype or if there are
|
||||
/// no formals. TODO: we could allocate this space immediately after the
|
||||
/// FunctionDecl object to save an allocation like FunctionType does.
|
||||
ParmVarDecl **ParamInfo;
|
||||
|
||||
Stmt *Body; // Null if a prototype.
|
||||
|
||||
/// DeclChain - Linked list of declarations that are defined inside this
|
||||
/// function.
|
||||
ScopedDecl *DeclChain;
|
||||
|
||||
// NOTE: VC++ treats enums as signed, avoid using the StorageClass enum
|
||||
unsigned SClass : 2;
|
||||
bool IsInline : 1;
|
||||
|
||||
FunctionDecl(SourceLocation L, IdentifierInfo *Id, QualType T,
|
||||
StorageClass S, bool isInline, ScopedDecl *PrevDecl)
|
||||
: ValueDecl(Function, L, Id, T, PrevDecl),
|
||||
|
@ -480,23 +496,6 @@ public:
|
|||
// Implement isa/cast/dyncast/etc.
|
||||
static bool classof(const Decl *D) { return D->getKind() == Function; }
|
||||
static bool classof(const FunctionDecl *D) { return true; }
|
||||
|
||||
private:
|
||||
/// ParamInfo - new[]'d array of pointers to VarDecls for the formal
|
||||
/// parameters of this function. This is null if a prototype or if there are
|
||||
/// no formals. TODO: we could allocate this space immediately after the
|
||||
/// FunctionDecl object to save an allocation like FunctionType does.
|
||||
ParmVarDecl **ParamInfo;
|
||||
|
||||
Stmt *Body; // Null if a prototype.
|
||||
|
||||
/// DeclChain - Linked list of declarations that are defined inside this
|
||||
/// function.
|
||||
ScopedDecl *DeclChain;
|
||||
|
||||
// NOTE: VC++ treats enums as signed, avoid using the StorageClass enum
|
||||
unsigned SClass : 2;
|
||||
bool IsInline : 1;
|
||||
|
||||
protected:
|
||||
/// EmitImpl - Serialize this FunctionDecl. Called by Decl::Emit.
|
||||
|
@ -518,10 +517,11 @@ protected:
|
|||
FieldDecl(Kind DK, SourceLocation L, IdentifierInfo *Id, QualType T,
|
||||
Expr *BW = NULL)
|
||||
: NamedDecl(DK, L, Id), DeclType(T), BitWidth(BW) {}
|
||||
public:
|
||||
FieldDecl(SourceLocation L, IdentifierInfo *Id, QualType T,
|
||||
Expr *BW = NULL)
|
||||
FieldDecl(SourceLocation L, IdentifierInfo *Id, QualType T, Expr *BW)
|
||||
: NamedDecl(Field, L, Id), DeclType(T), BitWidth(BW) {}
|
||||
public:
|
||||
static FieldDecl *Create(ASTContext &C, SourceLocation L, IdentifierInfo *Id,
|
||||
QualType T, Expr *BW = NULL);
|
||||
|
||||
QualType getType() const { return DeclType; }
|
||||
QualType getCanonicalType() const { return DeclType.getCanonicalType(); }
|
||||
|
@ -688,7 +688,6 @@ class EnumDecl : public TagDecl {
|
|||
ElementList = 0;
|
||||
IntegerType = QualType();
|
||||
}
|
||||
~EnumDecl() {}
|
||||
public:
|
||||
static EnumDecl *Create(ASTContext &C, SourceLocation L, IdentifierInfo *Id,
|
||||
ScopedDecl *PrevDecl);
|
||||
|
@ -749,8 +748,6 @@ class RecordDecl : public TagDecl {
|
|||
Members = 0;
|
||||
NumMembers = -1;
|
||||
}
|
||||
|
||||
~RecordDecl() {}
|
||||
public:
|
||||
|
||||
static RecordDecl *Create(ASTContext &C, Kind DK, SourceLocation L,
|
||||
|
@ -791,9 +788,11 @@ protected:
|
|||
|
||||
class FileScopeAsmDecl : public Decl {
|
||||
StringLiteral *AsmString;
|
||||
public:
|
||||
FileScopeAsmDecl(SourceLocation L, StringLiteral *asmstring)
|
||||
: Decl(FileScopeAsm, L), AsmString(asmstring) {}
|
||||
public:
|
||||
static FileScopeAsmDecl *Create(ASTContext &C, SourceLocation L,
|
||||
StringLiteral *Str);
|
||||
|
||||
const StringLiteral *getAsmString() const { return AsmString; }
|
||||
StringLiteral *getAsmString() { return AsmString; }
|
||||
|
@ -828,10 +827,13 @@ private:
|
|||
LanguageIDs Language;
|
||||
/// D - This is the Decl of the linkage specification.
|
||||
Decl *D;
|
||||
public:
|
||||
|
||||
LinkageSpecDecl(SourceLocation L, LanguageIDs lang, Decl *d)
|
||||
: Decl(LinkageSpec, L), Language(lang), D(d) {}
|
||||
|
||||
public:
|
||||
static LinkageSpecDecl *Create(ASTContext &C, SourceLocation L,
|
||||
LanguageIDs Lang, Decl *D);
|
||||
|
||||
LanguageIDs getLanguage() const { return Language; }
|
||||
const Decl *getDecl() const { return D; }
|
||||
Decl *getDecl() { return D; }
|
||||
|
|
|
@ -1064,7 +1064,8 @@ QualType ASTContext::getCFConstantStringType() {
|
|||
FieldDecl *FieldDecls[4];
|
||||
|
||||
for (unsigned i = 0; i < 4; ++i)
|
||||
FieldDecls[i] = new FieldDecl(SourceLocation(), 0, FieldTypes[i]);
|
||||
FieldDecls[i] = FieldDecl::Create(*this, SourceLocation(), 0,
|
||||
FieldTypes[i]);
|
||||
|
||||
CFConstantStringTypeDecl->defineBody(FieldDecls, 4);
|
||||
}
|
||||
|
|
|
@ -235,6 +235,12 @@ FunctionDecl *FunctionDecl::Create(ASTContext &C, SourceLocation L,
|
|||
return new (Mem) FunctionDecl(L, Id, T, S, isInline, PrevDecl);
|
||||
}
|
||||
|
||||
FieldDecl *FieldDecl::Create(ASTContext &C, SourceLocation L,
|
||||
IdentifierInfo *Id, QualType T, Expr *BW) {
|
||||
void *Mem = C.getAllocator().Allocate<FieldDecl>();
|
||||
return new (Mem) FieldDecl(L, Id, T, BW);
|
||||
}
|
||||
|
||||
|
||||
EnumConstantDecl *EnumConstantDecl::Create(ASTContext &C, SourceLocation L,
|
||||
IdentifierInfo *Id, QualType T,
|
||||
|
@ -263,6 +269,17 @@ RecordDecl *RecordDecl::Create(ASTContext &C, Kind DK, SourceLocation L,
|
|||
return new (Mem) RecordDecl(DK, L, Id, PrevDecl);
|
||||
}
|
||||
|
||||
FileScopeAsmDecl *FileScopeAsmDecl::Create(ASTContext &C, SourceLocation L,
|
||||
StringLiteral *Str) {
|
||||
void *Mem = C.getAllocator().Allocate<FileScopeAsmDecl>();
|
||||
return new (Mem) FileScopeAsmDecl(L, Str);
|
||||
}
|
||||
|
||||
LinkageSpecDecl *LinkageSpecDecl::Create(ASTContext &C, SourceLocation L,
|
||||
LanguageIDs Lang, Decl *D) {
|
||||
void *Mem = C.getAllocator().Allocate<LinkageSpecDecl>();
|
||||
return new (Mem) LinkageSpecDecl(L, Lang, D);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Decl Implementation
|
||||
|
|
|
@ -302,7 +302,7 @@ void FieldDecl::EmitImpl(Serializer& S) const {
|
|||
}
|
||||
|
||||
FieldDecl* FieldDecl::CreateImpl(Deserializer& D) {
|
||||
FieldDecl* decl = new FieldDecl(SourceLocation(),NULL,QualType());
|
||||
FieldDecl* decl = new FieldDecl(SourceLocation(), NULL, QualType(), 0);
|
||||
decl->DeclType.ReadBackpatch(D);
|
||||
decl->ReadInRec(D);
|
||||
decl->BitWidth = D.ReadOwnedPtr<Expr>();
|
||||
|
|
|
@ -116,8 +116,8 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer)
|
|||
RecordDecl *ObjectTag =
|
||||
RecordDecl::Create(Context, Decl::Struct, SourceLocation(),
|
||||
&IT.get("objc_object"), 0);
|
||||
FieldDecl *IsaDecl = new FieldDecl(SourceLocation(), 0,
|
||||
Context.getObjCClassType());
|
||||
FieldDecl *IsaDecl = FieldDecl::Create(Context, SourceLocation(), 0,
|
||||
Context.getObjCClassType());
|
||||
ObjectTag->defineBody(&IsaDecl, 1);
|
||||
QualType ObjT = Context.getPointerType(Context.getTagDeclType(ObjectTag));
|
||||
TypedefDecl *IdTypedef = TypedefDecl::Create(Context, SourceLocation(),
|
||||
|
|
|
@ -1332,7 +1332,7 @@ Sema::DeclTy *Sema::ActOnField(Scope *S, DeclTy *TagDecl,
|
|||
FieldDecl *NewFD;
|
||||
|
||||
if (isa<RecordDecl>(static_cast<Decl *>(TagDecl)))
|
||||
NewFD = new FieldDecl(Loc, II, T, BitWidth);
|
||||
NewFD = FieldDecl::Create(Context, Loc, II, T, BitWidth);
|
||||
else if (isa<ObjCInterfaceDecl>(static_cast<Decl *>(TagDecl)) ||
|
||||
isa<ObjCImplementationDecl>(static_cast<Decl *>(TagDecl)) ||
|
||||
isa<ObjCCategoryDecl>(static_cast<Decl *>(TagDecl)) ||
|
||||
|
@ -1750,7 +1750,7 @@ Sema::DeclTy *Sema::ActOnFileScopeAsmDecl(SourceLocation Loc,
|
|||
ExprTy *expr) {
|
||||
StringLiteral *AsmString = cast<StringLiteral>((Expr*)expr);
|
||||
|
||||
return new FileScopeAsmDecl(Loc, AsmString);
|
||||
return FileScopeAsmDecl::Create(Context, Loc, AsmString);
|
||||
}
|
||||
|
||||
Sema::DeclTy* Sema::ActOnLinkageSpec(SourceLocation Loc,
|
||||
|
@ -1771,7 +1771,7 @@ Sema::DeclTy* Sema::ActOnLinkageSpec(SourceLocation Loc,
|
|||
}
|
||||
|
||||
// FIXME: Add all the various semantics of linkage specifications
|
||||
return new LinkageSpecDecl(Loc, Language, dcl);
|
||||
return LinkageSpecDecl::Create(Context, Loc, Language, dcl);
|
||||
}
|
||||
|
||||
void Sema::HandleDeclAttribute(Decl *New, AttributeList *Attr) {
|
||||
|
|
Loading…
Reference in New Issue