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/Decl.cpp b/lib/AST/Decl.cpp
index 900096f..6ebaac5 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -198,6 +198,7 @@
   case ObjCPropertyImpl:    nObjCPropertyImplDecl++; break;
   case LinkageSpec:         nLinkageSpecDecl++; break;
   case FileScopeAsm:        nFileScopeAsmDecl++; break;
+  case TranslationUnit:     break;
   }
 }
 
@@ -205,6 +206,11 @@
 // 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 @@
   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 @@
 
 void Decl::Destroy(ASTContext& C) const {
   switch (getKind()) {
+  CASE(TranslationUnit);
   CASE(Field);
   CASE(ObjCIvar);
   CASE(ObjCCategory);