diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-04-17 14:40:12 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2008-04-17 14:40:12 +0000 |
commit | ef177820100ab583b08fd3056e2a5a52ee4b1629 (patch) | |
tree | 14282d5187bbc1083390174abf161b6cd5155bd2 /lib/AST/Decl.cpp | |
parent | 5da6b2592fbf69708a7863b41d8bd76440d0f41b (diff) |
Addition of TranslationUnitDecl to the AST:
-Added TranslationUnitDecl class to serve as top declaration context
-ASTContext gets a TUDecl member and a getTranslationUnitDecl() function
-All ScopedDecls get the TUDecl as DeclContext when declared at global scope
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49855 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 900096f1ec..6ebaac569f 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -198,6 +198,7 @@ void Decl::addDeclKind(Kind k) { case ObjCPropertyImpl: nObjCPropertyImplDecl++; break; case LinkageSpec: nLinkageSpecDecl++; break; case FileScopeAsm: nFileScopeAsmDecl++; break; + case TranslationUnit: break; } } @@ -205,6 +206,11 @@ void Decl::addDeclKind(Kind k) { // Decl Allocation/Deallocation Method Implementations //===----------------------------------------------------------------------===// +TranslationUnitDecl *TranslationUnitDecl::Create(ASTContext &C) { + void *Mem = C.getAllocator().Allocate<TranslationUnitDecl>(); + return new (Mem) TranslationUnitDecl(); +} + VarDecl *VarDecl::Create(ASTContext &C, DeclContext *CD, SourceLocation L, IdentifierInfo *Id, QualType T, @@ -213,7 +219,6 @@ VarDecl *VarDecl::Create(ASTContext &C, DeclContext *CD, return new (Mem) VarDecl(Var, CD, L, Id, T, S, PrevDecl); } - ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *CD, SourceLocation L, IdentifierInfo *Id, QualType T, StorageClass S, @@ -329,6 +334,7 @@ const Attr *Decl::getAttrs() const { void Decl::Destroy(ASTContext& C) const { switch (getKind()) { + CASE(TranslationUnit); CASE(Field); CASE(ObjCIvar); CASE(ObjCCategory); |