[clang] [Sema] Diagnose tautological bounds checks (PR #120222)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 17 04:29:26 PST 2024


================
@@ -11786,6 +11786,49 @@ static bool checkForArray(const Expr *E) {
   return D->getType()->isArrayType() && !D->isWeak();
 }
 
+/// Detect patterns ptr + size >= ptr and ptr + size < ptr, where ptr is a
+/// pointer and size is an unsigned integer. Return whether the result is
+/// always true/false.
+static std::optional<bool> isTautologicalBoundsCheck(Expr *LHS, Expr *RHS,
----------------
tbaederr wrote:

```suggestion
static std::optional<bool> isTautologicalBoundsCheck(const Expr *LHS, const Expr *RHS,
```

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


More information about the cfe-commits mailing list