[Dependency Scanning] Interface-scanning sub-invocations should not attempt to import CxxShims

Swift interfaces currently aren't meant to expose C++ in their API so we should not also bring in this C++-related module dependency which is not found when the ClangImporter is not configured for C++.
This commit is contained in:
Artem Chikin
2024-02-14 12:45:46 -08:00
parent 9607e9dec1
commit bb5e20d015
4 changed files with 29 additions and 1 deletions

View File

@@ -1169,9 +1169,14 @@ bool CompilerInstance::canImportCxxShim() const {
ImportPath::Module::Builder builder(
getASTContext().getIdentifier(CXX_SHIM_NAME));
auto modulePath = builder.get();
// Currently, Swift interfaces are not to expose their
// C++ dependencies. Which means that when scanning them we should not
// bring in such dependencies, including CxxShims.
return getASTContext().testImportModule(modulePath) &&
!Invocation.getFrontendOptions()
.InputsAndOutputs.hasModuleInterfaceOutputPath();
.InputsAndOutputs.hasModuleInterfaceOutputPath() &&
!Invocation.getFrontendOptions()
.DependencyScanningSubInvocation;
}
bool CompilerInstance::supportCaching() const {