[clang] [analyzer] Improve constraint inferring on concrete div/mod (PR #65448)

DonĂ¡t Nagy via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 2 01:18:04 PST 2026


================

----------------
NagyDonat wrote:

The hardcoded `extend(64)` is correct in many practical situations, but not elegant.

Instead I propose an accurate algorithm:
- Convert `R.To()` and `R.From()` to the unsigned variant of their own type, and subtract them in that type. This is guaranteed to accurately represent their difference.
- If this difference is larger than the maximal value of the unsigned variant of `ResultType`, return early: the range is too big, we cannot determine a concrete value.
- Convert the difference and `N` to the unsigned variant of `ResultType`, and compare them in that type: if `N` is greater, we can determine the concrete value.

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


More information about the cfe-commits mailing list