aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-04-17 14:40:12 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2008-04-17 14:40:12 +0000
commitef177820100ab583b08fd3056e2a5a52ee4b1629 (patch)
tree14282d5187bbc1083390174abf161b6cd5155bd2 /lib/Sema/Sema.cpp
parent5da6b2592fbf69708a7863b41d8bd76440d0f41b (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/Sema/Sema.cpp')
-rw-r--r--lib/Sema/Sema.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index c6a862b2b1..bb5316a126 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -42,6 +42,7 @@ bool Sema::isObjCObjectPointerType(QualType type) const {
void Sema::ActOnTranslationUnitScope(SourceLocation Loc, Scope *S) {
TUScope = S;
+ CurContext = Context.getTranslationUnitDecl();
if (!PP.getLangOptions().ObjC1) return;
TypedefType *t;
@@ -93,14 +94,16 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer)
// FIXME: Move this initialization up to Sema::ActOnTranslationUnitScope()
// and make sure the decls get inserted into TUScope!
if (PP.getLangOptions().ObjC1) {
+ TranslationUnitDecl *TUDecl = Context.getTranslationUnitDecl();
+
// Synthesize "typedef struct objc_class *Class;"
RecordDecl *ClassTag = RecordDecl::Create(Context, Decl::Struct,
- NULL,
+ TUDecl,
SourceLocation(),
&IT.get("objc_class"), 0);
QualType ClassT = Context.getPointerType(Context.getTagDeclType(ClassTag));
TypedefDecl *ClassTypedef =
- TypedefDecl::Create(Context, NULL, SourceLocation(),
+ TypedefDecl::Create(Context, TUDecl, SourceLocation(),
&Context.Idents.get("Class"), ClassT, 0);
Context.setObjCClassType(ClassTypedef);
@@ -113,14 +116,14 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer)
// Synthesize "typedef struct objc_object { Class isa; } *id;"
RecordDecl *ObjectTag =
- RecordDecl::Create(Context, Decl::Struct, NULL,
+ RecordDecl::Create(Context, Decl::Struct, TUDecl,
SourceLocation(),
&IT.get("objc_object"), 0);
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, NULL,
+ TypedefDecl *IdTypedef = TypedefDecl::Create(Context, TUDecl,
SourceLocation(),
&Context.Idents.get("id"),
ObjT, 0);