[PATCH] D24861: [Sema] extend Wshift-op-parentheses so it warns for multiplicative operators

Bruno Cardoso Lopes via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 27 10:01:41 PDT 2016


bruno added a subscriber: bruno.
bruno added a comment.

Hi Daniel,

This is very nice.

In https://reviews.llvm.org/D24861#553606, @danielmarjamaki wrote:

> Compiling 2064 projects resulted in 904 warnings
>
> Here are the results:
>  https://drive.google.com/file/d/0BykPmWrCOxt2N04tYl8zVHA3MXc/view?usp=sharing
>
> The results looks acceptable imho. The code looks intentional in many cases so I believe there are users that will disable this warning. Probably there are true positives where the evaluation order is not really known. There were many warnings about macro arguments where the macro bitshifts the argument - these macros look very shaky to me.
>
> I saw some warnings about such code:
>
>   a * b << c
>   
>
> Maybe we should not warn about this. As far as I see, the result will be the same if (a*b) or (b<<c) is evaluated first - unless there is some overflow or signedness issues. What do you think? I'll keep these warnings for now.


Any idea on how expensive would be to reason about these false positives and avoid them?


Repository:
  rL LLVM

https://reviews.llvm.org/D24861





More information about the cfe-commits mailing list