[Caching] Improve diagnostics around swift caching

Improve diagnostics message for swift caching build by trying to emit
the diagnostics early when there is more context to differentiate the
different kind of problems.

After the improvement, CAS Error should be more closer to when there is
functional problem with the CAS, rather than mixing in other kinds of
problem (like scanning dependency failures) when operating with a CAS.

rdar://145676736
(cherry picked from commit 226552bf23)
This commit is contained in:
Steven Wu
2025-04-08 15:57:33 -07:00
parent f6a864a188
commit edb94fb2fb
9 changed files with 178 additions and 127 deletions

View File

@@ -456,7 +456,7 @@ bool CompilerInstance::setupCASIfNeeded(ArrayRef<const char *> Args) {
const auto &Opts = getInvocation().getCASOptions();
auto MaybeDB= Opts.CASOpts.getOrCreateDatabases();
if (!MaybeDB) {
Diagnostics.diagnose(SourceLoc(), diag::error_cas,
Diagnostics.diagnose(SourceLoc(), diag::error_cas_initialization,
toString(MaybeDB.takeError()));
return true;
}
@@ -466,6 +466,7 @@ bool CompilerInstance::setupCASIfNeeded(ArrayRef<const char *> Args) {
auto BaseKey = createCompileJobBaseCacheKey(*CAS, Args);
if (!BaseKey) {
Diagnostics.diagnose(SourceLoc(), diag::error_cas,
"creating base cache key",
toString(BaseKey.takeError()));
return true;
}
@@ -636,7 +637,7 @@ bool CompilerInstance::setUpVirtualFileSystemOverlays() {
CASOpts.ClangIncludeTrees,
CASOpts.ClangIncludeTreeFileList);
if (!FS) {
Diagnostics.diagnose(SourceLoc(), diag::error_cas,
Diagnostics.diagnose(SourceLoc(), diag::error_cas_fs_creation,
toString(FS.takeError()));
return true;
}