diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index e4d91285b4458..2308a30cf754c 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -778,8 +778,6 @@ static bool ParseCASArgs(CASOptions &Opts, ArgList &Args, Opts.CacheSkipReplay |= Args.hasArg(OPT_cache_disable_replay); if (const Arg *A = Args.getLastArg(OPT_cas_path)) Opts.CASOpts.CASPath = A->getValue(); - else if (Opts.CASOpts.CASPath.empty()) - Opts.CASOpts.CASPath = llvm::cas::getDefaultOnDiskCASPath(); if (const Arg *A = Args.getLastArg(OPT_cas_plugin_path)) Opts.CASOpts.PluginPath = A->getValue(); diff --git a/lib/Frontend/Frontend.cpp b/lib/Frontend/Frontend.cpp index a21defd4be986..b5280fb575706 100644 --- a/lib/Frontend/Frontend.cpp +++ b/lib/Frontend/Frontend.cpp @@ -466,6 +466,11 @@ bool CompilerInstance::setupCASIfNeeded(ArrayRef Args) { return false; const auto &Opts = getInvocation().getCASOptions(); + 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.CASOpts.getOrCreateDatabases(); if (!MaybeDB) { Diagnostics.diagnose(SourceLoc(), diag::error_cas_initialization, diff --git a/test/CAS/cas_output_backend.swift b/test/CAS/cas_output_backend.swift index 992c4b6425f7c..0120ea00174be 100644 --- a/test/CAS/cas_output_backend.swift +++ b/test/CAS/cas_output_backend.swift @@ -13,6 +13,9 @@ // RUN: echo "\"-disable-implicit-concurrency-module-import\"" >> %t/MyApp.cmd // RUN: echo "\"-parse-stdlib\"" >> %t/MyApp.cmd +// RUN: not %target-swift-frontend -c -cache-compile-job %s -o %t/test.o @%t/MyApp.cmd 2>&1 | %FileCheck %s --check-prefix=NOT-CONFIG +// NOT-CONFIG: error: CAS cannot be initialized from the specified '-cas-*' options: no CAS options provided + // RUN: %target-swift-frontend -c -cache-compile-job -cas-path %t/cas %s -o %t/test.o @%t/MyApp.cmd // RUN: %cache-tool -cas-path %t/cas -cache-tool-action print-output-keys -- \ // RUN: %target-swift-frontend -c -cache-compile-job -cas-path %t/cas %s -o %t/test.o @%t/MyApp.cmd > %t/cache_key.json