@@ -3444,11 +3444,12 @@ namespace {
3444
3444
// that differ this way so we can disambiguate later
3445
3445
for (auto m : decl->decls ()) {
3446
3446
if (auto method = dyn_cast<clang::CXXMethodDecl>(m)) {
3447
- if (method->getDeclName ().isIdentifier ()) {
3448
- if (Impl.cxxMethods .find (method->getName ()) == Impl.cxxMethods .end ()) {
3447
+ if (method->getDeclName ().isIdentifier ()) {
3448
+ if (Impl.cxxMethods .find (method->getName ()) ==
3449
+ Impl.cxxMethods .end ()) {
3449
3450
Impl.cxxMethods [method->getName ()] = {};
3450
3451
}
3451
- if (method->isConst ()) {
3452
+ if (method->isConst ()) {
3452
3453
// Add to const set
3453
3454
Impl.cxxMethods [method->getName ()].first .insert (method);
3454
3455
} else {
@@ -3478,8 +3479,8 @@ namespace {
3478
3479
3479
3480
if (auto field = dyn_cast<clang::FieldDecl>(nd)) {
3480
3481
// Non-nullable pointers can't be zero-initialized.
3481
- if (auto nullability = field-> getType ()
3482
- ->getNullability (Impl.getClangASTContext ())) {
3482
+ if (auto nullability =
3483
+ field-> getType () ->getNullability (Impl.getClangASTContext ())) {
3483
3484
if (*nullability == clang::NullabilityKind::NonNull)
3484
3485
hasZeroInitializableStorage = false ;
3485
3486
}
@@ -3522,6 +3523,18 @@ namespace {
3522
3523
}
3523
3524
3524
3525
if (auto MD = dyn_cast<FuncDecl>(member)) {
3526
+
3527
+ // When 2 CXXMethods diff by "constness" alone we differentiate them
3528
+ // by changing the name of one. That changed method needs to be added
3529
+ // to the lookup table since it cannot be found lazily.
3530
+ if (auto cxxMethod = dyn_cast<clang::CXXMethodDecl>(m)) {
3531
+ if (cxxMethod->getDeclName ().isIdentifier ()) {
3532
+ auto &mutableFuncPtrs = Impl.cxxMethods [cxxMethod->getName ()].second ;
3533
+ if (mutableFuncPtrs.contains (cxxMethod)) {
3534
+ result->addMemberToLookupTable (member);
3535
+ }
3536
+ }
3537
+ }
3525
3538
methods.push_back (MD);
3526
3539
continue ;
3527
3540
}
@@ -3602,10 +3615,10 @@ namespace {
3602
3615
//
3603
3616
// If we can completely represent the struct in SIL, leave the body
3604
3617
// implicit, otherwise synthesize one to call property setters.
3605
- auto valueCtor = createValueConstructor (
3606
- Impl, result, members,
3607
- /* want param names*/ true ,
3608
- /* want body*/ hasUnreferenceableStorage);
3618
+ auto valueCtor =
3619
+ createValueConstructor ( Impl, result, members,
3620
+ /* want param names*/ true ,
3621
+ /* want body*/ hasUnreferenceableStorage);
3609
3622
if (!hasUnreferenceableStorage)
3610
3623
valueCtor->setIsMemberwiseInitializer ();
3611
3624
@@ -3636,8 +3649,8 @@ namespace {
3636
3649
continue ;
3637
3650
3638
3651
auto getterAndSetter = subscriptInfo.second ;
3639
- auto subscript = makeSubscript (getterAndSetter. first ,
3640
- getterAndSetter.second );
3652
+ auto subscript =
3653
+ makeSubscript (getterAndSetter. first , getterAndSetter.second );
3641
3654
// Also add subscripts directly because they won't be found from the
3642
3655
// clang decl.
3643
3656
result->addMember (subscript);
0 commit comments