summaryrefslogtreecommitdiff
path: root/lib/LTO/Caching.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-10-03 00:44:21 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-10-03 00:44:21 +0000
commiteb5fecf4d16be47d72b82fe8c6935476104722b0 (patch)
tree21eead7726493a5a9270ead2fd768cacb12083ed /lib/LTO/Caching.cpp
parent84be8d28a04cea95c142bebbf96a7cbf6531fe17 (diff)
LTO: Improve error reporting when adding a cache entry.
Move error handling code next to the code that returns the error, and change the error message in order to distinguish it from a similar error message elsewhere in this file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314745 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/LTO/Caching.cpp')
-rw-r--r--lib/LTO/Caching.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/LTO/Caching.cpp b/lib/LTO/Caching.cpp
index 98360f7e9e9..1708ab4c5c7 100644
--- a/lib/LTO/Caching.cpp
+++ b/lib/LTO/Caching.cpp
@@ -66,15 +66,17 @@ Expected<NativeObjectCache> lto::localCache(StringRef CacheDirectoryPath,
// Open the file first to avoid racing with a cache pruner.
ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr =
MemoryBuffer::getFile(TempFilename);
+ if (!MBOrErr)
+ report_fatal_error(Twine("Failed to open new cache file ") +
+ TempFilename + ": " +
+ MBOrErr.getError().message() + "\n");
// This is atomic on POSIX systems.
if (auto EC = sys::fs::rename(TempFilename, EntryPath))
report_fatal_error(Twine("Failed to rename temporary file ") +
- TempFilename + ": " + EC.message() + "\n");
+ TempFilename + " to " + EntryPath + ": " +
+ EC.message() + "\n");
- if (!MBOrErr)
- report_fatal_error(Twine("Failed to open cache file ") + EntryPath +
- ": " + MBOrErr.getError().message() + "\n");
AddBuffer(Task, std::move(*MBOrErr), EntryPath);
}
};