aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/LTO/LTOBackend.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2020-03-01 12:06:51 -0800
committerFangrui Song <maskray@google.com>2020-03-02 17:49:04 -0800
commit08ff4dc9ad962d0e2db8550deed31d0377e8d2e1 (patch)
treef92966b9bcf722a6bcd1b75db86134d992fb9ccb /llvm/lib/LTO/LTOBackend.cpp
parent20ce8affce85ddea069e979a6e79a2c62ca7a0bc (diff)
downloadllvm-08ff4dc9ad962d0e2db8550deed31d0377e8d2e1.zip
llvm-08ff4dc9ad962d0e2db8550deed31d0377e8d2e1.tar.gz
llvm-08ff4dc9ad962d0e2db8550deed31d0377e8d2e1.tar.bz2
[LTO] onfig::addSaveTemps: clear ResolutionFile upon an error
Otherwise ld.lld -save-temps will crash when writing to ResolutionFile. llvm-lto2 -save-temps does not crash because it exits immediately. Reviewed By: evgeny777 Differential Revision: https://reviews.llvm.org/D75426
Diffstat (limited to 'llvm/lib/LTO/LTOBackend.cpp')
-rw-r--r--llvm/lib/LTO/LTOBackend.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp
index ec57744..b749909 100644
--- a/llvm/lib/LTO/LTOBackend.cpp
+++ b/llvm/lib/LTO/LTOBackend.cpp
@@ -61,8 +61,10 @@ Error Config::addSaveTemps(std::string OutputFileName,
std::error_code EC;
ResolutionFile = std::make_unique<raw_fd_ostream>(
OutputFileName + "resolution.txt", EC, sys::fs::OpenFlags::OF_Text);
- if (EC)
+ if (EC) {
+ ResolutionFile.reset();
return errorCodeToError(EC);
+ }
auto setHook = [&](std::string PathSuffix, ModuleHookFn &Hook) {
// Keep track of the hook provided by the linker, which also needs to run.