summaryrefslogtreecommitdiff
path: root/tools/llvm-ld
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-08-20 16:59:15 +0000
committerDan Gohman <gohman@apple.com>2010-08-20 16:59:15 +0000
commitf29140106f74d15ba357aa0a7f109adc939c3104 (patch)
tree770be753408ca9fefa28ec3a13ef8f45e00cba3a /tools/llvm-ld
parente7b67d0e94df497791207618194e1db545ac3721 (diff)
downloadllvm-f29140106f74d15ba357aa0a7f109adc939c3104.tar.gz
llvm-f29140106f74d15ba357aa0a7f109adc939c3104.tar.bz2
llvm-f29140106f74d15ba357aa0a7f109adc939c3104.tar.xz
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
Diffstat (limited to 'tools/llvm-ld')
-rw-r--r--tools/llvm-ld/llvm-ld.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/tools/llvm-ld/llvm-ld.cpp b/tools/llvm-ld/llvm-ld.cpp
index eeb784b9e0..e4b2ae5d67 100644
--- a/tools/llvm-ld/llvm-ld.cpp
+++ b/tools/llvm-ld/llvm-ld.cpp
@@ -236,13 +236,16 @@ void GenerateBitcode(Module* M, const std::string& FileName) {
// Create the output file.
std::string ErrorInfo;
- raw_fd_ostream Out(FileName.c_str(), ErrorInfo,
- raw_fd_ostream::F_Binary);
- if (!ErrorInfo.empty())
+ tool_output_file Out(FileName.c_str(), ErrorInfo,
+ raw_fd_ostream::F_Binary);
+ if (!ErrorInfo.empty()) {
PrintAndExit(ErrorInfo, M);
+ return;
+ }
// Write it out
WriteBitcodeToFile(M, Out);
+ Out.keep();
}
/// GenerateAssembly - generates a native assembly language source file from the
@@ -425,7 +428,7 @@ static void EmitShellScript(char **argv, Module *M) {
// Output the script to start the program...
std::string ErrorInfo;
- raw_fd_ostream Out2(OutputFilename.c_str(), ErrorInfo);
+ tool_output_file Out2(OutputFilename.c_str(), ErrorInfo);
if (!ErrorInfo.empty())
PrintAndExit(ErrorInfo, M);
@@ -466,6 +469,7 @@ static void EmitShellScript(char **argv, Module *M) {
Out2 << " -load=" << FullLibraryPath.str() << " \\\n";
}
Out2 << " " << BitcodeOutputFilename << " ${1+\"$@\"}\n";
+ Out2.keep();
}
// BuildLinkItems -- This function generates a LinkItemList for the LinkItems