diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-23 02:56:05 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-23 02:56:05 +0000 |
commit | 4e95ea9a58b55a6e0e7783d65c0a7195fef012cd (patch) | |
tree | 510415fb9b67d009f2019ee24e85ef8eabaf2ca0 /tools/llvm-extract | |
parent | fdcd46e28ab0cc3eb975d6017ca77395214e8ad5 (diff) | |
download | external_llvm-4e95ea9a58b55a6e0e7783d65c0a7195fef012cd.zip external_llvm-4e95ea9a58b55a6e0e7783d65c0a7195fef012cd.tar.gz external_llvm-4e95ea9a58b55a6e0e7783d65c0a7195fef012cd.tar.bz2 |
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/llvm-extract')
-rw-r--r-- | tools/llvm-extract/llvm-extract.cpp | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/tools/llvm-extract/llvm-extract.cpp b/tools/llvm-extract/llvm-extract.cpp index 16e039b..4ea9dd8 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; } |