Skip to content

Commit 3884509

Browse files
Handle TSK_Undeclared in resolveTypeToTagDecl()
1 parent 5b4f650 commit 3884509

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
@@ -138,7 +138,15 @@ TagDecl *HeuristicResolverImpl::resolveTypeToTagDecl(QualType QT) {
138138
}
139139

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

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

0 commit comments

Comments
 (0)