[PATCH] D68124: [clangd] Fix template type aliases in findExplicitReference
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 27 02:47:57 PDT 2019
ilya-biryukov marked an inline comment as done.
ilya-biryukov added inline comments.
================
Comment at: clang-tools-extra/clangd/FindTarget.cpp:478
+ explicitReferenceTargets(DynTypedNode::create(L.getType()),
+ DeclRelation::Alias)};
}
----------------
kadircet wrote:
> can you explain why these two are special and get to keep `Alias` decls? Whereas the others dont?
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`.
2. `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.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68124/new/
https://reviews.llvm.org/D68124
More information about the cfe-commits
mailing list