Skip to content

Commit 639ffb9

Browse files
author
Gabor Horvath
committed
[cxx-interop] Fix crash with reverse interop in Embedded Swift
Embedded Swift has a minimal runtime, some type metadata is not available. This patch works around a crash that tries to emit C++ briding to this non-existent Swift metadata. It is very likely that there will be more fallout in reverse interop, but this patch should fix the most glaring issue, crashing on an empty Embedded Swift project. rdar://129030521
1 parent f300164 commit 639ffb9

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

lib/PrintAsClang/PrintSwiftToClangCoreScaffold.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ void printPrimitiveGenericTypeTraits(raw_ostream &os, ASTContext &astContext,
186186
if (!(isSwiftIntLong && !isInt64Long))
187187
primTypesArray = primTypesArray.drop_back(2);
188188

189+
// We do not have metadata for primitive types in Embedded Swift.
190+
if (astContext.LangOpts.hasFeature(Feature::Embedded))
191+
return;
192+
189193
for (Type type : primTypesArray) {
190194
auto typeInfo = *typeMapping.getKnownCxxTypeInfo(
191195
type->getNominalOrBoundGenericNominal());
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend %s -typecheck -module-name Core -target arm64-apple-macos15.0 -enable-experimental-feature Embedded -clang-header-expose-decls=all-public -emit-clang-header-path %t/core.h
3+
// RUN: %FileCheck %s < %t/core.h
4+
5+
// REQUIRES: OS=macosx
6+
7+
public func id(_ x: Int) -> Int {
8+
return x
9+
}
10+
11+
// CHECK-NOT: TypeMetadataTrait<bool>

0 commit comments

Comments
 (0)