[PATCH] D44231: [clang-tidy] Check for sizeof that call functions

Paul Fultz II via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 9 08:15:25 PST 2018

pfultz2 added a comment.

> Again, that only works for C++ and not C.

Typedef has always worked in C.

> Did it report any true positives that would need correcting?

Not for LLVM, but it has in other projects like I mentioned.

> Can you check some other large repos (both C++ and C), such as: Qt, cocos2d, rethinkdb, redis, and php-src?

None of those projects use cmake, so it doesn't look easy to run clang-tidy on them. Do you have a script that will run clang-tidy on these repos?

Actually, PVS-Studio has a more general check for `sizeof(expr)`:


It shows an example of FCEUX doing `sizeof(buf - 1)`, Asterisk doing `sizeof(data[0] * 2)` and ReactOS doing `sizeof(UnknownError [0] - 20)`. I think it might be a good idea to expand this from just a function call to any integer expression.

  rCTE Clang Tools Extra


More information about the cfe-commits mailing list