[clang] [alpha.webkit.NoDeleteChecker] Don't warn members with an unused default constructor (PR #241102)

Ryosuke Niwa via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 13 00:47:59 PST 2026


================
@@ -1016,6 +1016,28 @@ class TrivialFunctionAnalysisVisitor
               (CtorDecl->isMoveConstructor() &&
                RD->hasTrivialMoveConstructor()))
             return true;
+          // A defaulted default constructor that nothing has used yet has no
+          // definition, so decide from the initializers it would run.
+          if (CtorDecl->isDefaultConstructor() && !CtorDecl->isDeleted() &&
+              !CtorDecl->doesThisDeclarationHaveABody() &&
+              RD->hasDefinition()) {
+            for (const FieldDecl *F : RD->fields()) {
+              if (const Expr *Init = F->getInClassInitializer()) {
+                if (!Visit(Init))
+                  return false;
+              } else if (!CanTriviallyConstruct(F->getType()))
+                return false;
+            }
+            for (const CXXBaseSpecifier &B : RD->bases()) {
+              if (!CanTriviallyConstruct(B.getType()))
+                return false;
+            }
+            for (const CXXBaseSpecifier &B : RD->vbases()) {
----------------
rniwa wrote:

Ah, got it. Removed the redundant loop.

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


More information about the cfe-commits mailing list