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 | c3b69ae815298eeb29d849537ad229ba9bcf0f9c (patch) | |
tree | ea0f0f40e0c9174f8f0ad7d412e758bcab3eb364 /clang/lib/Sema/Sema.cpp | |
parent | 3da1d68662e5f9796de1692ae69d6c5393842cf6 (diff) | |
download | bcm5719-llvm-c3b69ae815298eeb29d849537ad229ba9bcf0f9c.tar.gz bcm5719-llvm-c3b69ae815298eeb29d849537ad229ba9bcf0f9c.zip |
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
llvm-svn: 49855
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
-rw-r--r-- | clang/lib/Sema/Sema.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index c6a862b2b1e..bb5316a126a 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/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); |