[clang-tools-extra] [clang-tidy] detect explicit casting within modernize-use-default-member-init (PR #129408)

David Rivera via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 11 10:51:01 PDT 2025


================
@@ -194,15 +199,21 @@ void UseDefaultMemberInitCheck::storeOptions(
 }
 
 void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
-  auto InitBase =
-      anyOf(stringLiteral(), characterLiteral(), integerLiteral(),
-            unaryOperator(hasAnyOperatorName("+", "-"),
-                          hasUnaryOperand(integerLiteral())),
-            floatLiteral(),
-            unaryOperator(hasAnyOperatorName("+", "-"),
-                          hasUnaryOperand(floatLiteral())),
-            cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
-            declRefExpr(to(enumConstantDecl())));
+
+  auto ExplicitCastExpr = castExpr(hasSourceExpression(anyOf(
+      unaryOperator(hasAnyOperatorName("+", "-"),
+                    hasUnaryOperand(anyOf(integerLiteral(), floatLiteral()))),
+      integerLiteral(), floatLiteral(), characterLiteral())));
----------------
RiverDave wrote:

Amazing, will apply these suggestions soon

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


More information about the cfe-commits mailing list