From: Rafael Espindola Date: Mon, 7 Jul 2014 20:34:51 +0000 (+0000) Subject: Use raw_fd_ostream instead of std::ofstream. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=44cb242ddafeee59852878982d1da91d2e9a74b6;p=platform%2Fupstream%2Fllvm.git Use raw_fd_ostream instead of std::ofstream. llvm-svn: 212483 --- diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index f424e46..b908510 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -410,15 +409,17 @@ static bool mustPreserve(const claimed_file &F, int i) { /// been overridden by a native object file. Then, perform optimization and /// codegen. static ld_plugin_status all_symbols_read_hook(void) { - std::ofstream api_file; + // FIXME: raw_fd_ostream should be able to represent an unopened file. + std::unique_ptr api_file; + assert(CodeGen); if (options::generate_api_file) { - api_file.open("apifile.txt", std::ofstream::out | std::ofstream::trunc); - if (!api_file.is_open()) { - (*message)(LDPL_FATAL, "Unable to open apifile.txt for writing."); - abort(); - } + std::string Error; + api_file.reset(new raw_fd_ostream("apifile.txt", Error, sys::fs::F_None)); + if (!Error.empty()) + (*message)(LDPL_FATAL, "Unable to open apifile.txt for writing: %s", + Error.c_str()); } for (std::list::iterator I = Modules.begin(), @@ -431,14 +432,11 @@ static ld_plugin_status all_symbols_read_hook(void) { CodeGen->addMustPreserveSymbol(I->syms[i].name); if (options::generate_api_file) - api_file << I->syms[i].name << "\n"; + (*api_file) << I->syms[i].name << "\n"; } } } - if (options::generate_api_file) - api_file.close(); - CodeGen->setCodePICModel(output_type); CodeGen->setDebugInfo(LTO_DEBUG_MODEL_DWARF); if (!options::mcpu.empty())