[PATCH] D61260: [clang-tidy] Extend bugprone-sizeof-expression to check sizeof(pointers to structures)
Whisperity via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 29 06:45:47 PDT 2019
whisperity added inline comments.
================
Comment at: test/clang-tidy/bugprone-sizeof-expression.cpp:196
typedef const MyStruct TMyStruct;
+ typedef const MyStruct *PMyStruct;
----------------
While I trust Clang and the matchers to unroll the type and still match, I'd prefer also adding a test case for
```
typedef TMyStruct* PMyStruct2;
```
or somesuch.
And perhaps a "copy" of these cases where they come from template arguments, in case the checker can also warn for that?
================
Comment at: test/clang-tidy/bugprone-sizeof-expression.cpp:231
+ sum += sizeof(MyStruct*);
+ // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(A*)'; pointer to aggregate
+ sum += sizeof(PMyStruct);
----------------
Why is this printed at `sizeof(A*)`? Do we not print the name of the actual type used in the expression?
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61260/new/
https://reviews.llvm.org/D61260
More information about the cfe-commits
mailing list