pfultz2 added a comment.

> I don't have a script for it. I've used "bear" with at least some of those 
> projects because they use makefiles rather than cmake 
> (https://github.com/rizsotto/Bear). I'm not tied to those projects 
> specifically, either, so if you have a different corpus you'd prefer to use, 
> that's fine. The important bit is testing it across a considerable amount of 
> C code and C++ code to see whether this diagnostic is too chatty or not.

So I did a grep over these codebases(with `grep -E 
'\bsizeof\([^()"*]+\([^()]*\)'`). Most of them are macros which access 
elements(ie no function call) or are used in type traits. The only false 
positive I saw was here:

https://github.com/rethinkdb/rethinkdb/blob/v2.3.x/external/re2_20140111/re2/prog.cc#L317

So I dont think it will be too chatty.

> That won't catch many (most?) of the issues demonstrated by PVS-Studio; the 
> rule their check follows are to warn on side-effecting operations (which 
> Clang already does with -Wunevaluated-expression) and arithmetic expressions 
> in sizeof.

It finds function calls as well. I tried on MIOpen and it caught the errors 
like I mentioned earlier here:

https://github.com/ROCmSoftwarePlatform/MIOpen/blob/master/src/convolution.cpp#L184


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44231



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to