Skip to content

[cxx-interop] Bail on dependent reference types. We don't know how to handle those yet. #41660

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
Mar 4, 2022
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
6 changes: 6 additions & 0 deletions lib/ClangImporter/ImportType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,12 @@ namespace {
return importFunctionPointerLikeType(*type, pointeeType);
}

// Currently, we can't generate thunks for references to dependent types
// because there's no way to cast without a copy (without writing the SIL
// manually).
if (pointeeQualType->isDependentType())
return Type();

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

template<class T>
struct ClassTemplate {};

template<class T>
const ClassTemplate<T> &refToDependent() { return ClassTemplate<T>(); }

// 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)&) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
// CHECK: func getFuncRef() -> @convention(c) () -> Int32
// CHECK: func getFuncRvalueRef() -> @convention(c) () -> Int32

// CHECK-NOT: refToDependent
// CHECK-NOT: dontImportAtomicRef