[clang-tools-extra] [clang-tidy] detect arithmetic operations within member list initialization in modernize-use-default-member-init check (PR #129370)
David Rivera via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 1 14:49:51 PST 2025
================
@@ -202,7 +208,13 @@ void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
unaryOperator(hasAnyOperatorName("+", "-"),
hasUnaryOperand(floatLiteral())),
cxxBoolLiteral(), cxxNullPtrLiteralExpr(), implicitValueInitExpr(),
- declRefExpr(to(enumConstantDecl())));
+ declRefExpr(to(enumConstantDecl())),
+ binaryOperator(hasLHS(anyOf(integerLiteral(), floatLiteral(),
----------------
RiverDave wrote:
Done. I've improved not only my part but think I got rid of some redundancies to make it more readable. There's still some duplicate code like:
```cpp
hasOperands(anyOf(NumericLiteral, EnumRef, binaryOperator()),
anyOf(NumericLiteral, EnumRef, binaryOperator())));
```
I'm not really sure if there's another way of avoiding that. for the rest let me know if this is the right direction.
https://github.com/llvm/llvm-project/pull/129370
More information about the cfe-commits
mailing list