Skip to content

Commit 9aff609

Browse files
Handle TSK_Undeclared in resolveTypeToTagDecl()
1 parent ba9b1bf commit 9aff609

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

clang/lib/Sema/HeuristicResolver.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,15 @@ TagDecl *HeuristicResolverImpl::resolveTypeToTagDecl(QualType QT) {
137137
}
138138

139139
if (auto *TT = T->getAs<TagType>()) {
140-
return TT->getDecl();
140+
TagDecl *TD = TT->getDecl();
141+
// Template might not be instantiated yet, fall back to primary template
142+
// in such cases.
143+
if (const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(TD)) {
144+
if (CTSD->getTemplateSpecializationKind() == TSK_Undeclared) {
145+
return CTSD->getSpecializedTemplate()->getTemplatedDecl();
146+
}
147+
}
148+
return TD;
141149
}
142150

143151
if (const auto *ICNT = T->getAs<InjectedClassNameType>())

0 commit comments

Comments
 (0)