Created a destructor so that the top-level decls can be deleted.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49142 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/TranslationUnit.h b/include/clang/AST/TranslationUnit.h
index 2839774..0c7d034 100644
--- a/include/clang/AST/TranslationUnit.h
+++ b/include/clang/AST/TranslationUnit.h
@@ -42,6 +42,8 @@
   explicit TranslationUnit(const LangOptions& lopt)
     : LangOpts(lopt), Context(NULL) {}
 
+  ~TranslationUnit();
+
   void setContext(ASTContext* context) { Context = context; }
   ASTContext* getContext() const { return Context; }
   
diff --git a/lib/AST/TranslationUnit.cpp b/lib/AST/TranslationUnit.cpp
index fdc37a8..8211db1 100644
--- a/lib/AST/TranslationUnit.cpp
+++ b/lib/AST/TranslationUnit.cpp
@@ -30,6 +30,11 @@
        ASTContextBlock = 2,
        DeclsBlock = 3 };
 
+TranslationUnit::~TranslationUnit()
+{
+  for (iterator I=begin(), E=end(); I!=E; ++I) 
+    delete *I;
+}
 
 bool clang::EmitASTBitcodeFile(const TranslationUnit& TU, 
                                const llvm::sys::Path& Filename) {