File tree 5 files changed +50
-9
lines changed
5 files changed +50
-9
lines changed Original file line number Diff line number Diff line change @@ -4021,6 +4021,30 @@ SwiftLookupTable *ClangImporter::Implementation::findLookupTable(
4021
4021
return known->second .get ();
4022
4022
}
4023
4023
4024
+ SwiftLookupTable *
4025
+ ClangImporter::Implementation::findLookupTable (const clang::Decl *decl) {
4026
+ // Contents of a C++ namespace are added to the __ObjC module.
4027
+ bool isWithinNamespace = false ;
4028
+ auto declContext = decl->getDeclContext ();
4029
+ while (!declContext->isTranslationUnit ()) {
4030
+ if (declContext->isNamespace ()) {
4031
+ isWithinNamespace = true ;
4032
+ break ;
4033
+ }
4034
+ declContext = declContext->getParent ();
4035
+ }
4036
+
4037
+ clang::Module *owningModule = nullptr ;
4038
+ if (!isWithinNamespace) {
4039
+ // Members of class template specializations don't have an owning module.
4040
+ if (auto spec = dyn_cast<clang::ClassTemplateSpecializationDecl>(decl))
4041
+ owningModule = spec->getSpecializedTemplate ()->getOwningModule ();
4042
+ else
4043
+ owningModule = decl->getOwningModule ();
4044
+ }
4045
+ return findLookupTable (owningModule);
4046
+ }
4047
+
4024
4048
bool ClangImporter::Implementation::forEachLookupTable (
4025
4049
llvm::function_ref<bool (SwiftLookupTable &table)> fn) {
4026
4050
// Visit the bridging header's lookup table.
Original file line number Diff line number Diff line change @@ -2118,15 +2118,7 @@ namespace {
2118
2118
if (friendDecl->getFriendDecl ()) {
2119
2119
m = friendDecl->getFriendDecl ();
2120
2120
2121
- // Find the owning module of the class template. Members of class
2122
- // template specializations don't have an owning module.
2123
- clang::Module *owningModule = nullptr ;
2124
- if (auto spec = dyn_cast<clang::ClassTemplateSpecializationDecl>(decl))
2125
- owningModule = spec->getSpecializedTemplate ()->getOwningModule ();
2126
- else
2127
- owningModule = decl->getOwningModule ();
2128
-
2129
- auto lookupTable = Impl.findLookupTable (owningModule);
2121
+ auto lookupTable = Impl.findLookupTable (decl);
2130
2122
addEntryToLookupTable (*lookupTable, friendDecl->getFriendDecl (),
2131
2123
Impl.getNameImporter ());
2132
2124
}
@@ -2243,6 +2235,9 @@ namespace {
2243
2235
2244
2236
// Make sure the synthesized decl can be found by lookupDirect.
2245
2237
result->addMemberToLookupTable (opFuncDecl);
2238
+
2239
+ addEntryToLookupTable (*Impl.findLookupTable (decl), cxxMethod,
2240
+ Impl.getNameImporter ());
2246
2241
}
2247
2242
}
2248
2243
methods.push_back (MD);
Original file line number Diff line number Diff line change @@ -1644,6 +1644,9 @@ class LLVM_LIBRARY_VISIBILITY ClangImporter::Implementation
1644
1644
// / about the directly-parsed headers.
1645
1645
SwiftLookupTable *findLookupTable (const clang::Module *clangModule);
1646
1646
1647
+ // / Find the lookup table that should contain the given Clang declaration.
1648
+ SwiftLookupTable *findLookupTable (const clang::Decl *decl);
1649
+
1647
1650
// / Visit each of the lookup tables in some deterministic order.
1648
1651
// /
1649
1652
// / \param fn Invoke the given visitor for each table. If the
Original file line number Diff line number Diff line change @@ -55,4 +55,16 @@ struct HasOperatorEqualEqual {
55
55
}
56
56
};
57
57
58
+ template <typename T>
59
+ struct HasOperatorPlusEqual {
60
+ T value;
61
+
62
+ HasOperatorPlusEqual &operator +=(int x) {
63
+ value += x;
64
+ return *this ;
65
+ }
66
+ };
67
+
68
+ using HasOperatorPlusEqualInt = HasOperatorPlusEqual<int >;
69
+
58
70
#endif // TEST_INTEROP_CXX_CLASS_INPUTS_PROTOCOL_CONFORMANCE_H
Original file line number Diff line number Diff line change @@ -35,3 +35,10 @@ protocol Invertable {
35
35
extension HasOperatorExclaim : Invertable { }
36
36
37
37
extension HasOperatorEqualEqual : Equatable { }
38
+
39
+
40
+ protocol HasOperatorPlusEqualProtocol {
41
+ static func += ( lhs: inout Self , x: Int32 )
42
+ }
43
+
44
+ extension HasOperatorPlusEqualInt : HasOperatorPlusEqualProtocol { }
You can’t perform that action at this time.
0 commit comments