llvm.org GIT mirror llvm / b6b12e5
Use raw_fd_ostream instead of std::ofstream. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212483 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
1 changed file(s) with 9 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
2727 #include
2828 #include
2929 #include
30 #include
3130 #include
3231 #include
3332 #include
409408 /// been overridden by a native object file. Then, perform optimization and
410409 /// codegen.
411410 static ld_plugin_status all_symbols_read_hook(void) {
412 std::ofstream api_file;
411 // FIXME: raw_fd_ostream should be able to represent an unopened file.
412 std::unique_ptr api_file;
413
413414 assert(CodeGen);
414415
415416 if (options::generate_api_file) {
416 api_file.open("apifile.txt", std::ofstream::out | std::ofstream::trunc);
417 if (!api_file.is_open()) {
418 (*message)(LDPL_FATAL, "Unable to open apifile.txt for writing.");
419 abort();
420 }
417 std::string Error;
418 api_file.reset(new raw_fd_ostream("apifile.txt", Error, sys::fs::F_None));
419 if (!Error.empty())
420 (*message)(LDPL_FATAL, "Unable to open apifile.txt for writing: %s",
421 Error.c_str());
421422 }
422423
423424 for (std::list::iterator I = Modules.begin(),
430431 CodeGen->addMustPreserveSymbol(I->syms[i].name);
431432
432433 if (options::generate_api_file)
433 api_file << I->syms[i].name << "\n";
434 (*api_file) << I->syms[i].name << "\n";
434435 }
435436 }
436437 }
437
438 if (options::generate_api_file)
439 api_file.close();
440438
441439 CodeGen->setCodePICModel(output_type);
442440 CodeGen->setDebugInfo(LTO_DEBUG_MODEL_DWARF);