File tree Expand file tree Collapse file tree 4 files changed +36
-0
lines changed
test/Interop/Cxx/extern-c Expand file tree Collapse file tree 4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -9331,6 +9331,13 @@ ClangImporter::Implementation::importDeclContextOf(
93319331 switch (context.getKind ()) {
93329332 case EffectiveClangContext::DeclContext: {
93339333 auto dc = context.getAsDeclContext ();
9334+
9335+ // For C++-Interop in cases where #ifdef __cplusplus surround an extern "C"
9336+ // you want to first check if the TU decl is the parent of this extern "C"
9337+ // decl (aka LinkageSpecDecl) and then proceed.
9338+ if (dc->getDeclKind () == clang::Decl::LinkageSpec)
9339+ dc = dc->getParent ();
9340+
93349341 if (dc->isTranslationUnit ()) {
93359342 if (auto *module = getClangModuleForDecl (decl))
93369343 return module ;
Original file line number Diff line number Diff line change 1+ @interface A
2+ @end
3+
4+ extern " C"
5+ @interface A (CAT1)
6+ - (int )foo ;
7+ @end
8+
9+ @interface A (CAT2)
10+ - (int )bar ;
11+ @end
Original file line number Diff line number Diff line change 1+ module ExternC {
2+ header "extern-c.h"
3+ requires cplusplus
4+ }
Original file line number Diff line number Diff line change 1+ // RUN: %target-swift-ide-test -print-module -module-to-print=ExternC -I %S/Inputs -source-filename=x -enable-cxx-interop -enable-objc-interop | %FileCheck %s
2+
3+ // CHECK: class A {
4+ // CHECK-NEXT: }
5+
6+ // CHECK: extension A {
7+ // CHECK-NEXT: class func foo() -> Int32
8+ // CHECK-NEXT: func foo() -> Int32
9+ // CHECK-NEXT: }
10+
11+ // CHECK: extension A {
12+ // CHECK-NEXT: class func bar() -> Int32
13+ // CHECK-NEXT: func bar() -> Int32
14+ // CHECK-NEXT: }
You can’t perform that action at this time.
0 commit comments