Skip to content

Commit 7ecf84a

Browse files
committed
[interop][SwiftToCxx] ensure that resilient class values are supported
1 parent 93b6e1b commit 7ecf84a

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

lib/PrintAsClang/PrintClangFunction.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ void DeclAndTypeClangFunctionPrinter::printFunctionSignature(
347347
bool isIndirectReturnType =
348348
kind == FunctionSignatureKind::CFunctionProto &&
349349
!isKnownCType(resultTy, typeMapping) &&
350-
(isResilientType(resultTy) || isGenericType(resultTy) ||
350+
((isResilientType(resultTy) && !resultTy->isAnyClassReferenceType()) ||
351+
isGenericType(resultTy) ||
351352
interopContext.getIrABIDetails().shouldReturnIndirectly(resultTy));
352353
if (!isIndirectReturnType) {
353354
OptionalTypeKind retKind;

test/Interop/SwiftToCxx/class/swift-class-execution.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88
// RUN: %target-codesign %t/swift-class-execution
99
// RUN: %target-run %t/swift-class-execution | %FileCheck %s
1010

11+
// RUN: %empty-directory(%t-evo)
12+
13+
// RUN: %target-swift-frontend %S/swift-class-in-cxx.swift -typecheck -module-name Class -clang-header-expose-public-decls -enable-library-evolution -emit-clang-header-path %t-evo/class.h
14+
15+
// RUN: %target-interop-build-clangxx -c %s -I %t-evo -o %t-evo/swift-class-execution.o
16+
// RUN: %target-interop-build-swift %S/swift-class-in-cxx.swift -o %t-evo/swift-class-execution-evo -Xlinker %t-evo/swift-class-execution.o -module-name Class -enable-library-evolution -Xfrontend -entry-point-function-name -Xfrontend swiftMain
17+
18+
// RUN: %target-codesign %t-evo/swift-class-execution-evo
19+
// RUN: %target-run %t-evo/swift-class-execution-evo | %FileCheck %s
20+
1121
// REQUIRES: executable_test
1222

1323
#include <assert.h>

test/Interop/SwiftToCxx/class/swift-class-in-cxx.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
// RUN: %check-interop-cxx-header-in-clang(%t/class.h)
66

7+
// RUN: %target-swift-frontend %s -typecheck -module-name Class -enable-library-evolution -clang-header-expose-public-decls -emit-clang-header-path %t/class-evo.h
8+
// RUN: %FileCheck %s < %t/class-evo.h
9+
10+
// RUN: %check-interop-cxx-header-in-clang(%t/class-evo.h)
11+
712
public final class ClassWithIntField {
813
var field: Int64
914

test/Interop/SwiftToCxx/class/swift-class-inheritance-execution.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
// RUN: not %target-interop-build-clangxx -c %s -I %t -o %t/swift-class-execution.o -DERROR1
1212
// RUN: not %target-interop-build-clangxx -c %s -I %t -o %t/swift-class-execution.o -DERROR2
1313

14+
// RUN: %empty-directory(%t-evo)
15+
16+
// RUN: %target-swift-frontend %S/swift-class-inheritance-in-cxx.swift -typecheck -module-name Class -enable-library-evolution -clang-header-expose-public-decls -emit-clang-header-path %t-evo/class.h
17+
18+
// RUN: %target-interop-build-clangxx -c %s -I %t-evo -o %t-evo/swift-class-execution.o
19+
// RUN: %target-interop-build-swift %S/swift-class-inheritance-in-cxx.swift -o %t-evo/swift-class-execution-evo -Xlinker %t-evo/swift-class-execution.o -module-name Class -enable-library-evolution -Xfrontend -entry-point-function-name -Xfrontend swiftMain
20+
21+
// RUN: %target-codesign %t-evo/swift-class-execution-evo
22+
// RUN: %target-run %t-evo/swift-class-execution-evo | %FileCheck %s
23+
1424
// REQUIRES: executable_test
1525

1626
#include <assert.h>

test/Interop/SwiftToCxx/class/swift-class-inheritance-in-cxx.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
// RUN: %check-interop-cxx-header-in-clang(%t/class.h)
66

7+
// RUN: %target-swift-frontend %s -typecheck -module-name Class -enable-library-evolution -clang-header-expose-public-decls -emit-clang-header-path %t/class-evo.h
8+
// RUN: %FileCheck %s < %t/class-evo.h
9+
10+
// RUN: %check-interop-cxx-header-in-clang(%t/class-evo.h)
11+
712
public class BaseClass {
813
var field: Int64
914

0 commit comments

Comments
 (0)