[PATCH] D91543: [clang-tidy] Improving bugprone-sizeof-expr check.
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 17 05:25:31 PST 2020
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.
LGTM aside from a testing request.
================
Comment at: clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp:301
+ sum += sizeof(PtrArray) / sizeof(PtrArray[0]);
+ sum += sizeof(PtrArray) / sizeof(PtrArray1[0]);
return sum;
----------------
I think this is missing some test coverage for cases like:
```
sum += sizeof(PtrArray) / sizeof(PtrArray[1]); // Bad array index
sum += sizeof(PtrArray) / sizeof(A[0]); // Different array types
```
Also, if you can add a comment to the `sum += sizeof(PtrArray) / sizeof(PtrArray1[0]);` test case about why this passes (same canonical types), that'd be appreciated since the test case is a bit subtle.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91543/new/
https://reviews.llvm.org/D91543
More information about the cfe-commits
mailing list