diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-03 00:10:29 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-03 00:10:29 +0000 |
commit | 1a55180238dbcf11113f610aea010447e51f595b (patch) | |
tree | b9769936054af70053271573496a228e18629946 /utils/TableGen/TableGen.cpp | |
parent | 78236f8c8a0e6bd966afd7e461599336956f7772 (diff) |
Replace std::iostreams with raw_ostream in TableGen.
- Sorry, I can't help myself.
- No intended functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74742 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/TableGen.cpp')
-rw-r--r-- | utils/TableGen/TableGen.cpp | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp index fb80302c1e..601581497a 100644 --- a/utils/TableGen/TableGen.cpp +++ b/utils/TableGen/TableGen.cpp @@ -18,11 +18,11 @@ #include "Record.h" #include "TGParser.h" #include "llvm/Support/CommandLine.h" -#include "llvm/Support/Streams.h" #include "llvm/System/Signals.h" #include "llvm/Support/FileUtilities.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/PrettyStackTrace.h" +#include "llvm/Support/raw_ostream.h" #include "CallingConvEmitter.h" #include "CodeEmitterGen.h" #include "RegisterInfoEmitter.h" @@ -37,8 +37,6 @@ #include "ClangDiagnosticsEmitter.h" #include <algorithm> #include <cstdio> -#include <fstream> -#include <ios> using namespace llvm; enum ActionType { @@ -140,7 +138,8 @@ static bool ParseFile(const std::string &Filename, std::string ErrorStr; MemoryBuffer *F = MemoryBuffer::getFileOrSTDIN(Filename.c_str(), &ErrorStr); if (F == 0) { - cerr << "Could not open input file '" + Filename + "': " << ErrorStr <<"\n"; + errs() << "Could not open input file '" + Filename + "': " + << ErrorStr <<"\n"; return true; } @@ -166,12 +165,14 @@ int main(int argc, char **argv) { if (ParseFile(InputFilename, IncludeDirs, SrcMgr)) return 1; - std::ostream *Out = cout.stream(); + raw_ostream *Out = &outs(); if (OutputFilename != "-") { - Out = new std::ofstream(OutputFilename.c_str()); + std::string Error; + Out = new raw_fd_ostream(OutputFilename.c_str(), false, Error); - if (!Out->good()) { - cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; + if (!Error.empty()) { + errs() << argv[0] << ": error opening " << OutputFilename + << ":" << Error << "\n"; return 1; } @@ -246,23 +247,23 @@ int main(int argc, char **argv) { return 1; } - if (Out != cout.stream()) + if (Out != &outs()) delete Out; // Close the file return 0; } catch (const TGError &Error) { - cerr << argv[0] << ": error:\n"; + errs() << argv[0] << ": error:\n"; PrintError(Error.getLoc(), Error.getMessage()); } catch (const std::string &Error) { - cerr << argv[0] << ": " << Error << "\n"; + errs() << argv[0] << ": " << Error << "\n"; } catch (const char *Error) { - cerr << argv[0] << ": " << Error << "\n"; + errs() << argv[0] << ": " << Error << "\n"; } catch (...) { - cerr << argv[0] << ": Unknown unexpected exception occurred.\n"; + errs() << argv[0] << ": Unknown unexpected exception occurred.\n"; } - if (Out != cout.stream()) { + if (Out != &outs()) { delete Out; // Close the file std::remove(OutputFilename.c_str()); // Remove the file, it's broken } |