diff --git a/clang/test/ClangScanDeps/modules-include-tree-sdk-settings.c b/clang/test/ClangScanDeps/modules-include-tree-sdk-settings.c new file mode 100644 index 0000000000000..d8064294738b7 --- /dev/null +++ b/clang/test/ClangScanDeps/modules-include-tree-sdk-settings.c @@ -0,0 +1,37 @@ +// This test checks that the module cache gets invalidated when the +// SDKSettings.json file changes. This prevents "file changed during build" +// errors when the TU does get rescanned and recompiled. + +// REQUIRES: ondisk_cas + +// RUN: rm -rf %t +// RUN: split-file %s %t + +//--- sdk/SDKSettings.json +{ + "Version": "11.0", + "MaximumDeploymentTarget": "11.0.99" +} + +//--- module.modulemap +module M { header "M.h" } +//--- M.h +//--- tu.c +#include "M.h" + +// RUN: clang-scan-deps -format experimental-include-tree-full -cas-path %t/cas -o %t/deps_clean.json \ +// RUN: -- %clang -target x86_64-apple-macos11 -isysroot %t/sdk \ +// RUN: -c %t/tu.c -o %t/tu.o -fmodules -fmodules-cache-path=%t/cache + +// RUN: sleep 1 +// RUN: echo " " >> %t/sdk/SDKSettings.json +// RUN: echo " " >> %t/tu.c + +// RUN: clang-scan-deps -format experimental-include-tree-full -cas-path %t/cas -o %t/deps_incremental.json \ +// RUN: -- %clang -target x86_64-apple-macos11 -isysroot %t/sdk \ +// RUN: -c %t/tu.c -o %t/tu.o -fmodules -fmodules-cache-path=%t/cache + +// RUN: %deps-to-rsp %t/deps_incremental.json --module-name M > %t/M.rsp +// RUN: %deps-to-rsp %t/deps_incremental.json --tu-index 0 > %t/tu.rsp +// RUN: %clang @%t/M.rsp +// RUN: %clang @%t/tu.rsp diff --git a/clang/tools/c-index-test/core_main.cpp b/clang/tools/c-index-test/core_main.cpp index af6320ae5f7fb..230d6903d840b 100644 --- a/clang/tools/c-index-test/core_main.cpp +++ b/clang/tools/c-index-test/core_main.cpp @@ -861,7 +861,10 @@ static int scanDeps(ArrayRef Args, std::string WorkingDirectory, llvm::outs() << " " << ModuleName << "\n"; llvm::outs() << " file-deps:\n"; for (const auto &FileName : ArrayRef(FileDeps.Strings, FileDeps.Count)) - llvm::outs() << " " << FileName << "\n"; + // Not reporting SDKSettings.json so that test checks can remain + // (mostly) platform-agnostic. + if (!StringRef(FileName).ends_with("SDKSettings.json")) + llvm::outs() << " " << FileName << "\n"; llvm::outs() << " build-args:"; for (const auto &Arg : ArrayRef(BuildArguments.Strings, BuildArguments.Count))