Skip to content

Commit db58c7e

Browse files
authored
Merge pull request #34537 from zoecarver/cxx/fix/unkown-pointee-type
[cxx-interop] Bail if the type a reference type is wrapping is unkown.
2 parents 4022e3d + 3172728 commit db58c7e

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

lib/ClangImporter/ImportType.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ namespace {
505505
Type pointeeType =
506506
Impl.importTypeIgnoreIUO(pointeeQualType, ImportTypeKind::Value,
507507
AllowNSUIntegerAsInt, Bridgeability::None);
508+
if (!pointeeType)
509+
return Type();
508510

509511
if (pointeeQualType->isFunctionType()) {
510512
return importFunctionPointerLikeType(*type, pointeeType);

test/Interop/Cxx/reference/Inputs/reference.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ void setConstStaticIntRvalueRef(const int &&);
1616
auto getFuncRef() -> int (&)();
1717
auto getFuncRvalueRef() -> int (&&)();
1818

19+
// We cannot import "_Atomic" types. Make sure we fail gracefully instead of
20+
// crashing when we have an "_Atomic" type or a reference to one.
21+
void dontImportAtomicRef(_Atomic(int)&) { }
22+
1923
#endif // TEST_INTEROP_CXX_REFERENCE_INPUTS_REFERENCE_H

test/Interop/Cxx/reference/reference-module-interface.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@
1212
// CHECK: func setConstStaticIntRvalueRef(_: UnsafePointer<Int32>)
1313
// CHECK: func getFuncRef() -> @convention(c) () -> Int32
1414
// CHECK: func getFuncRvalueRef() -> @convention(c) () -> Int32
15+
16+
// CHECK-NOT: dontImportAtomicRef

0 commit comments

Comments
 (0)