This patch extends the constraint manager to be able to reason about trivial sym-sym comparisons.
We all know that a < b if the maximum value of a is still less than the minimum value of b.
This reasoning can be applied for the <,<=,>,>= relation operators.
This patch solely implements this functionality.
This patch does not address transitity like:
If a < b and b < c than a < c.
This patch is necessary to be able to express hidden function preconditions.
For example, with the D69726 we could express the connection between the
extent size of src and the size (n) parameter of the function.
#define ANALYZER_ASSERT assert void my_memcpy(char *dst, char *src, int n) { ANALYZER_ASSERT(clang_analyzer_getExtent(src) >= n) ANALYZER_ASSERT(clang_analyzer_getExtent(dst) >= n) for (int i = 0; i < n; ++i) { // The extent of dst would be compared to the index i. dst[i] = src[i]; // each memory access in-bound, no-warning } }
Can we use Optional<BinaryOperatorKind> instead, to reduce similar enums? Or you want to separate the meaning in a such way?