Skip to content

Commit 1f71144

Browse files
authored
[cxx-interop] Don't crash for unkown inline-operator. (swiftlang#34602)
Skip unkown or unimportable inline operators (such as deleted operator members) instead of crashing.
1 parent cb7bb52 commit 1f71144

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3650,7 +3650,7 @@ void ClangImporter::Implementation::lookupValue(
36503650
if (name.isOperator()) {
36513651
for (auto entry : table.lookupMemberOperators(name.getBaseName())) {
36523652
if (isVisibleClangEntry(entry)) {
3653-
if (auto decl = dyn_cast<ValueDecl>(
3653+
if (auto decl = dyn_cast_or_null<ValueDecl>(
36543654
importDeclReal(entry->getMostRecentDecl(), CurrentVersion)))
36553655
consumer.foundDecl(decl, DeclVisibilityKind::VisibleAtTopLevel);
36563656
}

test/Interop/Cxx/operators/Inputs/member-inline.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ struct LoadableIntWrapper {
88
}
99
};
1010

11+
struct HasDeletedOperator {
12+
void operator!=(HasDeletedOperator) const = delete;
13+
};
14+
1115
#endif

test/Interop/Cxx/operators/member-inline-module-interface.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33
// CHECK: struct LoadableIntWrapper {
44
// CHECK: static func - (lhs: inout LoadableIntWrapper, rhs: LoadableIntWrapper) -> LoadableIntWrapper
55
// CHECK: }
6+
7+
// CHECK: struct HasDeletedOperator {
8+
// CHECK: }

0 commit comments

Comments
 (0)