[PATCH] D103440: [WIP][analyzer] Introduce range-based reasoning for addition operator
Manas Gupta via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 23 22:34:07 PDT 2021
manas added inline comments.
================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1400
+ if (ResultType.isUnsigned()) {
+ LHS.From().uadd_ov(RHS.From(), HasMinOverflowed);
+ LHS.To().uadd_ov(RHS.To(), HasMaxOverflowed);
----------------
Using `uadd_ov` (and `sadd_ov`), we can get the added value as well as whether overflow occurred or not. A point is that these functions return `APInt` instead of `APSInt`.
But when I tried just using:
Min = LHS.From().uadd_ov(RHS.From(), HasMinOverflowed);
Max = LHS.To().uadd_ov(RHS.From(), HasMaxOverflowed);
instead of
Min = LHS.From() + RHS.From();
Max = LHS.To() + RHS.To();
just for the added value, then the following tests failed (//these tests and all other tests pass when I use the latter method to get Min/Max//):
Clang :: Analysis/PR3991.m
Clang :: Analysis/global-region-invalidation.c
Clang :: Analysis/malloc-overflow2.c
Clang :: Analysis/out-of-bounds-new.cpp
Clang :: Analysis/taint-generic.c
I am working on fixing this part.
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