summaryrefslogtreecommitdiff
path: root/tools/llc
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2008-08-21 00:14:44 +0000
committerOwen Anderson <resistor@mac.com>2008-08-21 00:14:44 +0000
commitcb3718832375a581c5ea23f15918f3ea447a446c (patch)
treea72c740cc8590cd63825fcf08f71c5e2f625ca55 /tools/llc
parentf4a97da4072a2ee4aca3c668a9fa113c06fdef8d (diff)
downloadllvm-cb3718832375a581c5ea23f15918f3ea447a446c.tar.gz
llvm-cb3718832375a581c5ea23f15918f3ea447a446c.tar.bz2
llvm-cb3718832375a581c5ea23f15918f3ea447a446c.tar.xz
Use raw_ostream throughout the AsmPrinter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55092 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llc')
-rw-r--r--tools/llc/llc.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp
index dfd1f6b073..2c725e8a2f 100644
--- a/tools/llc/llc.cpp
+++ b/tools/llc/llc.cpp
@@ -31,6 +31,7 @@
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/PluginLoader.h"
#include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/System/Signals.h"
#include "llvm/Config/config.h"
@@ -106,10 +107,10 @@ GetFileNameRoot(const std::string &InputFilename) {
return outputFilename;
}
-static std::ostream *GetOutputStream(const char *ProgName) {
+static raw_ostream *GetOutputStream(const char *ProgName) {
if (OutputFilename != "") {
if (OutputFilename == "-")
- return &std::cout;
+ return &outs();
// Specified an output filename?
if (!Force && std::ifstream(OutputFilename.c_str())) {
@@ -123,12 +124,13 @@ static std::ostream *GetOutputStream(const char *ProgName) {
// SIGINT
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
- return new std::ofstream(OutputFilename.c_str());
+ std::string error;
+ return new raw_fd_ostream(OutputFilename.c_str(), error);
}
if (InputFilename == "-") {
OutputFilename = "-";
- return &std::cout;
+ return &outs();
}
OutputFilename = GetFileNameRoot(InputFilename);
@@ -165,9 +167,10 @@ static std::ostream *GetOutputStream(const char *ProgName) {
// SIGINT
sys::RemoveFileOnSignal(sys::Path(OutputFilename));
- std::ostream *Out = new std::ofstream(OutputFilename.c_str());
- if (!Out->good()) {
- std::cerr << ProgName << ": error opening " << OutputFilename << "!\n";
+ std::string error;
+ raw_ostream *Out = new raw_fd_ostream(OutputFilename.c_str(), error);
+ if (!error.empty()) {
+ std::cerr << error;
delete Out;
return 0;
}
@@ -229,7 +232,7 @@ int main(int argc, char **argv) {
TargetMachine &Target = *target.get();
// Figure out where we are going to send the output...
- std::ostream *Out = GetOutputStream(argv[0]);
+ raw_ostream *Out = GetOutputStream(argv[0]);
if (Out == 0) return 1;
// If this target requires addPassesToEmitWholeFile, do it now. This is
@@ -244,7 +247,7 @@ int main(int argc, char **argv) {
if (Target.addPassesToEmitWholeFile(PM, *Out, FileType, Fast)) {
std::cerr << argv[0] << ": target does not support generation of this"
<< " file type!\n";
- if (Out != &std::cout) delete Out;
+ if (Out != &outs()) delete Out;
// And the Out file is empty and useless, so remove it now.
sys::Path(OutputFilename).eraseFromDisk();
return 1;
@@ -271,7 +274,7 @@ int main(int argc, char **argv) {
case FileModel::Error:
std::cerr << argv[0] << ": target does not support generation of this"
<< " file type!\n";
- if (Out != &std::cout) delete Out;
+ if (Out != &outs()) delete Out;
// And the Out file is empty and useless, so remove it now.
sys::Path(OutputFilename).eraseFromDisk();
return 1;
@@ -288,7 +291,7 @@ int main(int argc, char **argv) {
if (Target.addPassesToEmitFileFinish(Passes, MCE, Fast)) {
std::cerr << argv[0] << ": target does not support generation of this"
<< " file type!\n";
- if (Out != &std::cout) delete Out;
+ if (Out != &outs()) delete Out;
// And the Out file is empty and useless, so remove it now.
sys::Path(OutputFilename).eraseFromDisk();
return 1;
@@ -306,7 +309,7 @@ int main(int argc, char **argv) {
}
// Delete the ostream if it's not a stdout stream
- if (Out != &std::cout) delete Out;
+ if (Out != &outs()) delete Out;
return 0;
}