diff --git a/include/swift/AST/ModuleDependencies.h b/include/swift/AST/ModuleDependencies.h index cfc47bfda95f8..7663b99069fb0 100644 --- a/include/swift/AST/ModuleDependencies.h +++ b/include/swift/AST/ModuleDependencies.h @@ -32,7 +32,6 @@ #include "llvm/ADT/DenseSet.h" #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/StringSet.h" -#include "llvm/CAS/CASConfiguration.h" #include "llvm/CAS/CachingOnDiskFileSystem.h" #include "llvm/Support/Mutex.h" #include @@ -1037,8 +1036,8 @@ using BridgeClangDependencyCallback = llvm::function_ref CASConfig; + /// The CASOption created the Scanning Service if used. + std::optional CASOpts; /// The persistent Clang dependency scanner service std::optional diff --git a/include/swift/Basic/CASOptions.h b/include/swift/Basic/CASOptions.h index b192a67081519..567c34671fc49 100644 --- a/include/swift/Basic/CASOptions.h +++ b/include/swift/Basic/CASOptions.h @@ -20,7 +20,6 @@ #include "clang/CAS/CASOptions.h" #include "llvm/ADT/Hashing.h" -#include "llvm/CAS/CASConfiguration.h" namespace swift { @@ -38,8 +37,8 @@ class CASOptions final { /// Import modules from CAS. bool ImportModuleFromCAS = false; - /// CAS Configuration. - llvm::cas::CASConfiguration Config; + /// CASOptions + clang::CASOptions CASOpts; /// Clang Include Trees. std::string ClangIncludeTree; diff --git a/lib/AST/ModuleDependencies.cpp b/lib/AST/ModuleDependencies.cpp index 0a65c1f99dc6e..da4e33804df5b 100644 --- a/lib/AST/ModuleDependencies.cpp +++ b/lib/AST/ModuleDependencies.cpp @@ -637,9 +637,9 @@ bool SwiftDependencyScanningService::setupCachingDependencyScanningService( if (!Instance.getInvocation().getCASOptions().EnableCaching) return false; - if (CASConfig) { + if (CASOpts) { // If CASOption matches, the service is initialized already. - if (*CASConfig == Instance.getInvocation().getCASOptions().Config) + if (*CASOpts == Instance.getInvocation().getCASOptions().CASOpts) return false; // CASOption mismatch, return error. @@ -648,18 +648,13 @@ bool SwiftDependencyScanningService::setupCachingDependencyScanningService( } // Setup CAS. - CASConfig = Instance.getInvocation().getCASOptions().Config; - - clang::CASOptions CASOpts; - CASOpts.CASPath = CASConfig->CASPath; - CASOpts.PluginPath = CASConfig->PluginPath; - CASOpts.PluginOptions = CASConfig->PluginOptions; + CASOpts = Instance.getInvocation().getCASOptions().CASOpts; ClangScanningService.emplace( clang::tooling::dependencies::ScanningMode::DependencyDirectivesScan, clang::tooling::dependencies::ScanningOutputFormat::FullIncludeTree, - CASOpts, Instance.getSharedCASInstance(), - Instance.getSharedCacheInstance(), + Instance.getInvocation().getCASOptions().CASOpts, + Instance.getSharedCASInstance(), Instance.getSharedCacheInstance(), /*CachingOnDiskFileSystem=*/nullptr, // The current working directory optimization (off by default) // should not impact CAS. We set the optization to all to be diff --git a/lib/Basic/CASOptions.cpp b/lib/Basic/CASOptions.cpp index 8ba863a960754..f7e5119f9aa07 100644 --- a/lib/Basic/CASOptions.cpp +++ b/lib/Basic/CASOptions.cpp @@ -23,14 +23,14 @@ void CASOptions::enumerateCASConfigurationFlags( llvm::function_ref Callback) const { if (EnableCaching) { Callback("-cache-compile-job"); - if (!Config.CASPath.empty()) { + if (!CASOpts.CASPath.empty()) { Callback("-cas-path"); - Callback(Config.CASPath); + Callback(CASOpts.CASPath); } - if (!Config.PluginPath.empty()) { + if (!CASOpts.PluginPath.empty()) { Callback("-cas-plugin-path"); - Callback(Config.PluginPath); - for (auto Opt : Config.PluginOptions) { + Callback(CASOpts.PluginPath); + for (auto Opt : CASOpts.PluginOptions) { Callback("-cas-plugin-option"); Callback((llvm::Twine(Opt.first) + "=" + Opt.second).str()); } diff --git a/lib/ClangImporter/ClangImporter.cpp b/lib/ClangImporter/ClangImporter.cpp index 9ec07b53df69b..ab6eedc32fa62 100644 --- a/lib/ClangImporter/ClangImporter.cpp +++ b/lib/ClangImporter/ClangImporter.cpp @@ -1198,9 +1198,7 @@ std::optional> ClangImporter::getClangCC1Arguments( // compiler can be more efficient to compute swift cache key without having // the knowledge about clang command-line options. if (ctx.CASOpts.EnableCaching || ctx.CASOpts.ImportModuleFromCAS) { - CI->getCASOpts().CASPath = ctx.CASOpts.Config.CASPath; - CI->getCASOpts().PluginPath = ctx.CASOpts.Config.PluginPath; - CI->getCASOpts().PluginOptions = ctx.CASOpts.Config.PluginOptions; + CI->getCASOpts() = ctx.CASOpts.CASOpts; // When clangImporter is used to compile (generate .pcm or .pch), need to // inherit the include tree from swift args (last one wins) and clear the // input file. diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index f5c81ee5b5d8b..8cea946f4d2c0 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -804,15 +804,15 @@ static bool ParseCASArgs(CASOptions &Opts, ArgList &Args, Opts.EnableCachingRemarks |= Args.hasArg(OPT_cache_remarks); Opts.CacheSkipReplay |= Args.hasArg(OPT_cache_disable_replay); if (const Arg *A = Args.getLastArg(OPT_cas_path)) - Opts.Config.CASPath = A->getValue(); + Opts.CASOpts.CASPath = A->getValue(); if (const Arg *A = Args.getLastArg(OPT_cas_plugin_path)) - Opts.Config.PluginPath = A->getValue(); + Opts.CASOpts.PluginPath = A->getValue(); for (StringRef Opt : Args.getAllArgValues(OPT_cas_plugin_option)) { StringRef Name, Value; std::tie(Name, Value) = Opt.split('='); - Opts.Config.PluginOptions.emplace_back(std::string(Name), + Opts.CASOpts.PluginOptions.emplace_back(std::string(Name), std::string(Value)); } diff --git a/lib/Frontend/Frontend.cpp b/lib/Frontend/Frontend.cpp index 798d08642e1db..a7d7acdaa10af 100644 --- a/lib/Frontend/Frontend.cpp +++ b/lib/Frontend/Frontend.cpp @@ -477,12 +477,12 @@ bool CompilerInstance::setupCASIfNeeded(ArrayRef Args) { return false; const auto &Opts = getInvocation().getCASOptions(); - if (Opts.Config.CASPath.empty() && Opts.Config.PluginPath.empty()) { + if (Opts.CASOpts.CASPath.empty() && Opts.CASOpts.PluginPath.empty()) { Diagnostics.diagnose(SourceLoc(), diag::error_cas_initialization, "no CAS options provided"); return true; } - auto MaybeDB = Opts.Config.createDatabases(); + auto MaybeDB = Opts.CASOpts.getOrCreateDatabases(); if (!MaybeDB) { Diagnostics.diagnose(SourceLoc(), diag::error_cas_initialization, toString(MaybeDB.takeError())); diff --git a/lib/Frontend/ModuleInterfaceLoader.cpp b/lib/Frontend/ModuleInterfaceLoader.cpp index bdcd7b73ee791..6b300e012cca7 100644 --- a/lib/Frontend/ModuleInterfaceLoader.cpp +++ b/lib/Frontend/ModuleInterfaceLoader.cpp @@ -1805,7 +1805,7 @@ void InterfaceSubContextDelegateImpl::inheritOptionsForBuildingInterface( if (casOpts.EnableCaching) { genericSubInvocation.getCASOptions().EnableCaching = casOpts.EnableCaching; - genericSubInvocation.getCASOptions().Config = casOpts.Config; + genericSubInvocation.getCASOptions().CASOpts = casOpts.CASOpts; genericSubInvocation.getCASOptions().HasImmutableFileSystem = casOpts.HasImmutableFileSystem; casOpts.enumerateCASConfigurationFlags( diff --git a/lib/FrontendTool/FrontendTool.cpp b/lib/FrontendTool/FrontendTool.cpp index 34135af9a9bbe..40515b9462076 100644 --- a/lib/FrontendTool/FrontendTool.cpp +++ b/lib/FrontendTool/FrontendTool.cpp @@ -1431,8 +1431,8 @@ static bool generateReproducer(CompilerInstance &Instance, llvm::sys::path::append(casPath, "cas"); clang::CASOptions newCAS; newCAS.CASPath = casPath.str(); - newCAS.PluginPath = casOpts.Config.PluginPath; - newCAS.PluginOptions = casOpts.Config.PluginOptions; + newCAS.PluginPath = casOpts.CASOpts.PluginPath; + newCAS.PluginOptions = casOpts.CASOpts.PluginOptions; auto db = newCAS.getOrCreateDatabases(); if (!db) { diags.diagnose(SourceLoc(), diag::error_cas_initialization,