summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-06-03 17:23:34 +0000
committerAlp Toker <alp@nuanti.com>2014-06-03 17:23:34 +0000
commitb830eaf3e0eb5fb7a548dc78fff33b2e3659704a (patch)
treea9eefeab4297f498d311184e959b74e2eca7ccd0
parent0a775494ece0c48015b3c249227a2379e079a0b1 (diff)
downloadclang-b830eaf3e0eb5fb7a548dc78fff33b2e3659704a.tar.gz
clang-b830eaf3e0eb5fb7a548dc78fff33b2e3659704a.tar.bz2
clang-b830eaf3e0eb5fb7a548dc78fff33b2e3659704a.tar.xz
Fix leak from r210059
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
-rw-r--r--include/clang/Frontend/CompilerInstance.h2
-rw-r--r--lib/CodeGen/CodeGenAction.cpp2
-rw-r--r--lib/Frontend/CompilerInstance.cpp6
-rw-r--r--test/Frontend/disable-output.c5
4 files changed, 11 insertions, 4 deletions
diff --git a/include/clang/Frontend/CompilerInstance.h b/include/clang/Frontend/CompilerInstance.h
index 97c140ecbd..b144069b97 100644
--- a/include/clang/Frontend/CompilerInstance.h
+++ b/include/clang/Frontend/CompilerInstance.h
@@ -663,6 +663,8 @@ public:
std::string *ResultPathName,
std::string *TempPathName);
+ llvm::raw_null_ostream *createNullOutputFile();
+
/// }
/// @name Initialization Utility Methods
/// {
diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp
index 88f02b4e6a..a197faece1 100644
--- a/lib/CodeGen/CodeGenAction.cpp
+++ b/lib/CodeGen/CodeGenAction.cpp
@@ -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");
}
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index c65d34bd2a..ac20d7a28e 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -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,
diff --git a/test/Frontend/disable-output.c b/test/Frontend/disable-output.c
index 46dae32fc5..786ac77ef1 100644
--- a/test/Frontend/disable-output.c
+++ b/test/Frontend/disable-output.c
@@ -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.