]> granicus.if.org Git - clang/commit
[Analyzer] SValBuilder Comparison Rearrangement (with Restrictions and Analyzer Option)
authorAdam Balogh <adam.balogh@ericsson.com>
Wed, 11 Apr 2018 06:21:12 +0000 (06:21 +0000)
committerAdam Balogh <adam.balogh@ericsson.com>
Wed, 11 Apr 2018 06:21:12 +0000 (06:21 +0000)
commit44fcdc119f6282033a8ff2e93bd073011fe8fc1d
treefcfeef66a340a05af2501b12db7a6fd4951f61d4
parentafb2127600cf1046e0ef5b6bcc5b648387487f4d
[Analyzer] SValBuilder Comparison Rearrangement (with Restrictions and Analyzer Option)

Since the range-based constraint manager (default) is weak in handling comparisons where symbols are on both sides it is wise to rearrange them to have symbols only on the left side. Thus e.g. A + n >= B + m becomes A - B >= m - n which enables the constraint manager to store a range m - n .. MAX_VALUE for the symbolic expression A - B. This can be used later to check whether e.g. A + k == B + l can be true, which is also rearranged to A - B == l - k so the constraint manager can check whether l - k is in the range (thus greater than or equal to m - n).

The restriction in this version is the the rearrangement happens only if both the symbols and the concrete integers are within the range [min/4 .. max/4] where min and max are the minimal and maximal values of their type.

The rearrangement is not enabled by default. It has to be enabled by using -analyzer-config aggressive-relational-comparison-simplification=true.

Co-author of this patch is Artem Dergachev (NoQ).

Differential Revision: https://reviews.llvm.org/D41938

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@329780 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
test/Analysis/conditional-path-notes.c
test/Analysis/explain-svals.cpp
test/Analysis/svalbuilder-rearrange-comparisons.c [new file with mode: 0644]