Skip to content

Commit 6684a59

Browse files
authored
[analyzer][NFC] Trivial cleanup in ArrayBoundChecker (#126941)
Two small stylistic improvements in code that I wrote ~a year ago: 1. fix a typo in a comment; and 2. simplify the code of `tryDividePair` by swapping the true and the false branches.
1 parent b16ce8f commit 6684a59

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ compareValueToThreshold(ProgramStateRef State, NonLoc Value, NonLoc Threshold,
323323
// we want to ensure that assumptions coming from this precondition and
324324
// assumptions coming from regular C/C++ operator calls are represented by
325325
// constraints on the same symbolic expression. A solution that would
326-
// evaluate these "mathematical" compariosns through a separate pathway would
326+
// evaluate these "mathematical" comparisons through a separate pathway would
327327
// be a step backwards in this sense.
328328

329329
const BinaryOperatorKind OpKind = CheckEquality ? BO_EQ : BO_LT;
@@ -394,14 +394,13 @@ static bool tryDividePair(std::optional<int64_t> &Val1,
394394
return false;
395395
const bool Val1HasRemainder = Val1 && *Val1 % Divisor;
396396
const bool Val2HasRemainder = Val2 && *Val2 % Divisor;
397-
if (!Val1HasRemainder && !Val2HasRemainder) {
398-
if (Val1)
399-
*Val1 /= Divisor;
400-
if (Val2)
401-
*Val2 /= Divisor;
402-
return true;
403-
}
404-
return false;
397+
if (Val1HasRemainder || Val2HasRemainder)
398+
return false;
399+
if (Val1)
400+
*Val1 /= Divisor;
401+
if (Val2)
402+
*Val2 /= Divisor;
403+
return true;
405404
}
406405

407406
static Messages getExceedsMsgs(ASTContext &ACtx, const SubRegion *Region,

0 commit comments

Comments
 (0)