[clang] [clang-tools-extra] [clang] Skip suggesting unqualified members in explicit-object member functions (PR #153760)
Mythreya Kuricheti via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 16 17:47:55 PDT 2025
================
@@ -1428,6 +1428,16 @@ void ResultBuilder::AddResult(Result R, DeclContext *CurContext,
AdjustResultPriorityForDecl(R);
+ if (isa<FieldDecl>(R.Declaration)) {
+ // If result is a member in the context of an explicit-object member
+ // function, drop it because it must be accessed through the object
+ // parameter
+ if (auto *MethodDecl = dyn_cast<CXXMethodDecl>(CurContext);
----------------
MythreyaK wrote:
How do we ensure that explicit object methods still participate in overload resolution, since the `HasObjectTypeQualifiers` is `false` [here](https://searchfox.org/llvm/rev/a293573c4e3e43f9f6279f075c3262ea5dc17086/clang/lib/Sema/SemaCodeComplete.cpp#1431)?
Example, his does not suggest `memberFnB`
```cpp
struct A {
int member {};
int memberFnA(int a);
int memberFnB(this A const& self, float b);
void foo(this const A& self) {
self.mem^ // suggests only 'member'
self.memberFnA(1); // correctly diagnosed by clangd
}
};
```
Should `HasObjectTypeQualifiers` be true for these?
https://github.com/llvm/llvm-project/pull/153760
More information about the cfe-commits
mailing list