[PATCH] D97445: [clang][sema] Ignore xor-used-as-pow if both sides are macros
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 25 07:31:56 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2cc58463caf4: [clang][sema] Ignore xor-used-as-pow if both sides are macros (authored by tbaeder).
Changed prior to commit:
https://reviews.llvm.org/D97445?vs=326294&id=326386#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97445/new/
https://reviews.llvm.org/D97445
Files:
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/warn-xor-as-pow.cpp
Index: clang/test/SemaCXX/warn-xor-as-pow.cpp
===================================================================
--- clang/test/SemaCXX/warn-xor-as-pow.cpp
+++ clang/test/SemaCXX/warn-xor-as-pow.cpp
@@ -65,6 +65,7 @@
res = 2 ^ 0x4;
res = 2 ^ 04;
+ res = TWO ^ TEN;
res = 0x2 ^ 10;
res = 0X2 ^ 10;
res = 02 ^ 10;
Index: clang/lib/Sema/SemaExpr.cpp
===================================================================
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -12102,6 +12102,11 @@
if (Loc.isMacroID())
return;
+ // Do not diagnose if both LHS and RHS are macros.
+ if (XorLHS.get()->getExprLoc().isMacroID() &&
+ XorRHS.get()->getExprLoc().isMacroID())
+ return;
+
bool Negative = false;
bool ExplicitPlus = false;
const auto *LHSInt = dyn_cast<IntegerLiteral>(XorLHS.get());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97445.326386.patch
Type: text/x-patch
Size: 847 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210225/d4f9332b/attachment-0001.bin>
More information about the cfe-commits
mailing list