[clang] [clang-tools-extra] [clangd] Autocomplete fixes for methods (PR #165916)
Hippolyte Melica via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 21 16:22:34 PST 2026
etyloppihacilem wrote:
I decided to use `Parser::ParseDeclaratorInternal` as a criteria to detect declaration context, it works great and was way easier than my previous approach.
I had to fix another issue where static and non-static member functions were mixed in the completion results. I now detect if a call occurs within a scope resolution context (::) to treat non-static functions like pointers, i.e., no completion (matches the behavior before my patch). This distinction is clearly visible here:
```cpp
struct Foo {
template <typename T, typename U, typename V = int>
T generic(U nameU, V nameV);
};
int i = Foo::^
// would complete
int i = Foo::generic<typename T, typename U>(U nameU, V nameV) // with placeholders
// which is incorrect because in a call context, we do not want 'typename U'
// and the call context is incorrect anyway
// it now complete, as it did before
int i = Foo::generic
// while
int main() {
Foo f;
f.^
// completes
f.generic<typename T>(U nameU, V nameV) // with placeholders as well.
}
```
https://github.com/llvm/llvm-project/pull/165916
More information about the cfe-commits
mailing list