diff options
Diffstat (limited to 'tools/opt/GraphPrinters.cpp')
-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"; } |