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 | 8525fe7155a34f9e3fad0ea1012542453e803153 (patch) | |
tree | 0e892b7149ebade5cee7d020dd1afca7fbc3a443 /llvm/tools/opt/GraphPrinters.cpp | |
parent | e3b3464d4e525c4ba1ff07329bfc7d0e2cc4f684 (diff) | |
download | bcm5719-llvm-8525fe7155a34f9e3fad0ea1012542453e803153.tar.gz bcm5719-llvm-8525fe7155a34f9e3fad0ea1012542453e803153.zip |
Convert tools to use tool_output_file, and introduce error
checking to places which previously lacked it.
llvm-svn: 111651
Diffstat (limited to 'llvm/tools/opt/GraphPrinters.cpp')
-rw-r--r-- | llvm/tools/opt/GraphPrinters.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/llvm/tools/opt/GraphPrinters.cpp b/llvm/tools/opt/GraphPrinters.cpp index 6a9e96516db..d689a4a1dae 100644 --- a/llvm/tools/opt/GraphPrinters.cpp +++ b/llvm/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"; } |