[llvm-commits] [llvm] r93685 - /llvm/trunk/tools/opt/opt.cpp
Dan Gohman
gohman at apple.com
Sun Jan 17 09:47:24 PST 2010
Author: djg
Date: Sun Jan 17 11:47:24 2010
New Revision: 93685
URL: http://llvm.org/viewvc/llvm-project?rev=93685&view=rev
Log:
Don't create a (empty) output file, and don't warn about bitcode output
to a console, when --analyze is used.
Similarly, avoid creating an empty output file when --disable-output is used.
Print a warning when the -o option appears with either --analyze or
--disable-output, to indicate that the option is being ignored.
Modified:
llvm/trunk/tools/opt/opt.cpp
Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=93685&r1=93684&r2=93685&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Sun Jan 17 11:47:24 2010
@@ -373,24 +373,29 @@
// FIXME: outs() is not binary!
raw_ostream *Out = &outs(); // Default to printing to stdout...
if (OutputFilename != "-") {
- // 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;
+ }
}
}
// If the output is set to be emitted to standard out, and standard out is a
// console, print out a warning message and refuse to do it. We don't
// impress anyone by spewing tons of binary goo to a terminal.
- if (!Force && !NoOutput && !OutputAssembly)
+ if (!Force && !NoOutput && !AnalyzeOnly && !OutputAssembly)
if (CheckBitcodeOutputToConsole(*Out, !Quiet))
NoOutput = true;
@@ -517,7 +522,7 @@
if (!NoVerify && !VerifyEach)
Passes.add(createVerifierPass());
- // Write bitcode or assembly out to disk or outs() as the last step...
+ // Write bitcode or assembly out to disk or outs() as the last step...
if (!NoOutput && !AnalyzeOnly) {
if (OutputAssembly)
Passes.add(createPrintModulePass(Out));
More information about the llvm-commits
mailing list