[clang] [DebugInfo] Ignore undefined constexpr constructors in constructor homing. (PR #218165)

Clayton Knittel via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 1 13:47:04 PDT 2026


================
@@ -3232,18 +3239,36 @@ static bool canUseCtorHoming(const CXXRecordDecl *RD) {
   if (isClassOrMethodDLLImport(RD))
     return false;
 
-  if (RD->isLambda() || RD->isAggregate() ||
-      RD->hasTrivialDefaultConstructor() ||
-      RD->hasConstexprNonCopyMoveConstructor())
+  if (RD->isLambda() || RD->isAggregate() || RD->hasTrivialDefaultConstructor())
+    return false;
+
+  // Skip this optimization if the class has a constexpr default constructor,
+  // since those constructors can be invoked without emitting type information
+  // for the constructor.
+  if (RD->needsImplicitDefaultConstructor() &&
+      RD->defaultedDefaultConstructorIsConstexpr())
     return false;
 
+  bool HasNonDeletedCtor = false;
   for (const CXXConstructorDecl *Ctor : RD->ctors()) {
     if (Ctor->isCopyOrMoveConstructor())
       continue;
+    const FunctionDecl *Def = nullptr;
+    if (Ctor->isDefined(Def)) {
----------------
ClaytonKnittel wrote:

Done.

https://github.com/llvm/llvm-project/pull/218165


More information about the cfe-commits mailing list