[PATCH] D66397: [Diagnostics] Improve -Wxor-used-as-pow

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 19 11:36:39 PDT 2019


aaron.ballman added a comment.

In D66397#1635715 <https://reviews.llvm.org/D66397#1635715>, @xbolva00 wrote:

> I agree what @tkanis suggested and be silent if RHS is macro as real world code shows it. Opinions?
>
> @jfb @aaron.ballman


I suspect we can come up with examples where the macro on either lhs or rhs is sensible and other examples where its senseless. The existing test cases already have:

  res = TWO ^ 8; // expected-warning {{result of 'TWO ^ 8' is 10; did you mean '1 << 8' (256)?}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1 << 8"
  // expected-note at -2 {{replace expression with '0x2 ^ 8' to silence this warning}}
  
  res = 2 ^ TEN; // expected-warning {{result of '2 ^ TEN' is 8; did you mean '1 << TEN' (1024)?}}
  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:9-[[@LINE-1]]:16}:"1 << TEN"
  // expected-note at -2 {{replace expression with '0x2 ^ TEN' to silence this warning}}

showing that we expect to warn when macros are involved. If we decide that macros should silence the warning, I would expect any use of a macro in the expression to silence it, not just a RHS macro.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66397/new/

https://reviews.llvm.org/D66397





More information about the cfe-commits mailing list