Skip to content

[cxx-interop] Bail if the type a reference type is wrapping is unkown. #34537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/ClangImporter/ImportType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ namespace {
Type pointeeType =
Impl.importTypeIgnoreIUO(pointeeQualType, ImportTypeKind::Value,
AllowNSUIntegerAsInt, Bridgeability::None);
if (!pointeeType)
return Type();

if (pointeeQualType->isFunctionType()) {
return importFunctionPointerLikeType(*type, pointeeType);
Expand Down
4 changes: 4 additions & 0 deletions test/Interop/Cxx/reference/Inputs/reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ void setConstStaticIntRvalueRef(const int &&);
auto getFuncRef() -> int (&)();
auto getFuncRvalueRef() -> int (&&)();

// We cannot import "_Atomic" types. Make sure we fail gracefully instead of
// crashing when we have an "_Atomic" type or a reference to one.
void dontImportAtomicRef(_Atomic(int)&) { }

#endif // TEST_INTEROP_CXX_REFERENCE_INPUTS_REFERENCE_H
2 changes: 2 additions & 0 deletions test/Interop/Cxx/reference/reference-module-interface.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@
// CHECK: func setConstStaticIntRvalueRef(_: UnsafePointer<Int32>)
// CHECK: func getFuncRef() -> @convention(c) () -> Int32
// CHECK: func getFuncRvalueRef() -> @convention(c) () -> Int32

// CHECK-NOT: dontImportAtomicRef