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 {
336
336
// / for testing purposes only.
337
337
bool DisableBuildingInterface = false ;
338
338
339
+ // / Is this frontend configuration of an interface dependency scan sub-invocation
340
+ bool DependencyScanningSubInvocation = false ;
341
+
339
342
// / When performing a dependency scanning action, only identify and output all imports
340
343
// / of the main Swift module's source files.
341
344
bool ImportPrescan = false ;
Original file line number Diff line number Diff line change @@ -1169,9 +1169,14 @@ bool CompilerInstance::canImportCxxShim() const {
1169
1169
ImportPath::Module::Builder builder (
1170
1170
getASTContext ().getIdentifier (CXX_SHIM_NAME));
1171
1171
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.
1172
1175
return getASTContext ().testImportModule (modulePath) &&
1173
1176
!Invocation.getFrontendOptions ()
1174
- .InputsAndOutputs .hasModuleInterfaceOutputPath ();
1177
+ .InputsAndOutputs .hasModuleInterfaceOutputPath () &&
1178
+ !Invocation.getFrontendOptions ()
1179
+ .DependencyScanningSubInvocation ;
1175
1180
}
1176
1181
1177
1182
bool CompilerInstance::supportCaching () const {
Original file line number Diff line number Diff line change @@ -1808,6 +1808,8 @@ InterfaceSubContextDelegateImpl::InterfaceSubContextDelegateImpl(
1808
1808
// in the Swift compile commands, when different.
1809
1809
inheritedParentContextClangArgs =
1810
1810
clangImporterOpts.getReducedExtraArgsForSwiftModuleDependency ();
1811
+ genericSubInvocation.getFrontendOptions ()
1812
+ .DependencyScanningSubInvocation = true ;
1811
1813
} else if (LoaderOpts.strictImplicitModuleContext ) {
1812
1814
// If the compiler has been asked to be strict with ensuring downstream
1813
1815
// 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