mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Avoid calling outs() and fouts() when the stream isn't really needed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104873 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
57bd643113
commit
26a7074939
@ -124,7 +124,8 @@ static formatted_raw_ostream *GetOutputStream(const char *TargetName,
|
|||||||
const char *ProgName) {
|
const char *ProgName) {
|
||||||
if (OutputFilename != "") {
|
if (OutputFilename != "") {
|
||||||
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
|
// Make sure that the Out file gets unlinked from the disk if we get a
|
||||||
// SIGINT
|
// SIGINT
|
||||||
@ -147,7 +148,8 @@ static formatted_raw_ostream *GetOutputStream(const char *TargetName,
|
|||||||
|
|
||||||
if (InputFilename == "-") {
|
if (InputFilename == "-") {
|
||||||
OutputFilename = "-";
|
OutputFilename = "-";
|
||||||
return &fouts();
|
return new formatted_raw_ostream(outs(),
|
||||||
|
formatted_raw_ostream::PRESERVE_STREAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
OutputFilename = GetFileNameRoot(InputFilename);
|
OutputFilename = GetFileNameRoot(InputFilename);
|
||||||
@ -332,7 +334,7 @@ int main(int argc, char **argv) {
|
|||||||
DisableVerify)) {
|
DisableVerify)) {
|
||||||
errs() << argv[0] << ": target does not support generation of this"
|
errs() << argv[0] << ": target does not support generation of this"
|
||||||
<< " file type!\n";
|
<< " file type!\n";
|
||||||
if (Out != &fouts()) delete Out;
|
delete Out;
|
||||||
// And the Out file is empty and useless, so remove it now.
|
// And the Out file is empty and useless, so remove it now.
|
||||||
sys::Path(OutputFilename).eraseFromDisk();
|
sys::Path(OutputFilename).eraseFromDisk();
|
||||||
return 1;
|
return 1;
|
||||||
@ -340,8 +342,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
PM.run(mod);
|
PM.run(mod);
|
||||||
|
|
||||||
// Delete the ostream if it's not a stdout stream
|
// Delete the ostream.
|
||||||
if (Out != &fouts()) delete Out;
|
delete Out;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -323,8 +323,7 @@ static int AssembleInput(const char *ProgName) {
|
|||||||
Parser.setTargetParser(*TAP.get());
|
Parser.setTargetParser(*TAP.get());
|
||||||
|
|
||||||
int Res = Parser.Run(NoInitialTextSection);
|
int Res = Parser.Run(NoInitialTextSection);
|
||||||
if (Out != &fouts())
|
delete Out;
|
||||||
delete Out;
|
|
||||||
|
|
||||||
// Delete output on errors.
|
// Delete output on errors.
|
||||||
if (Res && OutputFilename != "-")
|
if (Res && OutputFilename != "-")
|
||||||
|
@ -378,8 +378,12 @@ 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...
|
||||||
// FIXME: outs() is not binary!
|
// FIXME: outs() is not binary!
|
||||||
raw_ostream *Out = &outs(); // Default to printing to stdout...
|
raw_ostream *Out = 0;
|
||||||
if (OutputFilename != "-") {
|
bool DeleteStream = true;
|
||||||
|
if (OutputFilename == "-") {
|
||||||
|
Out = &outs(); // Default to printing to stdout...
|
||||||
|
DeleteStream = false;
|
||||||
|
} else {
|
||||||
if (NoOutput || AnalyzeOnly) {
|
if (NoOutput || AnalyzeOnly) {
|
||||||
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";
|
||||||
@ -540,7 +544,7 @@ 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 (Out != &outs())
|
if (DeleteStream)
|
||||||
delete Out;
|
delete Out;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user