Don't translate "-" to outs() manually; raw_ostream does that automatically.

llvm-svn: 111371
This commit is contained in:
Dan Gohman 2010-08-18 17:40:10 +00:00
parent 80f9de4bb5
commit b01aed1cb2
1 changed files with 22 additions and 30 deletions

View File

@ -53,7 +53,7 @@ InputFilename(cl::Positional, cl::desc("<input bitcode file>"),
static cl::opt<std::string> static cl::opt<std::string>
OutputFilename("o", cl::desc("Override output filename"), OutputFilename("o", cl::desc("Override output filename"),
cl::value_desc("filename"), cl::init("-")); cl::value_desc("filename"));
static cl::opt<bool> static cl::opt<bool>
Force("f", cl::desc("Enable binary output on terminals")); Force("f", cl::desc("Enable binary output on terminals"));
@ -381,22 +381,18 @@ int main(int argc, char **argv) {
// Figure out what stream we are supposed to write to... // Figure out what stream we are supposed to write to...
raw_ostream *Out = 0; raw_ostream *Out = 0;
bool DeleteStream = false;
if (!NoOutput && !AnalyzeOnly) {
if (OutputFilename == "-") {
// Print to stdout.
Out = &outs();
// If we're printing a bitcode file, switch stdout to binary mode.
// FIXME: This switches outs() globally, not just for the bitcode output.
if (!OutputAssembly)
sys::Program::ChangeStdoutToBinary();
} else {
if (NoOutput || AnalyzeOnly) { if (NoOutput || AnalyzeOnly) {
if (!OutputFilename.empty())
errs() << "WARNING: The -o (output filename) option is ignored when\n" errs() << "WARNING: The -o (output filename) option is ignored when\n"
"the --disable-output or --analyze options are used.\n"; "the --disable-output or --analyze options are used.\n";
} else { } else {
// Default to standard output.
if (OutputFilename.empty())
OutputFilename = "-";
// Make sure that the Output file gets unlinked from the disk if we get // Make sure that the Output file gets unlinked from the disk if we get
// a SIGINT. // a SIGINT.
if (OutputFilename != "-")
sys::RemoveFileOnSignal(sys::Path(OutputFilename)); sys::RemoveFileOnSignal(sys::Path(OutputFilename));
std::string ErrorInfo; std::string ErrorInfo;
@ -407,9 +403,6 @@ int main(int argc, char **argv) {
delete Out; delete Out;
return 1; return 1;
} }
DeleteStream = true;
}
}
} }
// If the output is set to be emitted to standard out, and standard out is a // If the output is set to be emitted to standard out, and standard out is a
@ -553,7 +546,6 @@ int main(int argc, char **argv) {
Passes.run(*M.get()); Passes.run(*M.get());
// Delete the raw_fd_ostream. // Delete the raw_fd_ostream.
if (DeleteStream)
delete Out; delete Out;
return 0; return 0;
} }