[clang] [analyzer] Support interestingness in ArrayBoundV2 (PR #78315)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 19 08:33:48 PST 2024


================
@@ -255,7 +319,28 @@ static Messages getPrecedesMsgs(const SubRegion *Region, NonLoc Offset) {
   Out << "Access of " << RegName << " at negative byte offset";
   if (auto ConcreteIdx = Offset.getAs<nonloc::ConcreteInt>())
     Out << ' ' << ConcreteIdx->getValue();
-  return {getShortMsg(OOB_Precedes, RegName), std::string(Buf)};
+  return {formatv("Out of bound access to memory preceding {0}", RegName),
+          std::string(Buf)};
+}
+
+/// Try to divide `Val1` and `Val2` (in place) by `Divisor` and return true if
+/// it can be performed (`Divisor` is nonzero and there is no remainder). The
+/// values `Val1` and `Val2` may be nullopt and in that case the corresponding
+/// division is considered to be successful.
+bool tryDividePair(std::optional<int64_t> &Val1, std::optional<int64_t> &Val2,
----------------
steakhal wrote:

```suggestion
static bool tryDividePair(std::optional<int64_t> &Val1, std::optional<int64_t> &Val2,
```

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


More information about the cfe-commits mailing list