Skip to content
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

go-to-definition doesn not work when "class template argument dedection" is used #242

Closed
lh123 opened this issue Jan 1, 2020 · 4 comments
Assignees

Comments

@lh123
Copy link

lh123 commented Jan 1, 2020

template<typename T>
struct Test {
    Test(T t);
};

int main() {
    Test a(5);
//  ^^^^ go-to-def not works
}
@HighCommander4
Copy link

The type specifier here has a BuiltinTypeLoc with an empty source range, so it doesn't get selected, only the enclosing VarDecl does, which targets itself.

@HighCommander4
Copy link

HighCommander4 commented Jan 2, 2020

The type specifier here has a BuiltinTypeLoc with an empty source range

Sorry, this was happening because my testcase wasn't being parsed in C++17 mode. The "BuiltinTypeLoc with an empty source range" was the error type.

In C++17 mode, we get a DeducedTemplateSpecializationTypeLoc, and it does get selected, so hopefully this will be a simple fix to TargetFinder.

@HighCommander4
Copy link

I tried to fix this in TargetFinder, but ran into PR42914, which appears to affect DeducedTemplateSpecializationTypeLoc as well.

We could, however, work around this if we're fine with always navigating to the primary template (as opposed to using the deduced template specialization, which could potentially come from a partial or explicit specialization) for now.

@HighCommander4
Copy link

It looks like PR42914 is not an easy fix, so I suggest we go ahead with the workaround.

Proposed patch.

@HighCommander4 HighCommander4 self-assigned this Jan 3, 2020
HighCommander4 added a commit to HighCommander4/llvm-project that referenced this issue Jan 7, 2020
Summary:
This is mostly a workaround for
https://bugs.llvm.org/show_bug.cgi?id=42914. Once that is fixed, the
handling in VisitDeducedTyped() should be sufficient.

Fixes clangd/clangd#242

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72119
arichardson pushed a commit to arichardson/llvm-project that referenced this issue Jan 20, 2020
Summary:
This is a workaround for https://bugs.llvm.org/show_bug.cgi?id=42914.
Once that is fixed, the handling in VisitDeducedTyped() should be sufficient.

Fixes clangd/clangd#242

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72119
shrouxm pushed a commit to sourcegraph/lsif-clang that referenced this issue Jul 12, 2020
Summary:
This is a workaround for https://bugs.llvm.org/show_bug.cgi?id=42914.
Once that is fixed, the handling in VisitDeducedTyped() should be sufficient.

Fixes clangd/clangd#242

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72119
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants