Skip to content

Commit 0fea0c4

Browse files
committed
[interop][SwiftToCxx] handle Swift tuples are unsupported types for now
1 parent 0dcb8b5 commit 0fea0c4

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

lib/IRGen/IRABIDetailsProvider.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,16 @@ class IRABIDetailsProviderImpl {
135135
if (silFuncType->getLanguage() != SILFunctionLanguage::Swift)
136136
return None;
137137

138+
// FIXME: Tuple parameter mapping support.
139+
llvm::SmallVector<const ParamDecl *, 8> silParamMapping;
140+
for (auto param : *fd->getParameters()) {
141+
if (auto *tuple =
142+
param->getType()->getDesugaredType()->getAs<TupleType>()) {
143+
if (tuple->getNumElements() > 0)
144+
return None;
145+
}
146+
}
147+
138148
auto funcPointerKind =
139149
FunctionPointerKind(FunctionPointerKind::BasicKind::Function);
140150

lib/PrintAsClang/PrintClangFunction.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,9 @@ class CFunctionSignatureTypePrinter
208208
ClangRepresentation visitTupleType(TupleType *TT,
209209
Optional<OptionalTypeKind> optionalKind,
210210
bool isInOutParam) {
211-
assert(TT->getNumElements() == 0);
212-
// FIXME: Handle non-void type.
211+
if (TT->getNumElements() > 0)
212+
// FIXME: Handle non-void type.
213+
return ClangRepresentation::unsupported;
213214
os << "void";
214215
return ClangRepresentation::representable;
215216
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend %s -typecheck -module-name Functions -clang-header-expose-public-decls -emit-clang-header-path %t/functions.h
3+
// RUN: %FileCheck %s < %t/functions.h
4+
5+
// RUN: %check-interop-cxx-header-in-clang(%t/functions.h)
6+
7+
// CHECK: takesFloat
8+
// CHECK-NOT: takesTuple
9+
10+
public func takesFloat(_ x: Float) {}
11+
12+
public func takesTuple(_ x: (Float, Float)) {}

0 commit comments

Comments
 (0)