[Analyzer][solver] Simplify existing eq classes and constraints when a new constraint...
authorGabor Marton <gabor.marton@ericsson.com>
Fri, 28 May 2021 13:18:28 +0000 (15:18 +0200)
committerGabor Marton <gabor.marton@ericsson.com>
Mon, 14 Jun 2021 10:19:09 +0000 (12:19 +0200)
commit8ddbb442b6e87efc9c6599280740c6f4fc40963d
treecb49f14f9e743def4c1aa51ca96968ed11c731bb
parent4629554f0b664c94ada7c44fe40855d7a9a39820
[Analyzer][solver] Simplify existing eq classes and constraints when a new constraint is added

Update `setConstraint` to simplify existing equivalence classes when a
new constraint is added. In this patch we iterate over all existing
equivalence classes and constraints and try to simplfy them with
simplifySVal. This solves problematic cases where we have two symbols in
the tree, e.g.:
```
int test_rhs_further_constrained(int x, int y) {
  if (x + y != 0)
    return 0;
  if (y != 0)
    return 0;
  clang_analyzer_eval(x + y == 0); // expected-warning{{TRUE}}
  clang_analyzer_eval(y == 0);     // expected-warning{{TRUE}}
  return 0;
}
```

Differential Revision: https://reviews.llvm.org/D103314
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
clang/test/Analysis/find-binop-constraints.cpp [new file with mode: 0644]