diff options
author | Dan Gohman <gohman@apple.com> | 2010-05-27 19:52:20 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-05-27 19:52:20 +0000 |
commit | 7f924a3116e41d234a5693cd5f8bd1a855ce606a (patch) | |
tree | f65f8bd8dbbf18ee0452172ad6e6f7a80dccf5c3 /tools | |
parent | 9d2cbffed0f6efe53d1ccdbe78de5990203db4b6 (diff) | |
download | external_llvm-7f924a3116e41d234a5693cd5f8bd1a855ce606a.zip external_llvm-7f924a3116e41d234a5693cd5f8bd1a855ce606a.tar.gz external_llvm-7f924a3116e41d234a5693cd5f8bd1a855ce606a.tar.bz2 |
Don't create an output stream when output is disabled.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104875 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/opt/opt.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index a29555c..d094ed1 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -379,26 +379,28 @@ int main(int argc, char **argv) { // Figure out what stream we are supposed to write to... // FIXME: outs() is not binary! raw_ostream *Out = 0; - bool DeleteStream = true; - if (OutputFilename == "-") { - Out = &outs(); // Default to printing to stdout... - DeleteStream = false; - } else { - if (NoOutput || AnalyzeOnly) { - errs() << "WARNING: The -o (output filename) option is ignored when\n" - "the --disable-output or --analyze options are used.\n"; + bool DeleteStream = false; + if (!NoOutput && !AnalyzeOnly) { + if (OutputFilename == "-") { + Out = &outs(); // Default to printing to stdout... } else { - // Make sure that the Output file gets unlinked from the disk if we get a - // SIGINT - sys::RemoveFileOnSignal(sys::Path(OutputFilename)); - - std::string ErrorInfo; - Out = new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo, - raw_fd_ostream::F_Binary); - if (!ErrorInfo.empty()) { - errs() << ErrorInfo << '\n'; - delete Out; - return 1; + if (NoOutput || AnalyzeOnly) { + errs() << "WARNING: The -o (output filename) option is ignored when\n" + "the --disable-output or --analyze options are used.\n"; + } else { + // Make sure that the Output file gets unlinked from the disk if we get + // a SIGINT. + sys::RemoveFileOnSignal(sys::Path(OutputFilename)); + + std::string ErrorInfo; + Out = new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo, + raw_fd_ostream::F_Binary); + if (!ErrorInfo.empty()) { + errs() << ErrorInfo << '\n'; + delete Out; + return 1; + } + DeleteStream = true; } } } |