[llvm] [llvm][cas] Improve UnifiedOnDiskActionCache validation to check cas refs (PR #171732)
Ben Langmuir via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 10 16:25:07 PST 2025
================
@@ -235,17 +235,30 @@ Error UnifiedOnDiskActionCache::putImpl(ArrayRef<uint8_t> Key,
}
Error UnifiedOnDiskActionCache::validate() const {
- auto ValidateRef = [](FileOffset Offset, ArrayRef<char> Value) -> Error {
+ auto ValidateRef = [this](FileOffset Offset, ArrayRef<char> Value) -> Error {
auto ID = ondisk::UnifiedOnDiskCache::getObjectIDFromValue(Value);
auto formatError = [&](Twine Msg) {
return createStringError(
llvm::errc::illegal_byte_sequence,
"bad record at 0x" +
- utohexstr((unsigned)Offset.get(), /*LowerCase=*/true) + ": " +
- Msg.str());
+ utohexstr((unsigned)Offset.get(), /*LowerCase=*/true) +
+ " ref=0x" + utohexstr(ID.getOpaqueData(), /*LowerCase=*/true) +
+ ": " + Msg.str());
};
if (ID.getOpaqueData() == 0)
return formatError("zero is not a valid ref");
+ // Use containsObject first, because getDigest assumes a valid ObjectID.
+ if (!UniDB->getGraphDB().containsObject(ID))
----------------
benlangmuir wrote:
Friend doesn't work because of unnamed namespace. I kept the current code but introduced `CheckUpstream` parameters on the API so we don't mix CAS instances.
https://github.com/llvm/llvm-project/pull/171732
More information about the llvm-commits
mailing list