@@ -7159,7 +7159,10 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) {
71597159 // "effectively constexpr" for better compatibility.
71607160 // See https://github.com/llvm/llvm-project/issues/102293 for more info.
71617161 if (isa<CXXDestructorDecl>(M)) {
7162- auto Check = [](QualType T, auto &&Check) -> bool {
7162+ llvm::SmallDenseSet<QualType> Visited;
7163+ auto Check = [&Visited](QualType T, auto &&Check) -> bool {
7164+ if (!Visited.insert(T->getCanonicalTypeUnqualified()).second)
7165+ return false;
71637166 const CXXRecordDecl *RD =
71647167 T->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
71657168 if (!RD || !RD->isCompleteDefinition())
@@ -7168,16 +7171,11 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) {
71687171 if (!RD->hasConstexprDestructor())
71697172 return false;
71707173
7171- QualType CanUnqualT = T.getCanonicalType().getUnqualifiedType();
71727174 for (const CXXBaseSpecifier &B : RD->bases())
7173- if (B.getType().getCanonicalType().getUnqualifiedType() !=
7174- CanUnqualT &&
7175- !Check(B.getType(), Check))
7175+ if (!Check(B.getType(), Check))
71767176 return false;
71777177 for (const FieldDecl *FD : RD->fields())
7178- if (FD->getType().getCanonicalType().getUnqualifiedType() !=
7179- CanUnqualT &&
7180- !Check(FD->getType(), Check))
7178+ if (!Check(FD->getType(), Check))
71817179 return false;
71827180 return true;
71837181 };
0 commit comments