[clang] [NFC][analyzer] Extract general logic in security.ArrayBound (PR #210774)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 23 04:26:50 PDT 2026


================
@@ -171,27 +226,57 @@ class ArrayBoundChecker : public Checker<check::PostStmt<ArraySubscriptExpr>,
 
   static bool isOffsetObviouslyNonnegative(const Expr *E, CheckerContext &C);
 
-  static bool isIdiomaticPastTheEndPtr(const Expr *E, ProgramStateRef State,
-                                       NonLoc Offset, NonLoc Limit,
-                                       CheckerContext &C);
   static bool isInAddressOf(const Stmt *S, ASTContext &AC);
 
 public:
   void checkPostStmt(const ArraySubscriptExpr *E, CheckerContext &C) const {
-    performCheck(E, C);
+    handleAccessExpr(E, C);
   }
   void checkPostStmt(const UnaryOperator *E, CheckerContext &C) const {
     if (E->getOpcode() == UO_Deref)
-      performCheck(E, C);
+      handleAccessExpr(E, C);
   }
   void checkPostStmt(const MemberExpr *E, CheckerContext &C) const {
     if (E->isArrow())
-      performCheck(E->getBase(), C);
+      handleAccessExpr(E->getBase(), C);
   }
 };
 
 } // anonymous namespace
 
+/// Return true if information about the value of \p SV can put constraints
+/// on some symbol which is interesting within the bug report \p BR
+/// In particular, this returns true when \p SV is interesting within \p BR;
+/// but it also returns true if \p SV is an expression that contains integer
+/// constants and a single symbolic operand which is interesting (in \p BR).
+/// We need to use this instead of plain `BR.isInteresting()` because if we
+/// are analyzing code like
+///   int array[10];
+///   int f(int arg) {
+///     return array[arg] && array[arg + 10];
+///   }
+/// then the byte offsets are `arg * 4` and `(arg + 10) * 4`, which are not
+/// sub-expressions of each other (but `getSimplifiedOffsets` is smart enough
+/// to detect this out of bounds access).
+static bool providesInformationAboutInteresting(SVal SV,
----------------
NagyDonat wrote:

`isInterestingForBugReport` would be synonymous with `PathSensitiveBugReport::isInteresting` and wouldn't highlight the characteristic property that this function returns true if the symbol is not itself interesting -- but has a part that is interesting.

The admittedly long and awkward name of this function attempts to abbreviate `providesInformationAboutInterestingSymbol`; turning its suffix into `Interestingness` changes its meaning.

@Xazax-hun What would you think about names like `isDeterminedByInterestingSymbol`, `hasInterestingPart`, `hasPartInterestingForBugReport`etc. ?

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


More information about the cfe-commits mailing list