Skip to content

Commit b716967

Browse files
committed
[cxx-interop][IRGen] Assign Clang function types to copy constructors
This fixes an assertion failure when building certain projects with `-use-clang-function-types` Swift compiler flag: ``` Expected non-null Clang type for @convention(c)/@convention(block) function but found nullptr ``` rdar://121227452
1 parent d285e8a commit b716967

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-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},

0 commit comments

Comments
 (0)