From: Daniel Dunbar Date: Tue, 11 Nov 2008 06:35:39 +0000 (+0000) Subject: Move backend output out of destructor. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d68ba0ee188d08e7a10b5f295675e0782ef4f990;p=clang Move backend output out of destructor. Don't free AST consumer when --disable-free is set. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59030 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/Driver/Backend.cpp b/Driver/Backend.cpp index dbe46fcf2f..f16c069497 100644 --- a/Driver/Backend.cpp +++ b/Driver/Backend.cpp @@ -89,9 +89,6 @@ namespace { CodeGenPasses(0), PerModulePasses(0), PerFunctionPasses(0) {} ~BackendConsumer() { - // FIXME: Move out of destructor. - EmitAssembly(); - delete AsmOutStream; delete TheTargetData; delete ModuleProvider; @@ -115,6 +112,11 @@ namespace { virtual void HandleTranslationUnit(TranslationUnit& TU) { Gen->HandleTranslationUnit(TU); + + EmitAssembly(); + // Force a flush here in case we never get released. + if (AsmOutStream) + AsmOutStream->flush(); } virtual void HandleTagDeclDefinition(TagDecl *D) { diff --git a/Driver/clang.cpp b/Driver/clang.cpp index 5fc86a7759..4973a42819 100644 --- a/Driver/clang.cpp +++ b/Driver/clang.cpp @@ -1363,6 +1363,9 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF, // files. if (ClearSourceMgr) PP.getSourceManager().clearIDTables(); + + if (DisableFree) + Consumer.take(); } static void ProcessSerializedFile(const std::string& InFile, Diagnostic& Diag,