|
1 | 1 | import csharp |
2 | 2 | import ControlFlow::Internal |
3 | 3 |
|
4 | | -predicate defReadInconsistency(AssignableRead ar, Expr e) { |
5 | | - exists(PreSsa::Definition ssaDef, AssignableDefinition def | |
6 | | - e = def.getExpr() and |
7 | | - PreSsa::firstReadSameVar(ssaDef, ar) and |
8 | | - ssaDef.getDefinition() = def and |
9 | | - not exists(Ssa::ExplicitDefinition edef | |
| 4 | +predicate defReadInconsistency(AssignableRead ar, Expr e, boolean b) { |
| 5 | + exists(AssignableDefinition def | |
| 6 | + e = def.getExpr() | |
| 7 | + b = true and |
| 8 | + exists(PreSsa::Definition ssaDef | |
| 9 | + PreSsa::firstReadSameVar(ssaDef, ar) and |
| 10 | + ssaDef.getDefinition() = def and |
| 11 | + not exists(Ssa::ExplicitDefinition edef | |
| 12 | + edef.getADefinition() = def and |
| 13 | + edef.getAFirstRead() = ar |
| 14 | + ) |
| 15 | + ) |
| 16 | + or |
| 17 | + b = false and |
| 18 | + exists(Ssa::ExplicitDefinition edef | |
10 | 19 | edef.getADefinition() = def and |
11 | | - edef.getARead() = ar |
| 20 | + edef.getAFirstRead() = ar and |
| 21 | + def.getTarget() instanceof PreSsa::SimpleLocalScopeVariable and |
| 22 | + not exists(PreSsa::Definition ssaDef | |
| 23 | + PreSsa::firstReadSameVar(ssaDef, ar) and |
| 24 | + ssaDef.getDefinition() = def |
| 25 | + ) |
12 | 26 | ) |
13 | 27 | ) |
14 | 28 | } |
15 | 29 |
|
16 | | -predicate readReadInconsistency(LocalScopeVariableRead read1, LocalScopeVariableRead read2) { |
| 30 | +predicate readReadInconsistency(LocalScopeVariableRead read1, LocalScopeVariableRead read2, boolean b) { |
| 31 | + b = true and |
17 | 32 | PreSsa::adjacentReadPairSameVar(read1, read2) and |
18 | 33 | not Ssa::Internal::adjacentReadPairSameVar(read1, read2) |
| 34 | + or |
| 35 | + b = false and |
| 36 | + Ssa::Internal::adjacentReadPairSameVar(read1, read2) and |
| 37 | + read1.getTarget() instanceof PreSsa::SimpleLocalScopeVariable and |
| 38 | + not PreSsa::adjacentReadPairSameVar(read1, read2) |
19 | 39 | } |
20 | 40 |
|
21 | | -from Element e1, Element e2, string s |
| 41 | +from Element e1, Element e2, boolean b, string s |
22 | 42 | where |
23 | | - defReadInconsistency(e1, e2) and |
24 | | - s = "def-read inconsistency" |
| 43 | + defReadInconsistency(e1, e2, b) and |
| 44 | + s = "def-read inconsistency (" + b + ")" |
25 | 45 | or |
26 | | - readReadInconsistency(e1, e2) and |
27 | | - s = "read-read inconsistency" |
| 46 | + readReadInconsistency(e1, e2, b) and |
| 47 | + s = "read-read inconsistency (" + b + ")" |
28 | 48 | select e1, e2, s |
0 commit comments