[Caching] Re-associate diagnostics cache key with InputFile

Change how cached diagnostics are stored inside the CAS. It used to be
stored as a standalone entry for a frontend invocation in the cache and
now it is switched to be associated with input files, stored together
with other outputs like object files, etc.

This enables cleaner Cache Replay APIs and future cached diagnostics
that can be splitted up by file contribution.
This commit is contained in:
Steven Wu
2023-10-26 10:44:07 -07:00
parent 22592d22fc
commit 30cfa3deb2
8 changed files with 83 additions and 61 deletions

View File

@@ -150,6 +150,15 @@ std::string FrontendInputsAndOutputs::getStatsFileMangledInputName() const {
return isWholeModule() ? "all" : firstPrimaryInput().getFileName();
}
const InputFile &
FrontendInputsAndOutputs::getFirstOutputProducingInput() const {
// Get the first input file that produces the output file. That is currently
// used to compute with input should the cached diagnostics be associated
// with. The first output producing input file is the first input if using
// whole module, or first primary input if not using whole module.
return isWholeModule() ? firstInput() : firstPrimaryInput();
}
bool FrontendInputsAndOutputs::isInputPrimary(StringRef file) const {
return primaryInputNamed(file) != nullptr;
}