File tree Expand file tree Collapse file tree 4 files changed +29
-1
lines changed Expand file tree Collapse file tree 4 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -336,6 +336,9 @@ class FrontendOptions {
336336 // / for testing purposes only.
337337 bool DisableBuildingInterface = false ;
338338
339+ // / Is this frontend configuration of an interface dependency scan sub-invocation
340+ bool DependencyScanningSubInvocation = false ;
341+
339342 // / When performing a dependency scanning action, only identify and output all imports
340343 // / of the main Swift module's source files.
341344 bool ImportPrescan = false ;
Original file line number Diff line number Diff line change @@ -1169,9 +1169,14 @@ bool CompilerInstance::canImportCxxShim() const {
11691169 ImportPath::Module::Builder builder (
11701170 getASTContext ().getIdentifier (CXX_SHIM_NAME));
11711171 auto modulePath = builder.get ();
1172+ // Currently, Swift interfaces are not to expose their
1173+ // C++ dependencies. Which means that when scanning them we should not
1174+ // bring in such dependencies, including CxxShims.
11721175 return getASTContext ().testImportModule (modulePath) &&
11731176 !Invocation.getFrontendOptions ()
1174- .InputsAndOutputs .hasModuleInterfaceOutputPath ();
1177+ .InputsAndOutputs .hasModuleInterfaceOutputPath () &&
1178+ !Invocation.getFrontendOptions ()
1179+ .DependencyScanningSubInvocation ;
11751180}
11761181
11771182bool CompilerInstance::supportCaching () const {
Original file line number Diff line number Diff line change @@ -1808,6 +1808,8 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
18081808 // in the Swift compile commands, when different.
18091809 inheritedParentContextClangArgs =
18101810 clangImporterOpts.getReducedExtraArgsForSwiftModuleDependency ();
1811+ genericSubInvocation.getFrontendOptions ()
1812+ .DependencyScanningSubInvocation = true ;
18111813 } else if (LoaderOpts.strictImplicitModuleContext ) {
18121814 // If the compiler has been asked to be strict with ensuring downstream
18131815 // dependencies get the parent invocation's context, inherit the extra Clang
Original file line number Diff line number Diff line change 1+ // REQUIRES: OS=macosx
2+ // RUN: %empty-directory(%t)
3+ // RUN: %empty-directory(%t/deps)
4+ // RUN: split-file %s %t
5+ // RUN: mv %t/Foo.swiftinterface %t/deps/
6+
7+ // RUN: %target-swift-frontend -scan-dependencies -o %t/deps.json %t/a.swift -I %t/deps -verify
8+
9+ //--- Foo.swiftinterface
10+ // swift-interface-format-version: 1.0
11+ // swift-module-flags: -module-name Foo -cxx-interoperability-mode=default
12+ public struct S1 { }
13+
14+ //--- a.swift
15+ import Foo
16+
17+ // RUN: cat %t/deps.json | %FileCheck %s
18+ // CHECK-NOT: "CxxShim"
You can’t perform that action at this time.
0 commit comments