[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 09:58:46 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:
I've improved it a bit, not only my changes but the rest as well as I think is way more readable now, there's still some duplicate code like:
```cpp
binaryOperator(hasLHS(anyOf(NumericLiteral, EnumRef, binaryOperator())),
hasRHS(anyOf(NumericLiteral, EnumRef, binaryOperator()))));
```
But I still didn't wanted to change it as I think It's better for readability. let me know if this is the right call.
https://github.com/llvm/llvm-project/pull/129370
More information about the cfe-commits
mailing list