Skip to content

Commit 3c46b0c

Browse files
committed
Swift: Add BinaryExpr.getOperator().
1 parent fa86e75 commit 3c46b0c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ private module Cached {
155155
or
156156
// flow through nil-coalescing operator `??`
157157
exists(BinaryExpr nco |
158-
nco.getStaticTarget().(FreeFunctionDecl).getName() = "??(_:_:)" and
158+
nco.getOperator().(FreeFunctionDecl).getName() = "??(_:_:)" and
159159
nodeTo.asExpr() = nco
160160
|
161161
// value argument

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
private import codeql.swift.generated.expr.BinaryExpr
22
private import codeql.swift.elements.expr.Expr
3+
private import codeql.swift.elements.decl.AbstractFunctionDecl
34

45
class BinaryExpr extends Generated::BinaryExpr {
56
Expr getLeftOperand() { result = this.getArgument(0).getExpr() }
67

78
Expr getRightOperand() { result = this.getArgument(1).getExpr() }
89

10+
AbstractFunctionDecl getOperator() { result = this.getStaticTarget() }
11+
912
Expr getAnOperand() { result = [this.getLeftOperand(), this.getRightOperand()] }
1013

1114
override string toString() { result = "... " + this.getFunction().toString() + " ..." }

0 commit comments

Comments
 (0)