From: Craig Topper Date: Sat, 12 Dec 2015 06:30:48 +0000 (+0000) Subject: [Sema] Simplify a couple if statements. Explicitly check up front that only one of... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=38e5da05bc019cc0d723c6e03dd30b726ad224e4;p=clang [Sema] Simplify a couple if statements. Explicitly check up front that only one of the expressions is a comparision op. Then if we find that either is a bitwise op, we know it must be the other one. NFC git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255427 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 9bbc304e2e..1d1ce44369 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -10474,17 +10474,17 @@ static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc, BinaryOperator *LHSBO = dyn_cast(LHSExpr); BinaryOperator *RHSBO = dyn_cast(RHSExpr); - // Check that one of the sides is a comparison operator. + // Check that one of the sides is a comparison operator and the other isn't. bool isLeftComp = LHSBO && LHSBO->isComparisonOp(); bool isRightComp = RHSBO && RHSBO->isComparisonOp(); - if (!isLeftComp && !isRightComp) + if (isLeftComp == isRightComp) return; // Bitwise operations are sometimes used as eager logical ops. // Don't diagnose this. bool isLeftBitwise = LHSBO && LHSBO->isBitwiseOp(); bool isRightBitwise = RHSBO && RHSBO->isBitwiseOp(); - if ((isLeftComp || isLeftBitwise) && (isRightComp || isRightBitwise)) + if (isLeftBitwise || isRightBitwise) return; SourceRange DiagRange = isLeftComp ? SourceRange(LHSExpr->getLocStart(),