aboutsummaryrefslogtreecommitdiffstats
path: root/tools/llvm-dis
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-08-20 01:07:01 +0000
committerDan Gohman <gohman@apple.com>2010-08-20 01:07:01 +0000
commitd5826a33a5a7c298a8934541d11cda042028be3b (patch)
tree56249c802243407a71acb23ba3bcf59eb0d58b2b /tools/llvm-dis
parent52fdaeda759b2ef3b9048ab8651b024f864b3858 (diff)
downloadexternal_llvm-d5826a33a5a7c298a8934541d11cda042028be3b.zip
external_llvm-d5826a33a5a7c298a8934541d11cda042028be3b.tar.gz
external_llvm-d5826a33a5a7c298a8934541d11cda042028be3b.tar.bz2
Use the new tool_output_file in several tools. This fixes a variety
of problems with output files being left behind or output streams being left unclosed. Fix llvm-mc to respect the -o option in all modes, rather than hardcoding outs() in some cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111603 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-dis')
-rw-r--r--tools/llvm-dis/llvm-dis.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp
index b8b1a39..de6ac02 100644
--- a/tools/llvm-dis/llvm-dis.cpp
+++ b/tools/llvm-dis/llvm-dis.cpp
@@ -25,7 +25,6 @@
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Signals.h"
-#include <memory>
using namespace llvm;
static cl::opt<std::string>
@@ -88,15 +87,10 @@ int main(int argc, char **argv) {
}
}
- // Make sure that the Out file gets unlinked from the disk if we get a
- // SIGINT.
- if (OutputFilename != "-")
- sys::RemoveFileOnSignal(sys::Path(OutputFilename));
-
std::string ErrorInfo;
- std::auto_ptr<raw_fd_ostream>
- Out(new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
- raw_fd_ostream::F_Binary));
+ OwningPtr<tool_output_file>
+ Out(new tool_output_file(OutputFilename.c_str(), ErrorInfo,
+ raw_fd_ostream::F_Binary));
if (!ErrorInfo.empty()) {
errs() << ErrorInfo << '\n';
return 1;
@@ -106,6 +100,9 @@ int main(int argc, char **argv) {
if (!DontPrint)
*Out << *M;
+ // Declare success.
+ Out->keep();
+
return 0;
}