summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-05-27 19:52:20 +0000
committerDan Gohman <gohman@apple.com>2010-05-27 19:52:20 +0000
commit93b2f9e97b601a2a20ef7dca96c49daea5e87f56 (patch)
treec30e6f2d2bf662e4cea8610b7fc4fd3bdcddf348
parentc6e5a4c68f6593a5ae61e46e3f22545e68ccbeb7 (diff)
downloadbcm5719-llvm-93b2f9e97b601a2a20ef7dca96c49daea5e87f56.tar.gz
bcm5719-llvm-93b2f9e97b601a2a20ef7dca96c49daea5e87f56.zip
Don't create an output stream when output is disabled.
llvm-svn: 104875
-rw-r--r--llvm/tools/opt/opt.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp
index a29555ccf95..d094ed11de2 100644
--- a/llvm/tools/opt/opt.cpp
+++ b/llvm/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;
}
}
}
OpenPOWER on IntegriCloud