const char *ProgName) {
if (OutputFilename != "") {
if (OutputFilename == "-")
- return &fouts();
+ return new formatted_raw_ostream(outs(),
+ formatted_raw_ostream::PRESERVE_STREAM);
// Make sure that the Out file gets unlinked from the disk if we get a
// SIGINT
if (InputFilename == "-") {
OutputFilename = "-";
- return &fouts();
+ return new formatted_raw_ostream(outs(),
+ formatted_raw_ostream::PRESERVE_STREAM);
}
OutputFilename = GetFileNameRoot(InputFilename);
DisableVerify)) {
errs() << argv[0] << ": target does not support generation of this"
<< " file type!\n";
- if (Out != &fouts()) delete Out;
+ delete Out;
// And the Out file is empty and useless, so remove it now.
sys::Path(OutputFilename).eraseFromDisk();
return 1;
PM.run(mod);
- // Delete the ostream if it's not a stdout stream
- if (Out != &fouts()) delete Out;
+ // Delete the ostream.
+ delete Out;
return 0;
}
Parser.setTargetParser(*TAP.get());
int Res = Parser.Run(NoInitialTextSection);
- if (Out != &fouts())
- delete Out;
+ delete Out;
// Delete output on errors.
if (Res && OutputFilename != "-")
// Figure out what stream we are supposed to write to...
// FIXME: outs() is not binary!
- raw_ostream *Out = &outs(); // Default to printing to stdout...
- if (OutputFilename != "-") {
+ 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";
Passes.run(*M.get());
// Delete the raw_fd_ostream.
- if (Out != &outs())
+ if (DeleteStream)
delete Out;
return 0;
}