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

Bruno Ricci via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 21 05:36:47 PDT 2019


riccibruno added a comment.

Is the test up-to-date ? I tried to apply the patch locally and I get a bunch of failures :

  error: 'warning' diagnostics expected but not seen: 
    File /home/bruno/software/llvm-project/clang/test/SemaCXX/warn-xor-as-pow.cpp Line 73: result of '2 ^ 64' is 66; did you mean '-1LL'?
    File /home/bruno/software/llvm-project/clang/test/SemaCXX/warn-xor-as-pow.cpp Line 77: result of '2 ^ 64' is 66; did you mean 'ULLONG_MAX'?
  error: 'warning' diagnostics seen but not expected: 
    File /home/bruno/software/llvm-project/clang/test/SemaCXX/warn-xor-as-pow.cpp Line 53: result of '2 ^ TEN' is 8; did you mean '1 << TEN' (1024)?
    File /home/bruno/software/llvm-project/clang/test/SemaCXX/warn-xor-as-pow.cpp Line 119: result of '2 ^ ALPHA_OFFSET' is 1; did you mean '1 << ALPHA_OFFSET' (8)?
  error: 'note' diagnostics expected but not seen: 
    File /home/bruno/software/llvm-project/clang/test/SemaCXX/warn-xor-as-pow.cpp Line 73 (directive at /home/bruno/software/llvm-project/clang/test/SemaCXX/warn-xor-as-pow.cpp:75): replace expression with '0x2 ^ 64' to silence this warning
    File /home/bruno/software/llvm-project/clang/test/SemaCXX/warn-xor-as-pow.cpp Line 77 (directive at /home/bruno/software/llvm-project/clang/test/SemaCXX/warn-xor-as-pow.cpp:79): replace expression with '0x2 ^ 64' to silence this warning
  error: 'note' diagnostics seen but not expected: 
    File /home/bruno/software/llvm-project/clang/test/SemaCXX/warn-xor-as-pow.cpp Line 53: replace expression with '0x2 ^ TEN' to silence this warning
    File /home/bruno/software/llvm-project/clang/test/SemaCXX/warn-xor-as-pow.cpp Line 119: replace expression with '0x2 ^ ALPHA_OFFSET' to silence this warning
  8 errors generated.



================
Comment at: lib/Sema/SemaExpr.cpp:9429
+                                    const Expr *SubLHS = nullptr,
+                                    const Expr *SubRHS = nullptr) {
+  // Do not diagnose xor in macros.
----------------
I think it would be nice to have a little comment above `diagnoseXorMisusedAsPow` to explain what the parameters are (for example. it is not immediately clear to me what is the difference between `SubLHS` and `LHS`).


================
Comment at: lib/Sema/SemaExpr.cpp:9434
+
+  // Do not diagnose if xor's rhs is macro.
+  if (RHS.get()->getBeginLoc().isMacroID())
----------------
s/is macro/is a macro ?


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

https://reviews.llvm.org/D66397





More information about the cfe-commits mailing list