Skip to content

Commit b5229ea

Browse files
committed
[cxx-interop] Refactor: add member operator instantiations to the lookup table elsewhere
NFC intended Cherrypick commit 0b69eb5 Cherrypick PR #69991
1 parent 6e4f3ba commit b5229ea

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,9 +2337,6 @@ namespace {
23372337

23382338
// Make sure the synthesized decl can be found by lookupDirect.
23392339
result->addMemberToLookupTable(opFuncDecl);
2340-
2341-
addEntryToLookupTable(*Impl.findLookupTable(decl), cxxMethod,
2342-
Impl.getNameImporter());
23432340
}
23442341
}
23452342
methods.push_back(MD);
@@ -3002,6 +2999,21 @@ namespace {
30022999
if (isSpecializationDepthGreaterThan(def, 8))
30033000
return nullptr;
30043001

3002+
// For class template instantiations, we need to add their member
3003+
// operators to the lookup table to make them discoverable with
3004+
// unqualified lookup. This makes it possible to implement a Swift
3005+
// protocol requirement with an instantiation of a C++ member operator.
3006+
// This cannot be done when building the lookup table,
3007+
// because templates are instantiated lazily.
3008+
for (auto member : def->decls()) {
3009+
if (auto method = dyn_cast<clang::CXXMethodDecl>(member)) {
3010+
if (method->isOverloadedOperator()) {
3011+
addEntryToLookupTable(*Impl.findLookupTable(decl), method,
3012+
Impl.getNameImporter());
3013+
}
3014+
}
3015+
}
3016+
30053017
return VisitCXXRecordDecl(def);
30063018
}
30073019

0 commit comments

Comments
 (0)