[clang-tools-extra] [clang-tidy] Make `P +- BS / sizeof(*P)` opt-outable in `bugprone-sizeof-expression` (PR #111178)
Nicolas van Kempen via cfe-commits
cfe-commits at lists.llvm.org
Sat Oct 5 14:41:13 PDT 2024
================
@@ -306,8 +310,13 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) {
unaryExprOrTypeTraitExpr(ofKind(UETT_AlignOf)),
offsetOfExpr()))
.bind("sizeof-in-ptr-arithmetic-scale-expr");
+ const auto PtrArithmeticIntegerScaleExprInterestingOperatorNames = [this] {
+ if (WarnOnSizeOfPointerArithmeticWithDivisionScaled)
+ return binaryOperator(hasAnyOperatorName("*", "/"));
+ return binaryOperator(hasOperatorName("*"));
+ };
----------------
nicovank wrote:
```suggestion
const auto HasSoughtIntegerScaleExprOperatorName =
WarnOnSizeOfPointerArithmeticWithDivisionScaled
? binaryOperator(hasAnyOperatorName("*", "/"))
: binaryOperator(hasOperatorName("*"));
```
Ternary should be OK, and I find name a little long but nit.
https://github.com/llvm/llvm-project/pull/111178
More information about the cfe-commits
mailing list