[PATCH] D61260: [clang-tidy] Extend bugprone-sizeof-expression to check sizeof(pointers to structures)

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 1 04:03:11 PDT 2019


aaron.ballman added a comment.

Aside from the testing request, this LGTM.



================
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);
----------------
whisperity wrote:
> Why is this printed at `sizeof(A*)`? Do we not print the name of the actual type used in the expression?
The original check did this, so it's not really new behavior here. I don't recall the rationale off the top of my head, but I'd guess it's because the type is not really salient, but the fact that the type is a pointer is.


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