[PATCH] D44231: [clang-tidy] Check for sizeof that call functions
Paul Fultz II via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 8 14:38:45 PST 2018
pfultz2 added a comment.
> If the return type of foo() is changed, then the use for s1 will be automatically updated
But usually you write it as:
using foo_return = uint16_t;
size_t s1 = sizeof(foo());
size_t s2 = sizeof(foo_return);
So you just update the `foo_return` typedef, and it will update it everywhere that type is used.
> I think we need some data measurements over several large (>500k LoC) C and C++ code bases to see how frequently this check yields false positives.
So I ran it on llvm. It mainly complained about areas where `sizeof` is used for building traits. I should add an extra check that the function is not overloaded.
It did complain once about `sizeof` in a detection idiom(in BitmaskEnum.h) and once with `sizeof(getVersion())`, like you mentioned.
rCTE Clang Tools Extra
More information about the cfe-commits