Add logic for computing rangesets for symbolic subtraction operator and
add test cases.
Details
- Reviewers
teemperor vsavchenko NoQ xazax.hun
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Hey Manas! Great job, you put this together real quick!
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp | ||
---|---|---|
1481 | Maybe you can include this as yet another condition in the next if statement? Their bodies are identical. | |
clang/test/Analysis/constant-folding.c | ||
399 | Maybe you can check (a - b) > 5 && (a - b) < UINT_MAX - 9 to cover the whole range? | |
405 | This is also Min and Max overflowing on the positive side. |
Thanks Valeriy.
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp | ||
---|---|---|
1481 | True. I wanted to optimize the following if condition as it looks quite ugly right now! Although, I will concatenate these conditions for now and work on the optimization later. | |
clang/test/Analysis/constant-folding.c | ||
399 | That's true! I never thought of putting them together. Makes more sense. | |
405 | I missed it! I will add another case for only Max overflowing on positive side and will keep this test as well. |
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp | ||
---|---|---|
1485 | @vsavchenko one thing crossed my mind is that, shouldn't I compare From and To values with llvm::APSInt Zero = ValueFactory.getAPSIntType(T).getZeroValue() instead of literal 0? |
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp | ||
---|---|---|
1485 | Yes! Thanks for noticing this (the same goes to the other patch as well) |
Here is the proof using Z3: https://gist.github.com/weirdsmiley/8a35a0e1f55f310e3566cbd47555491a
Maybe you can include this as yet another condition in the next if statement? Their bodies are identical.