[CAS] Improve swift cas options

Using the same CASOption from clang to communicate CAS configurations so
it is easier to exchange CAS configuration between them.
This commit is contained in:
Steven Wu
2023-06-12 15:33:35 -07:00
parent b1b16981fe
commit 2b7d38dc16
15 changed files with 289 additions and 39 deletions

View File

@@ -406,14 +406,13 @@ bool CompilerInstance::setupCASIfNeeded(ArrayRef<const char *> Args) {
if (!Opts.EnableCAS)
return false;
auto MaybeCache = llvm::cas::createOnDiskUnifiedCASDatabases(Opts.CASPath);
if (!MaybeCache) {
Diagnostics.diagnose(SourceLoc(), diag::error_create_cas, Opts.CASPath,
toString(MaybeCache.takeError()));
auto MaybeDB= Opts.CASOpts.getOrCreateDatabases();
if (!MaybeDB) {
Diagnostics.diagnose(SourceLoc(), diag::error_cas,
toString(MaybeDB.takeError()));
return true;
}
CAS = std::move(MaybeCache->first);
ResultCache = std::move(MaybeCache->second);
std::tie(CAS, ResultCache) = *MaybeDB;
// create baseline key.
auto BaseKey = createCompileJobBaseCacheKey(*CAS, Args);