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());
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());
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits