summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-08-23 02:56:05 +0000
committerChris Lattner <sabre@nondot.org>2009-08-23 02:56:05 +0000
commit51a1132403da7c4e8a57369815596c8d485f5db2 (patch)
tree510415fb9b67d009f2019ee24e85ef8eabaf2ca0 /tools
parent17e9edc4a7bbeadf756494cf39fcacc9eff72202 (diff)
downloadllvm-51a1132403da7c4e8a57369815596c8d485f5db2.tar.gz
llvm-51a1132403da7c4e8a57369815596c8d485f5db2.tar.bz2
llvm-51a1132403da7c4e8a57369815596c8d485f5db2.tar.xz
simplify output file selection, fixing two FIXMEs about binary output
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79808 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-extract/llvm-extract.cpp29
-rw-r--r--tools/llvm-link/llvm-link.cpp28
2 files changed, 22 insertions, 35 deletions
diff --git a/tools/llvm-extract/llvm-extract.cpp b/tools/llvm-extract/llvm-extract.cpp
index 16e039bcbf..4ea9dd84a1 100644
--- a/tools/llvm-extract/llvm-extract.cpp
+++ b/tools/llvm-extract/llvm-extract.cpp
@@ -110,29 +110,20 @@ int main(int argc, char **argv) {
Passes.add(createDeadTypeEliminationPass()); // Remove dead types...
Passes.add(createStripDeadPrototypesPass()); // Remove dead func decls
- raw_ostream *Out = 0;
-
- if (OutputFilename != "-") { // Not stdout?
- std::string ErrorInfo;
- Out = new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
- raw_fd_ostream::F_Binary |
- (Force ? raw_fd_ostream::F_Force : 0));
- if (!ErrorInfo.empty()) {
- errs() << ErrorInfo << '\n';
- if (!Force)
- errs() << "Use -f command line argument to force output\n";
- delete Out;
- return 1;
- }
- } else { // Specified stdout
- // FIXME: outs() is not binary!
- Out = &outs();
+ std::string ErrorInfo;
+ std::auto_ptr<raw_fd_ostream>
+ Out(new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
+ raw_fd_ostream::F_Binary |
+ (Force ? raw_fd_ostream::F_Force : 0)));
+ if (!ErrorInfo.empty()) {
+ errs() << ErrorInfo << '\n';
+ if (!Force)
+ errs() << "Use -f command line argument to force output\n";
+ return 1;
}
Passes.add(createBitcodeWriterPass(*Out));
Passes.run(*M.get());
- if (Out != &outs())
- delete Out;
return 0;
}
diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp
index 3d10ee3c4d..cebfec3fce 100644
--- a/tools/llvm-link/llvm-link.cpp
+++ b/tools/llvm-link/llvm-link.cpp
@@ -118,25 +118,22 @@ int main(int argc, char **argv) {
if (DumpAsm) errs() << "Here's the assembly:\n" << *Composite.get();
- // FIXME: outs() is not binary!
- raw_ostream *Out = &outs(); // Default to printing to stdout...
- if (OutputFilename != "-") {
- std::string ErrorInfo;
- Out = new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
- raw_fd_ostream::F_Binary |
- (Force ? raw_fd_ostream::F_Force : 0));
- if (!ErrorInfo.empty()) {
- errs() << ErrorInfo << '\n';
- if (!Force)
- errs() << "Use -f command line argument to force output\n";
- delete Out;
- return 1;
- }
+ std::string ErrorInfo;
+ std::auto_ptr<raw_ostream>
+ Out(new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
+ raw_fd_ostream::F_Binary |
+ (Force ? raw_fd_ostream::F_Force : 0)));
+ if (!ErrorInfo.empty()) {
+ errs() << ErrorInfo << '\n';
+ if (!Force)
+ errs() << "Use -f command line argument to force output\n";
+ return 1;
+ }
// Make sure that the Out file gets unlinked from the disk if we get a
// SIGINT
+ if (OutputFilename != "-")
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
- }
if (verifyModule(*Composite.get())) {
errs() << argv[0] << ": linked module is broken!\n";
@@ -146,6 +143,5 @@ int main(int argc, char **argv) {
if (Verbose) errs() << "Writing bitcode...\n";
WriteBitcodeToFile(Composite.get(), *Out);
- if (Out != &outs()) delete Out;
return 0;
}