diff options
author | Alex Lorenz <arphaman@gmail.com> | 2017-05-15 14:26:22 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2017-05-15 14:26:22 +0000 |
commit | 048c8a9e7f48da1e9a6453a15baeec2f02713ba9 (patch) | |
tree | 3b96f9d66580056eed0cf2f8ace5da9504955af2 /clang/lib/Index/IndexingContext.cpp | |
parent | 96a13635f5caff0f30a9fa4d24266d4f14ebbff5 (diff) | |
download | bcm5719-llvm-048c8a9e7f48da1e9a6453a15baeec2f02713ba9.tar.gz bcm5719-llvm-048c8a9e7f48da1e9a6453a15baeec2f02713ba9.zip |
[index] References to fields from template instantiations should refer to
fields in base templates
rdar://32197158
llvm-svn: 303068
Diffstat (limited to 'clang/lib/Index/IndexingContext.cpp')
-rw-r--r-- | clang/lib/Index/IndexingContext.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Index/IndexingContext.cpp b/clang/lib/Index/IndexingContext.cpp index 709a23657b0..5cebb198460 100644 --- a/clang/lib/Index/IndexingContext.cpp +++ b/clang/lib/Index/IndexingContext.cpp @@ -124,6 +124,10 @@ bool IndexingContext::isTemplateImplicitInstantiation(const Decl *D) { TKind = FD->getTemplateSpecializationKind(); } else if (auto *VD = dyn_cast<VarDecl>(D)) { TKind = VD->getTemplateSpecializationKind(); + } else if (isa<FieldDecl>(D)) { + if (const auto *Parent = + dyn_cast<ClassTemplateSpecializationDecl>(D->getDeclContext())) + TKind = Parent->getSpecializationKind(); } switch (TKind) { case TSK_Undeclared: @@ -159,6 +163,17 @@ static const Decl *adjustTemplateImplicitInstantiation(const Decl *D) { return FD->getTemplateInstantiationPattern(); } else if (auto *VD = dyn_cast<VarDecl>(D)) { return VD->getTemplateInstantiationPattern(); + } else if (const auto *FD = dyn_cast<FieldDecl>(D)) { + if (const auto *Parent = + dyn_cast<ClassTemplateSpecializationDecl>(D->getDeclContext())) { + const CXXRecordDecl *Pattern = Parent->getTemplateInstantiationPattern(); + for (const NamedDecl *ND : Pattern->lookup(FD->getDeclName())) { + if (ND->isImplicit()) + continue; + if (isa<FieldDecl>(ND)) + return ND; + } + } } return nullptr; } |