Skip to content

Commit

Permalink
LTO: Improve error reporting when adding a cache entry.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
pcc committed Oct 3, 2017
1 parent 84be8d2 commit eb5fecf
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/LTO/Caching.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand Down

0 comments on commit eb5fecf

Please sign in to comment.