-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dependent member function name is resolved incorrectly #64841
Comments
@llvm/issue-subscribers-clangd |
To be clear,
|
Given that it's a dependent context, ideally I'd like clangd to list candidate implementations for me to pick from, ranking them by popularity, or at the very least give up and not mislead the user. |
Minimized testcase: struct PointerIntPairInfo {
static void *getPointer(void *Value);
};
template <typename Info = PointerIntPairInfo>
struct PointerIntPair {
void *Value;
void *getPointer() const { return Info::getPointer(Value); }
}; |
So my first thought was that this is one of our textual heuristics ( |
I think what's happening here is that |
I tried just returning early if we have a qualifier and couldn't find anything in the qualifier's scope, expecting that some testcases will break, but nothing did. So that's seems like a good enough fix for now. |
Proposed fix: https://reviews.llvm.org/D158873 |
After the fix, the behaviour is that AST-based resolution produces no results and we fall back on our textual heuristics. On the minimized testcase, the textual heuristics offer both This could be improved further (e.g. for calls, we could do arity-based filtering on function results founds by the textual heuristics), but I'm going to leave that to future issues and consider the original bug here fixed. |
(I don't have a local opt build handy to try the updated behaviour on the original testcase in the LLVM source, but the result is presumably similar, except that perhaps some additional functions named |
Thank you for addressing it so quickly!
That sounds good enough for me as well. Definitely an improvement over (what was) status quo. |
For completeness, I did check the behaviour on the original testcase. What actually happens is that the textual heuristic finds more than 5 candidate functions named |
Consider the following one-liner:
llvm-project/llvm/include/llvm/ADT/PointerIntPair.h
Line 94 in fa2b038
Info::getPointer
is incorrectly resolved to be the function defined in this very line.It's observable by jumping to definition (jumps to the same line), and by asking for information about
Info::getPointer
symbol:Function is actually defined 100 lines below, in
PointerIntPairInfo
:llvm-project/llvm/include/llvm/ADT/PointerIntPair.h
Lines 190 to 193 in fa2b038
I'm using VS Code with clangd extension, if that matters.
The text was updated successfully, but these errors were encountered: