]> granicus.if.org Git - clang/commitdiff
Move backend output out of destructor.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 11 Nov 2008 06:35:39 +0000 (06:35 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 11 Nov 2008 06:35:39 +0000 (06:35 +0000)
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

Driver/Backend.cpp
Driver/clang.cpp

index dbe46fcf2f1aa1f9bf6717c679b34ba8df57c6a5..f16c0694971478e038cf88817070cf713c37f0ff 100644 (file)
@@ -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) {
index 5fc86a775996134e4eb54c0f2295eb64d7758a6b..4973a42819846b440e6364c009bbe76165f3b03a 100644 (file)
@@ -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,