Skip to content

Commit 17f5864

Browse files
CodaFiRobert Widmann
authored andcommitted
Support Clang Module
1 parent 13140df commit 17f5864

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

lib/AST/Module.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3448,8 +3448,7 @@ bool SourceFile::importsModuleAsWeakLinked(const ModuleDecl *module) const {
34483448
importedModule->getImportedModules(reexportedModules,
34493449
ModuleDecl::ImportFilterKind::Exported);
34503450
for (const ImportedModule &reexportedModule : reexportedModules) {
3451-
if (!module->isNonSwiftModule() &&
3452-
module == reexportedModule.importedModule)
3451+
if (module == reexportedModule.importedModule)
34533452
return true;
34543453
}
34553454
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extern void clang_fn(void);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module weaklinked_import_helper_clang {
2+
header "weaklinked_import_helper_clang.h"
3+
export *
4+
}

test/IRGen/weaklinked_import_peer_transitive.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@
55
// RUN: echo '@_exported import weaklinked_import_helper' > %t/intermediate.swift
66
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/intermediate.swiftmodule -parse-as-library %t/intermediate.swift -I %t -enable-library-evolution
77
//
8-
// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir | %FileCheck %s
8+
// RUN: echo '@_exported import weaklinked_import_helper_clang' > %t/intermediate_clang.swift
9+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/intermediate_clang.swiftmodule -parse-as-library %t/intermediate_clang.swift -I %t -enable-library-evolution -Xcc -fmodule-map-file=%S/Inputs/weaklinked_import_helper_clang.modulemap
10+
//
11+
// RUN: %target-swift-frontend -primary-file %s -I %t -emit-ir -Xcc -fmodule-map-file=%S/Inputs/weaklinked_import_helper_clang.modulemap | %FileCheck %s
912

1013
// UNSUPPORTED: OS=windows-msvc
1114

1215
@_weakLinked import intermediate
16+
@_weakLinked import intermediate_clang
1317

1418
// CHECK-DAG: declare extern_weak swiftcc {{.+}} @"$s24weaklinked_import_helper2fnyyF"()
1519
fn()
20+
// CHECK-DAG: declare extern_weak void @clang_fn()
21+
clang_fn()

0 commit comments

Comments
 (0)