summaryrefslogtreecommitdiffstats
path: root/clang/lib/Index/IndexingContext.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2017-05-23 16:25:06 +0000
committerAlex Lorenz <arphaman@gmail.com>2017-05-23 16:25:06 +0000
commit73e27a603101e77cfceb34540ff51fac292f250e (patch)
tree6ae25ff7a20822ae16ee93bc251f4052d886df2a /clang/lib/Index/IndexingContext.cpp
parent2109d436abdb0408b2bd8b76602eb7a478e9dbbd (diff)
downloadbcm5719-llvm-73e27a603101e77cfceb34540ff51fac292f250e.tar.gz
bcm5719-llvm-73e27a603101e77cfceb34540ff51fac292f250e.zip
[index] The references to fields from nested records in template instantiations
should refer to the pattern fields in the nested records in the base templates rdar://32352429 llvm-svn: 303647
Diffstat (limited to 'clang/lib/Index/IndexingContext.cpp')
-rw-r--r--clang/lib/Index/IndexingContext.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/clang/lib/Index/IndexingContext.cpp b/clang/lib/Index/IndexingContext.cpp
index b9f991d6ba6..1a341b04c43 100644
--- a/clang/lib/Index/IndexingContext.cpp
+++ b/clang/lib/Index/IndexingContext.cpp
@@ -128,9 +128,8 @@ bool IndexingContext::isTemplateImplicitInstantiation(const Decl *D) {
if (RD->getInstantiatedFromMemberClass())
TKind = RD->getTemplateSpecializationKind();
} else if (isa<FieldDecl>(D)) {
- if (const auto *Parent =
- dyn_cast<ClassTemplateSpecializationDecl>(D->getDeclContext()))
- TKind = Parent->getSpecializationKind();
+ if (const auto *Parent = dyn_cast<Decl>(D->getDeclContext()))
+ return isTemplateImplicitInstantiation(Parent);
}
switch (TKind) {
case TSK_Undeclared:
@@ -158,6 +157,16 @@ bool IndexingContext::shouldIgnoreIfImplicit(const Decl *D) {
return true;
}
+static const CXXRecordDecl *
+getDeclContextForTemplateInstationPattern(const Decl *D) {
+ if (const auto *CTSD =
+ dyn_cast<ClassTemplateSpecializationDecl>(D->getDeclContext()))
+ return CTSD->getTemplateInstantiationPattern();
+ else if (const auto *RD = dyn_cast<CXXRecordDecl>(D->getDeclContext()))
+ return RD->getInstantiatedFromMemberClass();
+ return nullptr;
+}
+
static const Decl *adjustTemplateImplicitInstantiation(const Decl *D) {
if (const ClassTemplateSpecializationDecl *
SD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
@@ -169,9 +178,8 @@ static const Decl *adjustTemplateImplicitInstantiation(const Decl *D) {
} else if (const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
return RD->getInstantiatedFromMemberClass();
} else if (const auto *FD = dyn_cast<FieldDecl>(D)) {
- if (const auto *Parent =
- dyn_cast<ClassTemplateSpecializationDecl>(D->getDeclContext())) {
- const CXXRecordDecl *Pattern = Parent->getTemplateInstantiationPattern();
+ if (const CXXRecordDecl *Pattern =
+ getDeclContextForTemplateInstationPattern(FD)) {
for (const NamedDecl *ND : Pattern->lookup(FD->getDeclName())) {
if (ND->isImplicit())
continue;
OpenPOWER on IntegriCloud