diff options
author | Ilya Biryukov <ibiryukov@google.com> | 2019-09-27 17:55:46 +0000 |
---|---|---|
committer | Ilya Biryukov <ibiryukov@google.com> | 2019-09-27 17:55:46 +0000 |
commit | 4ae2381430013b64a3c013c62bf038f3fa659f66 (patch) | |
tree | 5983d0425da6deb3ac07c391b77d4aa68b30fc9c /clang-tools-extra/clangd/FindTarget.cpp | |
parent | a524e630a793e18e7d5fabc2262781f310eb0279 (diff) | |
download | bcm5719-llvm-4ae2381430013b64a3c013c62bf038f3fa659f66.tar.gz bcm5719-llvm-4ae2381430013b64a3c013c62bf038f3fa659f66.zip |
[clangd] Fix template type aliases in findExplicitReference
Reviewers: kadircet
Reviewed By: kadircet
Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D68124
llvm-svn: 373104
Diffstat (limited to 'clang-tools-extra/clangd/FindTarget.cpp')
-rw-r--r-- | clang-tools-extra/clangd/FindTarget.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp index 6bbaa5e616b..08bdf977d16 100644 --- a/clang-tools-extra/clangd/FindTarget.cpp +++ b/clang-tools-extra/clangd/FindTarget.cpp @@ -477,13 +477,6 @@ Optional<ReferenceLoc> refInTypeLoc(TypeLoc L) { Ref->Qualifier = L.getQualifierLoc(); } - void VisitDeducedTemplateSpecializationTypeLoc( - DeducedTemplateSpecializationTypeLoc L) { - Ref = ReferenceLoc{ - NestedNameSpecifierLoc(), L.getNameLoc(), - explicitReferenceTargets(DynTypedNode::create(L.getType()))}; - } - void VisitTagTypeLoc(TagTypeLoc L) { Ref = ReferenceLoc{NestedNameSpecifierLoc(), L.getNameLoc(), {L.getDecl()}}; @@ -495,9 +488,25 @@ Optional<ReferenceLoc> refInTypeLoc(TypeLoc L) { } void VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc L) { + // We must ensure template type aliases are included in results if they + // were written in the source code, e.g. in + // template <class T> using valias = vector<T>; + // ^valias<int> x; + // 'explicitReferenceTargets' will return: + // 1. valias with mask 'Alias'. + // 2. 'vector<int>' with mask 'Underlying'. + // we want to return only #1 in this case. Ref = ReferenceLoc{ NestedNameSpecifierLoc(), L.getTemplateNameLoc(), - explicitReferenceTargets(DynTypedNode::create(L.getType()))}; + explicitReferenceTargets(DynTypedNode::create(L.getType()), + DeclRelation::Alias)}; + } + void VisitDeducedTemplateSpecializationTypeLoc( + DeducedTemplateSpecializationTypeLoc L) { + Ref = ReferenceLoc{ + NestedNameSpecifierLoc(), L.getNameLoc(), + explicitReferenceTargets(DynTypedNode::create(L.getType()), + DeclRelation::Alias)}; } void VisitDependentTemplateSpecializationTypeLoc( |