File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -1403,6 +1403,14 @@ class ComparisonFormula extends TComparisonFormula, Formula {
1403
1403
or
1404
1404
pred = directMember ( "getRightOperand" ) and result = this .getRightOperand ( )
1405
1405
}
1406
+
1407
+ /** Hplds if this comparison has the operands `a` and `b` (in any order). */
1408
+ pragma [ noinline]
1409
+ predicate hasOperands ( Expr a , Expr b ) {
1410
+ this .getLeftOperand ( ) = a and this .getRightOperand ( ) = b
1411
+ or
1412
+ this .getLeftOperand ( ) = b and this .getRightOperand ( ) = a
1413
+ }
1406
1414
}
1407
1415
1408
1416
/** A quantifier formula, such as `exists` or `forall`. */
Original file line number Diff line number Diff line change 10
10
11
11
import ql
12
12
13
+ AstNode getASubExpression ( Select sel ) {
14
+ result = sel .getExpr ( _)
15
+ or
16
+ result = getASubExpression ( sel ) .getAChild ( )
17
+ }
18
+
13
19
/** Gets the `index`th part of the select statement. */
14
20
private AstNode getSelectPart ( Select sel , int index ) {
15
21
result =
16
22
rank [ index ] ( AstNode n , Location loc |
17
23
(
18
- n . getParent * ( ) = sel . getExpr ( _ ) and loc = n .getLocation ( )
24
+ n = getASubExpression ( sel ) and loc = n .getLocation ( )
19
25
or
20
26
// the strings are behind a predicate call.
21
- exists ( Call c , Predicate target |
22
- c .getParent * ( ) = sel .getExpr ( _) and loc = c .getLocation ( )
23
- |
27
+ exists ( Call c , Predicate target | c = getASubExpression ( sel ) and loc = c .getLocation ( ) |
24
28
c .getTarget ( ) = target and
25
29
(
26
30
target .getBody ( ) .( ComparisonFormula ) .getAnOperand ( ) = n
@@ -30,6 +34,14 @@ private AstNode getSelectPart(Select sel, int index) {
30
34
)
31
35
)
32
36
)
37
+ or
38
+ // the string is a variable that is assigned in the `where` clause.
39
+ exists ( VarAccess v , ComparisonFormula comp , String str |
40
+ v = getASubExpression ( sel ) and
41
+ loc = v .getLocation ( ) and
42
+ comp .hasOperands ( v .getDeclaration ( ) .getAnAccess ( ) , str ) and
43
+ n = str
44
+ )
33
45
)
34
46
|
35
47
n
You can’t perform that action at this time.
0 commit comments