[clang] [analyzer] Mention possibility of underflow in array overflow errors (PR #84201)

Balázs Kéri via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 7 06:18:09 PST 2024


================
@@ -603,6 +611,8 @@ void ArrayBoundCheckerV2::performCheck(const Expr *E, CheckerContext &C) const {
     auto [WithinUpperBound, ExceedsUpperBound] =
         compareValueToThreshold(State, ByteOffset, *KnownSize, SVB);
 
+    bool AssumedNonNegative = SUR.assumedNonNegative();
----------------
balazske wrote:

My first observation was at the text output generation when at the `if` statement `AssumedNonNegative` is true and a message is printed "can be negative or ...", this looks like a bug. Because the same name is used at other places this may clarify the meaning, but a comment would be useful anyway (even if the current name remains).
I would not use a variable, instead call `SUR.assumedNonNegative()` directly, then it is better visible that the value comes from `StateUpdateReporter`.

https://github.com/llvm/llvm-project/pull/84201


More information about the cfe-commits mailing list