[analyzer][solver] Track symbol disequalities
authorValeriy Savchenko <vsavchenko@apple.com>
Tue, 7 Jul 2020 08:36:20 +0000 (11:36 +0300)
committerValeriy Savchenko <vsavchenko@apple.com>
Wed, 22 Jul 2020 10:02:39 +0000 (13:02 +0300)
commite63b488f2755f91e8147fd678ed525cf6ba007cc
tree31f3dcb0001a1e86a495b40cf34a3f15b002f145
parentb13d9878b8dcef4354ddfc86f382ca9b537e65aa
[analyzer][solver] Track symbol disequalities

Summary:
This commmit adds another relation that we can track separately from
range constraints.  Symbol disequality can help us understand that
two equivalence classes are not equal to each other.  We can generalize
this knowledge to classes because for every a,b,c, and d that
a == b, c == d, and b != c it is true that a != d.

As a result, we can reason about other equalities/disequalities of symbols
that we know nothing else about, i.e. no constraint ranges associated
with them.  However, we also benefit from the knowledge of disequal
symbols by following the rule:
  if a != b and b == C where C is a constant, a != C
This information can refine associated ranges for different classes
and reduce the number of false positives and paths to explore.

Differential Revision: https://reviews.llvm.org/D83286
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang/test/Analysis/equality_tracking.c
clang/test/Analysis/mutually_exclusive_null_fp.cpp [new file with mode: 0644]