diff options
author | Adam Balogh <adam.balogh@ericsson.com> | 2018-04-11 06:21:12 +0000 |
---|---|---|
committer | Adam Balogh <adam.balogh@ericsson.com> | 2018-04-11 06:21:12 +0000 |
commit | 2bbccca9f75b6bce08d77cf19abfb206d0c3bc2e (patch) | |
tree | f2d4b1cd2a3b4dc788ca5434c37f9b28574654d0 /clang/test/Analysis/explain-svals.cpp | |
parent | bfd98d064a126aca73d257edb8cc956872bcfdb9 (diff) | |
download | bcm5719-llvm-2bbccca9f75b6bce08d77cf19abfb206d0c3bc2e.tar.gz bcm5719-llvm-2bbccca9f75b6bce08d77cf19abfb206d0c3bc2e.zip |
[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
llvm-svn: 329780
Diffstat (limited to 'clang/test/Analysis/explain-svals.cpp')
-rw-r--r-- | clang/test/Analysis/explain-svals.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/test/Analysis/explain-svals.cpp b/clang/test/Analysis/explain-svals.cpp index ecb5af1f8ef..c1b5200eb8e 100644 --- a/clang/test/Analysis/explain-svals.cpp +++ b/clang/test/Analysis/explain-svals.cpp @@ -69,7 +69,7 @@ void test_4(int x, int y) { static int stat; clang_analyzer_explain(x + 1); // expected-warning-re{{{{^\(argument 'x'\) \+ 1$}}}} clang_analyzer_explain(1 + y); // expected-warning-re{{{{^\(argument 'y'\) \+ 1$}}}} - clang_analyzer_explain(x + y); // expected-warning-re{{{{^unknown value$}}}} + clang_analyzer_explain(x + y); // expected-warning-re{{{{^\(argument 'x'\) \+ \(argument 'y'\)$}}}} clang_analyzer_explain(z); // expected-warning-re{{{{^undefined value$}}}} clang_analyzer_explain(&z); // expected-warning-re{{{{^pointer to local variable 'z'$}}}} clang_analyzer_explain(stat); // expected-warning-re{{{{^signed 32-bit integer '0'$}}}} |