[clang] [clang-tools-extra] [clangd] Autocomplete fixes for methods (PR #165916)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 7 23:07:21 PST 2026
================
@@ -1503,8 +1506,27 @@ void ResultBuilder::AddResult(Result R, DeclContext *CurContext,
}
OverloadSet.Add(Method, Results.size());
}
-
- R.FunctionCanBeCall = canFunctionBeCalled(R.getDeclaration(), BaseExprType);
+ R.DeclaringEntity = IsInDeclarationContext;
+ R.IsAddressOfOperand = IsAddressOfOperand;
+ R.FunctionCanBeCall = canFunctionBeCalled(R.getDeclaration(), BaseExprType) ||
----------------
HighCommander4 wrote:
In HighCommander4 at 27df471, I'm suggesting two changes to the computation of `FunctionCanBeCall`.
The first is to add `|| !IsAddressOfOperand`, as a way of avoiding needing to store the `IsAddressOfOperand` flag separately.
I do think that change deserves a comment such as this:
```
// If the user wrote `&` before the function name, assume the
// user is more likely to take the address of the function rather
// than call it and take the address of the result.
```
The second is to remove the `|| IsInDeclarationContext` part which does not make sense conceptually (if the user is writing a declaration, it's definitely not a call). I think the reason for this was so that clangd's getSignature doesn't chop off the parameters in declaration contexts, which I've addressed in my patch in a different way (passing `IncludeFunctionArguments = FunctionCanBeCall || DeclaringEntity` to `getSignature`).
https://github.com/llvm/llvm-project/pull/165916
More information about the cfe-commits
mailing list