forked from OSchip/llvm-project
[index] The references to enum constants from member enums that are
from template instantiations should refer to the enum constant in the pattern enum in the base template rdar://32325459 llvm-svn: 303651
This commit is contained in:
parent
9d60520608
commit
4bbce51539
|
@ -130,7 +130,8 @@ bool IndexingContext::isTemplateImplicitInstantiation(const Decl *D) {
|
|||
} else if (const auto *ED = dyn_cast<EnumDecl>(D)) {
|
||||
if (ED->getInstantiatedFromMemberEnum())
|
||||
TKind = ED->getTemplateSpecializationKind();
|
||||
} else if (isa<FieldDecl>(D) || isa<TypedefNameDecl>(D)) {
|
||||
} else if (isa<FieldDecl>(D) || isa<TypedefNameDecl>(D) ||
|
||||
isa<EnumConstantDecl>(D)) {
|
||||
if (const auto *Parent = dyn_cast<Decl>(D->getDeclContext()))
|
||||
return isTemplateImplicitInstantiation(Parent);
|
||||
}
|
||||
|
@ -193,6 +194,13 @@ static const Decl *adjustTemplateImplicitInstantiation(const Decl *D) {
|
|||
return BaseND;
|
||||
}
|
||||
}
|
||||
} else if (const auto *ECD = dyn_cast<EnumConstantDecl>(D)) {
|
||||
if (const auto *ED = dyn_cast<EnumDecl>(ECD->getDeclContext())) {
|
||||
if (const EnumDecl *Pattern = ED->getInstantiatedFromMemberEnum()) {
|
||||
for (const NamedDecl *BaseECD : Pattern->lookup(ECD->getDeclName()))
|
||||
return BaseECD;
|
||||
}
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
enum Enum {
|
||||
// CHECK: [[@LINE-1]]:10 | enum/C | Enum | c:@ST>2#T#T@TemplateClass@S@NestedType@E@Enum |
|
||||
EnumCase
|
||||
// CHECK: [[@LINE-1]]:7 | enumerator/C | EnumCase | c:@ST>2#T#T@TemplateClass@S@NestedType@E@Enum@EnumCase |
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -82,4 +83,6 @@ void canonicalizeInstaniationReferences(TemplateClass<int, float> &object) {
|
|||
|
||||
TT::NestedType::Enum nestedEnum;
|
||||
// CHECK: [[@LINE-1]]:19 | enum/C | Enum | c:@ST>2#T#T@TemplateClass@S@NestedType@E@Enum |
|
||||
(void)TT::NestedType::Enum::EnumCase;
|
||||
// CHECK: [[@LINE-1]]:31 | enumerator/C | EnumCase | c:@ST>2#T#T@TemplateClass@S@NestedType@E@Enum@EnumCase |
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue