[PATCH] D103440: [WIP][analyzer] Introduce range-based reasoning for addition operator
Gábor Horváth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 1 20:45:12 PDT 2021
xazax.hun added inline comments.
================
Comment at: clang/test/Analysis/constant-folding.c:265
+ if (a > INT_MAX) {
+ clang_analyzer_eval((a + b) <= 0); // expected-warning{{FALSE}}
+ clang_analyzer_eval((a + b) > 0); // expected-warning{{FALSE}}
----------------
Since both `a` and `b` are unsigned values, their sum is also unsigned. We basically check if their sum could be zero. I don't see why it could not in this case (e.g. when `b == UINT_MAX - a + 1`). Do I miss something?
================
Comment at: clang/test/Analysis/constant-folding.c:266
+ clang_analyzer_eval((a + b) <= 0); // expected-warning{{FALSE}}
+ clang_analyzer_eval((a + b) > 0); // expected-warning{{FALSE}}
+ }
----------------
If `a == INT_MAX + 1 && b == 0` then `(a + b) > 0`. Do I miss something? Or is this a bug?
================
Comment at: clang/test/Analysis/constant-folding.c:275
+
+ if (a <= UINT_MAX && b <= UINT_MAX) {
+ clang_analyzer_eval((a + b) < 0); // expected-warning{{UNKNOWN}}
----------------
vsavchenko wrote:
> I think this is always true.
So is `a >= 0 && b >= 0` unless I miss something.
================
Comment at: clang/test/Analysis/constant-folding.c:282
+ if (a == UINT_MAX && b == UINT_MAX) {
+ clang_analyzer_eval((a + b) >= 0); // expected-warning{{FALSE}}
+ }
----------------
I think `UINT_MAX + UINT_MAX` supposed to be positive. Do I miss something here?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103440/new/
https://reviews.llvm.org/D103440
More information about the cfe-commits
mailing list