Skip to content

Commit 9e0cf62

Browse files
committed
Swift: Fix + simplify LogicalOperation.qll.
1 parent 63376da commit 9e0cf62

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

swift/ql/lib/codeql/swift/elements/expr/LogicalOperation.qll

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,19 @@ private import codeql.swift.elements.expr.DeclRefExpr
66
private import codeql.swift.elements.decl.ConcreteFuncDecl
77

88
private predicate unaryHasName(PrefixUnaryExpr e, string name) {
9-
e.getFunction()
10-
.(DotSyntaxCallExpr)
11-
.getFunction()
12-
.(DeclRefExpr)
13-
.getDecl()
14-
.(ConcreteFuncDecl)
15-
.getName() = name
9+
e.getFunction().(DotSyntaxCallExpr).getStaticTarget().getName() = name
1610
}
1711

1812
private predicate binaryHasName(BinaryExpr e, string name) {
19-
e.getFunction()
20-
.(DotSyntaxCallExpr)
21-
.getFunction()
22-
.(DeclRefExpr)
23-
.getDecl()
24-
.(ConcreteFuncDecl)
25-
.getName() = name
13+
e.getFunction().(DotSyntaxCallExpr).getStaticTarget().getName() = name
2614
}
2715

2816
class LogicalAndExpr extends BinaryExpr {
29-
LogicalAndExpr() { binaryHasName(this, "&&") }
17+
LogicalAndExpr() { binaryHasName(this, "&&(_:_:)") }
3018
}
3119

3220
class LogicalOrExpr extends BinaryExpr {
33-
LogicalOrExpr() { binaryHasName(this, "||") }
21+
LogicalOrExpr() { binaryHasName(this, "||(_:_:)") }
3422
}
3523

3624
class BinaryLogicalOperation extends BinaryExpr {
@@ -41,7 +29,7 @@ class BinaryLogicalOperation extends BinaryExpr {
4129
}
4230

4331
class NotExpr extends PrefixUnaryExpr {
44-
NotExpr() { unaryHasName(this, "!") }
32+
NotExpr() { unaryHasName(this, "!(_:)") }
4533
}
4634

4735
class UnaryLogicalOperation extends PrefixUnaryExpr {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| logicaloperation.swift:4:6:4:11 | ... call to &&(_:_:) ... | BinaryLogicalExpr, LogicalAndExpr |
2+
| logicaloperation.swift:5:6:5:11 | ... call to \|\|(_:_:) ... | BinaryLogicalExpr, LogicalOrExpr |
3+
| logicaloperation.swift:6:6:6:7 | call to ... | NotExpr, UnaryLogicalOperation |
4+
| logicaloperation.swift:7:6:7:21 | call to ... | NotExpr, UnaryLogicalOperation |
5+
| logicaloperation.swift:7:8:7:20 | ... call to \|\|(_:_:) ... | BinaryLogicalExpr, LogicalOrExpr |
6+
| logicaloperation.swift:7:9:7:14 | ... call to &&(_:_:) ... | BinaryLogicalExpr, LogicalAndExpr |

0 commit comments

Comments
 (0)