summaryrefslogtreecommitdiffstats
path: root/clang/lib/Index
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2019-05-23 16:48:47 +0000
committerIlya Biryukov <ibiryukov@google.com>2019-05-23 16:48:47 +0000
commit346758407e1dabb0d68af6bae7fba131b74e4e54 (patch)
tree626f6efc99cb0e4da08bb5ccee2298878ce05127 /clang/lib/Index
parentfd11a5f47d00dd6176938a3767fd902742617a1e (diff)
downloadbcm5719-llvm-346758407e1dabb0d68af6bae7fba131b74e4e54.tar.gz
bcm5719-llvm-346758407e1dabb0d68af6bae7fba131b74e4e54.zip
[Index] Fix reported references in presence of template type aliases
Summary: See the added test for an example. Reviewers: kadircet Reviewed By: kadircet Subscribers: jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62303 llvm-svn: 361511
Diffstat (limited to 'clang/lib/Index')
-rw-r--r--clang/lib/Index/IndexTypeSourceInfo.cpp44
1 files changed, 28 insertions, 16 deletions
diff --git a/clang/lib/Index/IndexTypeSourceInfo.cpp b/clang/lib/Index/IndexTypeSourceInfo.cpp
index 9f9740b6079..959d5f1197f 100644
--- a/clang/lib/Index/IndexTypeSourceInfo.cpp
+++ b/clang/lib/Index/IndexTypeSourceInfo.cpp
@@ -133,29 +133,41 @@ public:
return true;
}
- template<typename TypeLocType>
- bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) {
- if (const auto *T = TL.getTypePtr()) {
- if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) {
- if (!RD->isImplicit() || IndexCtx.shouldIndexImplicitInstantiation()) {
- IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), Parent,
- ParentDC, SymbolRoleSet(), Relations);
- return true;
- }
- }
- if (const TemplateDecl *D = T->getTemplateName().getAsTemplateDecl())
- IndexCtx.handleReference(D, TL.getTemplateNameLoc(), Parent, ParentDC,
- SymbolRoleSet(), Relations);
+ void HandleTemplateSpecializationTypeLoc(TemplateName TemplName,
+ SourceLocation TemplNameLoc,
+ CXXRecordDecl *ResolvedClass,
+ bool IsTypeAlias) {
+ // In presence of type aliases, the resolved class was never written in
+ // the code so don't report it.
+ if (!IsTypeAlias && ResolvedClass &&
+ (!ResolvedClass->isImplicit() ||
+ IndexCtx.shouldIndexImplicitInstantiation())) {
+ IndexCtx.handleReference(ResolvedClass, TemplNameLoc, Parent, ParentDC,
+ SymbolRoleSet(), Relations);
+ } else if (const TemplateDecl *D = TemplName.getAsTemplateDecl()) {
+ IndexCtx.handleReference(D, TemplNameLoc, Parent, ParentDC,
+ SymbolRoleSet(), Relations);
}
- return true;
}
bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
- return HandleTemplateSpecializationTypeLoc(TL);
+ auto *T = TL.getTypePtr();
+ if (!T)
+ return true;
+ HandleTemplateSpecializationTypeLoc(
+ T->getTemplateName(), TL.getTemplateNameLoc(), T->getAsCXXRecordDecl(),
+ T->isTypeAlias());
+ return true;
}
bool VisitDeducedTemplateSpecializationTypeLoc(DeducedTemplateSpecializationTypeLoc TL) {
- return HandleTemplateSpecializationTypeLoc(TL);
+ auto *T = TL.getTypePtr();
+ if (!T)
+ return true;
+ HandleTemplateSpecializationTypeLoc(
+ T->getTemplateName(), TL.getTemplateNameLoc(), T->getAsCXXRecordDecl(),
+ /*IsTypeAlias=*/false);
+ return true;
}
bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
OpenPOWER on IntegriCloud