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 {
14031403 or
14041404 pred = directMember ( "getRightOperand" ) and result = this .getRightOperand ( )
14051405 }
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+ }
14061414}
14071415
14081416/** A quantifier formula, such as `exists` or `forall`. */
Original file line number Diff line number Diff line change 1010
1111import ql
1212
13+ AstNode getASubExpression ( Select sel ) {
14+ result = sel .getExpr ( _)
15+ or
16+ result = getASubExpression ( sel ) .getAChild ( )
17+ }
18+
1319/** Gets the `index`th part of the select statement. */
1420private AstNode getSelectPart ( Select sel , int index ) {
1521 result =
1622 rank [ index ] ( AstNode n , Location loc |
1723 (
18- n . getParent * ( ) = sel . getExpr ( _ ) and loc = n .getLocation ( )
24+ n = getASubExpression ( sel ) and loc = n .getLocation ( )
1925 or
2026 // 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 ( ) |
2428 c .getTarget ( ) = target and
2529 (
2630 target .getBody ( ) .( ComparisonFormula ) .getAnOperand ( ) = n
@@ -30,6 +34,14 @@ private AstNode getSelectPart(Select sel, int index) {
3034 )
3135 )
3236 )
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+ )
3345 )
3446 |
3547 n
You can’t perform that action at this time.
0 commit comments