diff options
author | Dan Gohman <gohman@apple.com> | 2010-08-20 16:59:15 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-08-20 16:59:15 +0000 |
commit | f29140106f74d15ba357aa0a7f109adc939c3104 (patch) | |
tree | 770be753408ca9fefa28ec3a13ef8f45e00cba3a /tools/opt | |
parent | e7b67d0e94df497791207618194e1db545ac3721 (diff) | |
download | llvm-f29140106f74d15ba357aa0a7f109adc939c3104.tar.gz llvm-f29140106f74d15ba357aa0a7f109adc939c3104.tar.bz2 llvm-f29140106f74d15ba357aa0a7f109adc939c3104.tar.xz |
Convert tools to use tool_output_file, and introduce error
checking to places which previously lacked it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111651 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/opt')
-rw-r--r-- | tools/opt/GraphPrinters.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/tools/opt/GraphPrinters.cpp b/tools/opt/GraphPrinters.cpp index 6a9e96516d..d689a4a1da 100644 --- a/tools/opt/GraphPrinters.cpp +++ b/tools/opt/GraphPrinters.cpp @@ -28,13 +28,19 @@ static void WriteGraphToFile(raw_ostream &O, const std::string &GraphName, std::string Filename = GraphName + ".dot"; O << "Writing '" << Filename << "'..."; std::string ErrInfo; - raw_fd_ostream F(Filename.c_str(), ErrInfo); + tool_output_file F(Filename.c_str(), ErrInfo); - if (ErrInfo.empty()) + if (ErrInfo.empty()) { WriteGraph(F, GT); - else - O << " error opening file for writing!"; - O << "\n"; + F.close(); + if (!F.has_error()) { + O << "\n"; + F.keep(); + return; + } + } + F.clear_error(); + O << " error opening file for writing!\n"; } |