Skip to content

Commit a81259e

Browse files
authored
Merge pull request #72770 from apple/egorzhdan/clang-fn-type-copy-ctor
[cxx-interop][IRGen] Assign Clang function types to copy constructors
2 parents f751131 + 802f20e commit a81259e

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

lib/IRGen/GenStruct.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,10 +603,17 @@ namespace {
603603
ParameterConvention::Direct_Unowned);
604604
SILResultInfo result(T.getASTType(), ResultConvention::Indirect);
605605

606+
auto clangFnType = T.getASTContext().getCanonicalClangFunctionType(
607+
{ptrParam}, result, SILFunctionTypeRepresentation::CFunctionPointer);
608+
auto extInfo = SILExtInfoBuilder()
609+
.withClangFunctionType(clangFnType)
610+
.withRepresentation(
611+
SILFunctionTypeRepresentation::CFunctionPointer)
612+
.build();
613+
606614
return SILFunctionType::get(
607615
GenericSignature(),
608-
SILFunctionType::ExtInfo().withRepresentation(
609-
SILFunctionTypeRepresentation::CFunctionPointer),
616+
extInfo,
610617
SILCoroutineKind::None,
611618
/*callee=*/ParameterConvention::Direct_Unowned,
612619
/*params*/ {ptrParam},

test/Interop/Cxx/class/Inputs/constructors.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,10 @@ struct DeletedCopyConstructor {
8080
DeletedCopyConstructor(const DeletedCopyConstructor &) = delete;
8181
};
8282

83+
#ifdef ENABLE_PTRAUTH
84+
struct HasPtrAuthMember {
85+
void (*__ptrauth(1, 1, 3) handler)();
86+
};
87+
#endif
88+
8389
#endif // TEST_INTEROP_CXX_CLASS_INPUTS_CONSTRUCTORS_H
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %swift -emit-ir -module-name CopyConstructorsPtrAuth -target arm64e-apple-macosx11.0 -use-clang-function-types -Xcc -D -Xcc ENABLE_PTRAUTH -dump-clang-diagnostics -I %S/Inputs -cxx-interoperability-mode=default %s -parse-as-library
2+
3+
// REQUIRES: CPU=arm64e
4+
// REQUIRES: OS=macosx
5+
6+
import Constructors
7+
8+
public func copyPtrAuthMemberWithDefaultCopyConstructor(_ x: HasPtrAuthMember)
9+
-> (HasPtrAuthMember, HasPtrAuthMember) {
10+
return (x, x)
11+
}

0 commit comments

Comments
 (0)