This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Include the underlying decls in go-to-definition.
ClosedPublic

Authored by hokein on Feb 5 2020, 8:11 AM.

Diff Detail

Event Timeline

hokein created this revision.Feb 5 2020, 8:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 5 2020, 8:11 AM

Unit tests: unknown.

clang-tidy: unknown.

clang-format: unknown.

Build artifacts: CMakeCache.txt, console-log.txt

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

hokein planned changes to this revision.Feb 6 2020, 12:56 AM
hokein marked an inline comment as done.
hokein added inline comments.
clang-tools-extra/clangd/unittests/XRefsTests.cpp
959–1023

we need to avoid the underlying decl in this case.

hokein updated this revision to Diff 242855.Feb 6 2020, 3:36 AM

no regression on non-definition of renaming alias.

hokein updated this revision to Diff 242856.Feb 6 2020, 3:37 AM

remove an accident change.

hokein added a comment.Mar 9 2020, 8:33 AM

friendly ping, this patch should be ready for review.

nridge added a subscriber: nridge.Mar 17 2020, 2:07 PM
nridge added inline comments.
clang-tools-extra/clangd/unittests/XRefsTests.cpp
980

Why is it useful to give the using-declaration itself as a result?

It seems like the more useful behaviour from the user's point of view is to jump directly to the definition of class Foo, without having to choose from a popup first.

Sorry about being late coming back to this.

clang-tools-extra/clangd/XRefs.cpp
295

I believe this is going to do the wrong thing on overload sets.

namespace ns { int x(char); int x(double); }
using ns::x;
int y = ^x('a');

getDeclAtPosition(..., TemplatePattern|Alias) will yield UsingDecl, and then targetDecl(UsingDecl, Underlying) will yield both overloads of x.
However getDeclAtPosition(..., Underlying) would correctly return only the desired overload.
(Please add a test like this!)

This is awkward to work around, it's a failure of the targetDecl API. Maybe for now, call getDeclAtPosition with TemplatePattern|Alias, and if there's exactly one result, replace D with it? And leave a fixme to address more complicated cases somehow.

clang-tools-extra/clangd/unittests/XRefsTests.cpp
980

+1, that would mean adding a continue after the addresultdecl

hokein updated this revision to Diff 270715.Jun 15 2020, 4:16 AM
hokein marked 2 inline comments as done.

address review comment: fix the wrong result for multiple overloads.

sammccall accepted this revision.Aug 7 2020, 1:40 AM

Thanks!

clang-tools-extra/clangd/unittests/XRefsTests.cpp
1005

this is basically the same as the above case (which is fine)
but what about class [[Foo]]; using Bar = ^Foo;?

(maybe this is tested elsewhere already, but it should be moved here)

This revision is now accepted and ready to land.Aug 7 2020, 1:40 AM
hokein updated this revision to Diff 283851.Aug 7 2020, 2:38 AM
hokein marked 2 inline comments as done.

address comment.

This revision was landed with ongoing or failed builds.Aug 7 2020, 2:40 AM
This revision was automatically updated to reflect the committed changes.