From a94d873b4bf9316a3d306a2f1f605101b1015289 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 11 Nov 2008 06:35:39 +0000 Subject: [PATCH] Move backend output out of destructor. Don't free AST consumer when --disable-free is set. llvm-svn: 59030 --- clang/Driver/Backend.cpp | 8 +++++--- clang/Driver/clang.cpp | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/clang/Driver/Backend.cpp b/clang/Driver/Backend.cpp index dbe46fcf2f1a..f16c06949714 100644 --- a/clang/Driver/Backend.cpp +++ b/clang/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/clang/Driver/clang.cpp b/clang/Driver/clang.cpp index 5fc86a775996..4973a4281984 100644 --- a/clang/Driver/clang.cpp +++ b/clang/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,