This patch refactors the ArrayBoundCheckerV2 to use more SValVisitor machinery.
IMO this pattern leads to a more functional style, thus more readable - compared to an ad-hoc recursion what getSimplifiedOffsets did.
I also drastically reduce the scope of the mutated local variables for readability.
This resulted in a fairly large change:
- Use MemRegionVisitor to compute RegionRawOffsetV2 of a memory region.
- Use SymExprVisitor to simplify subscript expression.
- Remove getSimplifiedOffsets function.
- Split up ArrayBoundCheckerV2::checkLocation into checkLowerBound and checkUpperBound.
Since you are already deep in refactoring. This calculation together with the enclosing class seems to be useful for other Checkers too. Would make sense to put this to CheckerHelpers?
E.g. the PlacementNewChecker could have benefited from this class if it had been available for use during the implementation of the checker.