Skip to content

Commit 5cc6f24

Browse files
authored
Merge pull request #83592 from Xazax-hun/fix-bridging-header-reverse-interop-on-6.2
2 parents 838cb7a + ef63ec9 commit 5cc6f24

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

lib/AST/SwiftNameTranslation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ bool swift::cxx_translation::isObjCxxOnly(const clang::Decl *D,
272272
// requirements and the language options to check if we should actually
273273
// consider the module to have ObjC constructs.
274274
const auto &langOpts = D->getASTContext().getLangOpts();
275+
// TODO: have a reasonable guess for headers specified via
276+
// `-import-objc-header`.
277+
if (!D->hasOwningModule())
278+
return false;
275279
auto clangModule = D->getOwningModule()->getTopLevelModule();
276280
bool requiresObjC = false;
277281
for (auto req : clangModule->Requirements)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %target-swift-frontend -typecheck %t/use-cxx-types.swift -typecheck -module-name UseCxx -emit-clang-header-path %t/UseCxx.h -I %t -enable-experimental-cxx-interop -clang-header-expose-decls=all-public -import-objc-header %t/header.h
5+
6+
// RUN: %target-interop-build-clangxx -std=c++20 -c %t/use-swift-cxx-types.cpp -I %t -o %t/swift-cxx-execution.o -g
7+
// RUN: %target-interop-build-swift %t/use-cxx-types.swift -o %t/swift-cxx-execution -Xlinker %t/swift-cxx-execution.o -module-name UseCxx -Xfrontend -entry-point-function-name -Xfrontend swiftMain -I %t -g -import-objc-header %t/header.h
8+
9+
//--- header.h
10+
struct CxxTy {
11+
int field;
12+
};
13+
14+
//--- use-cxx-types.swift
15+
public func foo() -> CxxTy {
16+
CxxTy()
17+
}
18+
19+
//--- use-swift-cxx-types.cpp
20+
21+
#include "header.h"
22+
#include "UseCxx.h"
23+
24+
int main() {
25+
auto obj = UseCxx::foo();
26+
}

0 commit comments

Comments
 (0)