From f942fde819c29f217a7e4bdc33fad57a185dd2db Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sat, 12 Dec 2015 06:30:48 +0000 Subject: [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 llvm-svn: 255427 --- clang/lib/Sema/SemaExpr.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'clang/lib') diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 9bbc304e2e2..1d1ce443690 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/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(), -- cgit v1.2.3