[clang-tools-extra] [clang-tidy] Add modernize-default-arg-braced-init check (PR #203474)

Zeyi Xu via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 12 01:04:20 PDT 2026


================
@@ -0,0 +1,113 @@
+// RUN: %check_clang_tidy -std=c++11-or-later %s modernize-default-arg-braced-init %t
+
+struct Box {
+  Box() = default;
+  Box(int x) {}
+  Box(const Box&) {}
+};
+
+struct ExplicitBox {
+  explicit ExplicitBox() {}
+};
+
+struct Base {
+  Base() = default;
+};
+
+struct Derived : Base {
+  Derived() = default;
+};
+
+
+
+// Helper function for testing nested calls
+Box makeBox(Box b) { return b; }
+
+// ========== CASES THAT SHOULD TRANSFORM ==========
+
+// Case 1: Basic transformation
+// CHECK-MESSAGES: :[[@LINE+2]]:25: warning: use braced initializer list for default argument [modernize-default-arg-braced-init]
----------------
zeyi2 wrote:

```suggestion
// CHECK-MESSAGES: :[[@LINE+2]]:25: warning: use braced initializer list for default argument
```

Same as below.

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


More information about the cfe-commits mailing list