forked from OSchip/llvm-project
[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
This commit is contained in:
parent
550654aaf1
commit
f942fde819
clang/lib/Sema
|
@ -10474,17 +10474,17 @@ static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc,
|
|||
BinaryOperator *LHSBO = dyn_cast<BinaryOperator>(LHSExpr);
|
||||
BinaryOperator *RHSBO = dyn_cast<BinaryOperator>(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(),
|
||||
|
|
Loading…
Reference in New Issue