================
@@ -7042,12 +7042,38 @@ void Sema::CheckCompletedCXXClass(Scope *S,
CXXRecordDecl *Record) {
}
}
+ bool EffectivelyConstexprDestructor = true;
+ // Avoid triggering vtable instantiation due to a dtor that is not
+ // "effectively constexpr" for better compatibility.
+ if (isa<CXXDestructorDecl>(M)) {
+ auto Check = [](QualType T, auto &&Check) -> bool {
+ const CXXRecordDecl *RD =
+ T->getBaseElementTypeUnsafe()->getAsCXXRecordDecl();
+ if (!RD || !RD->isCompleteDefinition())
+ return true;
+
+ if (!RD->hasConstexprDestructor())
+ return false;
+
+ for (const CXXBaseSpecifier &B : RD->bases())
+ if (!Check(B.getType(), Check))
+ return false;
+ for (const FieldDecl *FD : RD->fields())
+ if (!Check(FD->getType(), Check))
+ return false;
+ return true;
+ };
+ EffectivelyConstexprDestructor =
+ Check(QualType(Record->getTypeForDecl(), 0), Check);
+ }
+
----------------
cor3ntin wrote:
I think `Record->defaultedDestructorIsConstexpr()` would give the right result
even if C++23, so I think we can simplify that to `CSM !=
CXXSpecialMemberKind::Destructor || Record->defaultedDestructorIsConstexpr()`
Could you try?
https://github.com/llvm/llvm-project/pull/102605
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits