From f29140106f74d15ba357aa0a7f109adc939c3104 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 20 Aug 2010 16:59:15 +0000 Subject: 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 --- tools/gold/gold-plugin.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'tools/gold/gold-plugin.cpp') diff --git a/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index db0db3b5b2..858af6f432 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -453,8 +453,8 @@ static ld_plugin_status all_symbols_read_hook(void) { (*message)(LDPL_ERROR, "%s", ErrMsg.c_str()); return LDPS_ERR; } - raw_fd_ostream objFile(uniqueObjPath.c_str(), ErrMsg, - raw_fd_ostream::F_Binary); + tool_output_file objFile(uniqueObjPath.c_str(), ErrMsg, + raw_fd_ostream::F_Binary); if (!ErrMsg.empty()) { (*message)(LDPL_ERROR, "%s", ErrMsg.c_str()); return LDPS_ERR; @@ -462,6 +462,13 @@ static ld_plugin_status all_symbols_read_hook(void) { objFile.write(buffer, bufsize); objFile.close(); + if (objFile.has_error()) { + (*message)(LDPL_ERROR, "Error writing output file '%s'", + uniqueObjPath.c_str()); + objFile.clear_error(); + return LDPS_ERR; + } + objFile.keep(); lto_codegen_dispose(cg); -- cgit v1.2.3