]> granicus.if.org Git - clang/commitdiff
Fix leak from r210059
authorAlp Toker <alp@nuanti.com>
Tue, 3 Jun 2014 17:23:34 +0000 (17:23 +0000)
committerAlp Toker <alp@nuanti.com>
Tue, 3 Jun 2014 17:23:34 +0000 (17:23 +0000)
Also revert r210096 which temporarily disabled the test while this was being
investigated.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210115 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/CompilerInstance.h
lib/CodeGen/CodeGenAction.cpp
lib/Frontend/CompilerInstance.cpp
test/Frontend/disable-output.c

index 97c140ecbdac77c773e78371d9460da15b09c522..b144069b975b8b1c38d183404ef37f50400a276b 100644 (file)
@@ -663,6 +663,8 @@ public:
                    std::string *ResultPathName,
                    std::string *TempPathName);
 
+  llvm::raw_null_ostream *createNullOutputFile();
+
   /// }
   /// @name Initialization Utility Methods
   /// {
index 88f02b4e6a0c21833366ac9ee451badae322774d..a197faece1f543eae8aa2614e59fb2c1e65d639d 100644 (file)
@@ -568,7 +568,7 @@ static raw_ostream *GetOutputStream(CompilerInstance &CI,
   case Backend_EmitNothing:
     return nullptr;
   case Backend_EmitMCNull:
-    return new raw_null_ostream();
+    return CI.createNullOutputFile();
   case Backend_EmitObj:
     return CI.createDefaultOutputFile(true, InFile, "o");
   }
index c65d34bd2a960fda7cae597618d52b39500be5e2..ac20d7a28e5832a750182849a226cd6bcbda6029 100644 (file)
@@ -478,6 +478,12 @@ CompilerInstance::createDefaultOutputFile(bool Binary,
                           /*UseTemporary=*/true);
 }
 
+llvm::raw_null_ostream *CompilerInstance::createNullOutputFile() {
+  llvm::raw_null_ostream *OS = new llvm::raw_null_ostream();
+  addOutputFile(OutputFile("", "", OS));
+  return OS;
+}
+
 llvm::raw_fd_ostream *
 CompilerInstance::createOutputFile(StringRef OutputPath,
                                    bool Binary, bool RemoveFileOnSignal,
index 46dae32fc51b2be153f09d5fe7e4b49d56727d01..786ac77ef18e1c5abb4b6a66ac74e0ffcf7fda26 100644 (file)
@@ -1,8 +1,7 @@
-// FIXME: this test produces a leak report in clang.
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 %s -emit-llvm-only -triple=i386-apple-darwin -o %t
 // RUN: not rm %t
-// FIXME: %clang_cc1 %s -emit-codegen-only -triple=i386-apple-darwin -o %t
-// FIXME: not rm %t
+// RUN: %clang_cc1 %s -emit-codegen-only -triple=i386-apple-darwin -o %t
+// RUN: not rm %t
 
 // Test that output is not generated when emission is disabled.