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
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index e4b48e2..7220ce4 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1175,7 +1175,7 @@
QualType ASTContext::getCFConstantStringType() {
if (!CFConstantStringTypeDecl) {
CFConstantStringTypeDecl =
- RecordDecl::Create(*this, Decl::Struct, NULL, SourceLocation(),
+ RecordDecl::Create(*this, Decl::Struct, TUDecl, SourceLocation(),
&Idents.get("NSConstantString"), 0);
QualType FieldTypes[4];
@@ -1727,6 +1727,8 @@
I!=E;++I)
(*I)->Emit(S);
+ S.EmitOwnedPtr(TUDecl);
+
// FIXME: S.EmitOwnedPtr(CFConstantStringTypeDecl);
}
@@ -1743,6 +1745,8 @@
for (unsigned i = 0; i < size_reserve; ++i)
Type::Create(*A,i,D);
+ A->TUDecl = cast<TranslationUnitDecl>(D.ReadOwnedPtr<Decl>(*A));
+
// FIXME: A->CFConstantStringTypeDecl = D.ReadOwnedPtr<RecordDecl>();
return A;