[PATCH] D63423: [Diagnostics] Diagnose misused xor as pow

Dávid Bolvanský via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 17 11:39:28 PDT 2019


xbolva00 marked 2 inline comments as done.
xbolva00 added inline comments.


================
Comment at: lib/Sema/SemaExpr.cpp:10924
+
+  if (LeftSideValue == 2 || LeftSideValue == 10) {
+    llvm::APInt XorValue = LeftSideValue ^ RightSideValue;
----------------
Quuxplusone wrote:
> Do you have metrics indicating that this line is an improvement over `if (true) {`?
This is left over of older code :) I will fix it.


================
Comment at: test/Sema/warn-xor-as-pow.c:39
+  res = 2 ^ 0b100;
+  res = XOR(2, 16);
+  unsigned char two = 2;
----------------
Quuxplusone wrote:
> I don't understand why this line doesn't warn. Is it because the macro's name has the case-insensitive string `xor` in it? Is it because there is a macro involved at all? In either case, please add another test case for `res = FOOBAR(2, 16)`.
> 
> Also `res = EPSILON` where `#define EPSILON 10^-300`. That seems to come up in the codesearch results a lot.
EPSILON 10^-300

this is in macro :( 

so maybe if negative RHS, we should check macro too? @jfb 


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

https://reviews.llvm.org/D63423





More information about the cfe-commits mailing list