From: Sam Bishop Date: Thu, 3 Apr 2008 05:35:20 +0000 (+0000) Subject: Created a destructor so that the top-level decls can be deleted. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=71de20ef8bf50e83f60d4b191cc6797cf27853d3;p=clang 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 2839774eae..0c7d0348da 100644 --- a/include/clang/AST/TranslationUnit.h +++ b/include/clang/AST/TranslationUnit.h @@ -42,6 +42,8 @@ public: 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 fdc37a8443..8211db1b74 100644 --- a/lib/AST/TranslationUnit.cpp +++ b/lib/AST/TranslationUnit.cpp @@ -30,6 +30,11 @@ enum { BasicMetadataBlock = 1, 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) {