r303651 - [index] The references to enum constants from member enums that are
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Tue May 23 09:47:02 PDT 2017
Author: arphaman
Date: Tue May 23 11:47:01 2017
New Revision: 303651
URL: http://llvm.org/viewvc/llvm-project?rev=303651&view=rev
Log:
[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
Modified:
cfe/trunk/lib/Index/IndexingContext.cpp
cfe/trunk/test/Index/Core/index-instantiated-source.cpp
Modified: cfe/trunk/lib/Index/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=303651&r1=303650&r2=303651&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexingContext.cpp (original)
+++ cfe/trunk/lib/Index/IndexingContext.cpp Tue May 23 11:47:01 2017
@@ -130,7 +130,8 @@ bool IndexingContext::isTemplateImplicit
} 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 *adjustTemplateImplici
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;
}
Modified: cfe/trunk/test/Index/Core/index-instantiated-source.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-instantiated-source.cpp?rev=303651&r1=303650&r2=303651&view=diff
==============================================================================
--- cfe/trunk/test/Index/Core/index-instantiated-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-instantiated-source.cpp Tue May 23 11:47:01 2017
@@ -46,6 +46,7 @@ public:
enum Enum {
// CHECK: [[@LINE-1]]:10 | enum/C | Enum | c:@ST>2#T#T at TemplateClass@S at NestedType@E at Enum |
EnumCase
+// CHECK: [[@LINE-1]]:7 | enumerator/C | EnumCase | c:@ST>2#T#T at TemplateClass@S at NestedType@E at Enum@EnumCase |
};
};
};
@@ -82,4 +83,6 @@ void canonicalizeInstaniationReferences(
TT::NestedType::Enum nestedEnum;
// CHECK: [[@LINE-1]]:19 | enum/C | Enum | c:@ST>2#T#T at TemplateClass@S at NestedType@E at Enum |
+ (void)TT::NestedType::Enum::EnumCase;
+// CHECK: [[@LINE-1]]:31 | enumerator/C | EnumCase | c:@ST>2#T#T at TemplateClass@S at NestedType@E at Enum@EnumCase |
}
More information about the cfe-commits
mailing list