Properly checks enclosing DeclContext, and add the related test case.
Fix #56221
Differential D128715
[clang-tidy] Fix confusable identifiers interaction with DeclContext serge-sans-paille on Jun 28 2022, 1:37 AM. Authored by
Details Properly checks enclosing DeclContext, and add the related test case. Fix #56221
Diff Detail
Event TimelineComment Actions LGTM, but I have some additional testing requests which might spawn follow-up patches.
Comment Actions @aaron.ballman : I agree with most of your suggestion except the one below that I annotated accordingly struct Base { virtual void O0(); private: void II(); }; struct Derived : Base { void OO(); // We should warn about this void I1(); // I think we should warn about this too, because implementation of, say, `O0` could refer to `I1` wich would be confusable with `Il` }; void I1(); // we should probably warn here too, becaus ein the implementation of, says, `O0`, if we refer to `Il`, it's confusable with this `I1` too Comment Actions I don't think we should diagnose Derived::I1() because Base::II() is private, so I1 can never be validly confused with II (either from within the class context or externally). The free function case is actually interesting but not because of confusable identifiers. If you call I1() within the context of Derived, are you trying to call the member function (you will) or the free function (you won't)? But I don't think it should be warned as a confusable identifier in terms of Unicode confusables because calling the member function outside of the class context requires an object while calling the free function does not, while calling it within the class is already confused because of name hiding. Does that change your opinion at all? Comment Actions Update test case to take into accounts reviewers suggestions. As a consequence use a more complex approach to detect whether two NamedDecl may interfere. |