This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fix template type aliases in findExplicitReference
ClosedPublic

Authored by ilya-biryukov on Sep 27 2019, 2:10 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

ilya-biryukov created this revision.Sep 27 2019, 2:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 27 2019, 2:11 AM
kadircet added inline comments.Sep 27 2019, 2:30 AM
clang-tools-extra/clangd/FindTarget.cpp
478 ↗(On Diff #222104)

can you explain why these two are special and get to keep Alias decls? Whereas the others dont?

ilya-biryukov marked an inline comment as done.Sep 27 2019, 2:45 AM
ilya-biryukov added inline comments.
clang-tools-extra/clangd/FindTarget.cpp
478 ↗(On Diff #222104)

There are two cases to consider for a reference of the form Templ<int> in type positions:

  1. Templ is a template type alias
template <class X>
Templ = vector<X>;

in this case targetDecl returns Templ with mask Alias | TemplatePattern and vector<int> with mask Underlying
since we are interested in the thing explicitly written in the source code, we want Templ and not vector.

  1. Templ is a name of some template type (a class or template template parameter)

in this case targetDecl returns Templ with mask TemplatePattern and that's what we want to return, since this is what was written in the source code.

So in both cases the important thing is to not filter-out the result with mask Alias. This is exactly what this patch does.

kadircet accepted this revision.Sep 27 2019, 9:27 AM

LGTM.

clang-tools-extra/clangd/FindTarget.cpp
478 ↗(On Diff #222104)

thanks! I was rather asking for comments in the code though :D

Please also mention them in comments.

This revision is now accepted and ready to land.Sep 27 2019, 9:27 AM
ilya-biryukov marked 2 inline comments as done.Sep 27 2019, 10:51 AM
  • Add a comment
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 27 2019, 10:53 AM