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:
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)) {
} 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;
struct NestedType {
// CHECK: [[@LINE-1]]:10 | struct/C++ | NestedType | c:@ST>2#T#T@TemplateClass@S@NestedType |
+
+ T nestedField;
+// CHECK: [[@LINE-1]]:7 | field/C++ | nestedField | c:@ST>2#T#T@TemplateClass@S@NestedType@FI@nestedField |
+
class SubNestedType {
// CHECK: [[@LINE-1]]:11 | class/C++ | SubNestedType | c:@ST>2#T#T@TemplateClass@S@NestedType@S@SubNestedType |
public:
// CHECK: [[@LINE-1]]:30 | struct/C | NestedBaseType | c:@ST>1#T@BaseTemplate@S@NestedBaseType |
TemplateClass<int, float>::NestedType nestedSubType;
// CHECK: [[@LINE-1]]:30 | struct/C++ | NestedType | c:@ST>2#T#T@TemplateClass@S@NestedType |
+ (void)nestedSubType.nestedField;
+// CHECK: [[@LINE-1]]:23 | field/C++ | nestedField | c:@ST>2#T#T@TemplateClass@S@NestedType@FI@nestedField |
+
typedef TemplateClass<int, float> TT;
TT::NestedType::SubNestedType subNestedType(0);
// CHECK: [[@LINE-1]]:7 | struct/C++ | NestedType | c:@ST>2#T#T@TemplateClass@S@NestedType |