Skip to content

Commit f53be47

Browse files
authored
Merge pull request #67211 from zoecarver/fix-linker-error-in-linkage
[cxx-interop] Break when we find a linkage specification when traversing all decls in IRGen.
2 parents e811193 + 28ba2d8 commit f53be47

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

lib/IRGen/GenClangDecl.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ void IRGenModule::emitClangDecl(const clang::Decl *decl) {
188188
if (isa<clang::TagDecl>(DC)) {
189189
break;
190190
}
191+
if (isa<clang::LinkageSpecDecl>(DC)) {
192+
break;
193+
}
191194
D = cast<const clang::Decl>(DC);
192195
}
193196
if (!GlobalClangDecls.insert(D->getCanonicalDecl()).second) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
extern "C" {
2+
3+
inline void inlineFn();
4+
5+
void cacheMis() { }
6+
void incorrectCacheHit() {
7+
inlineFn();
8+
}
9+
10+
static void caller() {
11+
cacheMis();
12+
incorrectCacheHit();
13+
}
14+
15+
inline void inlineFn() { }
16+
17+
}
18+

test/Interop/Cxx/extern-c/Inputs/module.modulemap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ module ExternC {
22
header "extern-c.h"
33
requires cplusplus
44
}
5+
6+
module InlineFunc {
7+
header "inline-func.h"
8+
requires cplusplus
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-run-simple-swift(-I %S/Inputs/ -Xfrontend -enable-experimental-cxx-interop)
2+
// REQUIRES: executable_test
3+
4+
import InlineFunc
5+
6+
public func test() {
7+
caller()
8+
}

0 commit comments

Comments
 (0)