diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index 93a3f3e84ad0..b57166d65abe 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -502,7 +502,11 @@ public: OS << OutputBuffer.getBuffer(); } // Rename to final destination (hopefully race condition won't matter here) - sys::fs::rename(TempFilename, EntryPath); + EC = sys::fs::rename(TempFilename, EntryPath); + if (EC) { + errs() << "Error: " << EC.message() << "\n"; + report_fatal_error("ThinLTO: Can't rename temporary file " + TempFilename + " to " + EntryPath); + } } };