[cfe-commits] r48403 - in /cfe/trunk: Driver/RewriteTest.cpp clang.xcodeproj/project.pbxproj include/clang/AST/Decl.h lib/AST/ASTContext.cpp lib/AST/Decl.cpp lib/AST/DeclSerialization.cpp lib/Sema/Sema.cpp lib/Sema/SemaDecl.cpp
Chris Lattner
sabre at nondot.org
Sat Mar 15 17:16:02 PDT 2008
Author: lattner
Date: Sat Mar 15 19:16:02 2008
New Revision: 48403
URL: http://llvm.org/viewvc/llvm-project?rev=48403&view=rev
Log:
switch the rest of the C decl classes to do their
allocation through ASTContext.
Modified:
cfe/trunk/Driver/RewriteTest.cpp
cfe/trunk/clang.xcodeproj/project.pbxproj
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclSerialization.cpp
cfe/trunk/lib/Sema/Sema.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/Driver/RewriteTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteTest.cpp?rev=48403&r1=48402&r2=48403&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteTest.cpp (original)
+++ cfe/trunk/Driver/RewriteTest.cpp Sat Mar 15 19:16:02 2008
@@ -1805,7 +1805,8 @@
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 @@
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);
}
Modified: cfe/trunk/clang.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/clang.xcodeproj/project.pbxproj?rev=48403&r1=48402&r2=48403&view=diff
==============================================================================
--- cfe/trunk/clang.xcodeproj/project.pbxproj (original)
+++ cfe/trunk/clang.xcodeproj/project.pbxproj Sat Mar 15 19:16:02 2008
@@ -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;
};
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=48403&r1=48402&r2=48403&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sat Mar 15 19:16:02 2008
@@ -434,6 +434,22 @@
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 @@
// 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 @@
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 @@
ElementList = 0;
IntegerType = QualType();
}
- ~EnumDecl() {}
public:
static EnumDecl *Create(ASTContext &C, SourceLocation L, IdentifierInfo *Id,
ScopedDecl *PrevDecl);
@@ -749,8 +748,6 @@
Members = 0;
NumMembers = -1;
}
-
- ~RecordDecl() {}
public:
static RecordDecl *Create(ASTContext &C, Kind DK, SourceLocation L,
@@ -791,9 +788,11 @@
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 @@
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; }
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=48403&r1=48402&r2=48403&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sat Mar 15 19:16:02 2008
@@ -1064,7 +1064,8 @@
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);
}
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=48403&r1=48402&r2=48403&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Sat Mar 15 19:16:02 2008
@@ -235,6 +235,12 @@
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 @@
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
Modified: cfe/trunk/lib/AST/DeclSerialization.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclSerialization.cpp?rev=48403&r1=48402&r2=48403&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclSerialization.cpp (original)
+++ cfe/trunk/lib/AST/DeclSerialization.cpp Sat Mar 15 19:16:02 2008
@@ -302,7 +302,7 @@
}
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>();
Modified: cfe/trunk/lib/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=48403&r1=48402&r2=48403&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.cpp (original)
+++ cfe/trunk/lib/Sema/Sema.cpp Sat Mar 15 19:16:02 2008
@@ -116,8 +116,8 @@
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(),
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=48403&r1=48402&r2=48403&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Mar 15 19:16:02 2008
@@ -1332,7 +1332,7 @@
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 @@
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 @@
}
// 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) {
More information about the cfe-commits
mailing list