[clang-tools-extra] [clang-tidy] Make `P +- BS / sizeof(*P)` opt-outable in `bugprone-sizeof-expression` (PR #111178)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 11 13:09:14 PDT 2024


https://github.com/5chmidti commented:

Basically LGTM, but the name `WarnOnArithmeticWithDivisionBySizeOf` would imply that
```c++
(Buffer - Buffer) / sizeof(*Buffer);
```
would be ignored as well when the flag is `false`. Please add something in the documentation about this. The option could also be renamed of course. 
I don't really have a name that stands out as best, but here some ideas: 
- `WarnOnOffsetByScaledDownSize`
- `WarnOnOffsetDividedBySizeOf` (this one comes closer to the above example again)

(non-blocking on renaming the option)

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


More information about the cfe-commits mailing list