[clang-tools-extra] [clang-tidy] Fix false positive in modernize-use-equals-default (PR #232363)

via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 16 02:44:57 PDT 2026


================
@@ -243,23 +243,45 @@ struct DC : KW {
   // CHECK-FIXES: ~DC() override = default;
 };
 
-// Delegating constructor with multiple initializers.
-struct DCM : KW, N {
-  DCM() : KW(), N() {}
+// Delegating constructor with multiple bases.
+struct Base {
+  Base();
+};
+
+struct DCM : KW, Base {
+  DCM() : KW(), Base() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
   // CHECK-FIXES: DCM() = default;
 };
 
-struct dummy {};
-
 // Delegating constructor with field initializer.
 struct DCF : KW {
 
   DCF() : KW(), d() {}
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
   // CHECK-FIXES: DCF() = default;
 
-  dummy d;
+  Base d{};
+};
+
+struct non_empty {
+  int a,b;
+};
+
+// Delegating constructor with zero-init
+struct DCN : non_empty {
+
+  DCN() : non_empty() {}
+  // defaulting would remove the zero-init of non_empty.
+};
+
+// Delegating constructor with zero-init
+struct DCNF {
+
+  DCNF() : n() {}
+  // defaulting would remove the zero-init of n
+
+  non_empty n;
 };
 
----------------
serge-sans-paille wrote:

test cases added, works like a charm locally

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


More information about the cfe-commits mailing list