================
@@ -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);
----------------
HighCommander4 wrote:
I don't think `CurContext` is the right `DeclContext` to check here, as it
could be a nested context inside the method. For example:
```c++
struct A {
int member;
void foo(this A &self) {
[&]() {
// Completion should not offer `member`, but with the current patch it
does.
mem^
}();
}
};
```
I think you want something like
`getFunctionLevelDeclContext(/*AllowLambda=*/false)`.
Also, as mentioned on Discord, we should do this check in
`CodeCompleteOrdinaryName()` and save the result on the `ResultBuilder`. This
is actually important not just for performance, but also to limit the effect of
the change to cases where we're in `CodeCompleteOrdinaryName()`, since
`ResultBuilder` is used for completions in other contexts as well.
https://github.com/llvm/llvm-project/pull/153760
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits