mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
Swift: Fix Code Scanning alerts.
This commit is contained in:
@@ -75,7 +75,7 @@ class AstCfgNode extends ControlFlowNode, TElementNode {
|
||||
override Location getLocation() { result = n.getLocation() }
|
||||
|
||||
final override string toString() {
|
||||
exists(string s | s = n.(AstNode).toString() |
|
||||
exists(string s | s = n.toString() |
|
||||
result = "[" + this.getSplitsString() + "] " + s
|
||||
or
|
||||
not exists(this.getSplitsString()) and result = s
|
||||
|
||||
@@ -100,16 +100,16 @@ module Stmts {
|
||||
*/
|
||||
private BraceStmt getFirstDeferStmtBody() {
|
||||
exists(int i |
|
||||
result = getDeferStmtBody(i) and
|
||||
not exists(getDeferStmtBody(i + 1))
|
||||
result = this.getDeferStmtBody(i) and
|
||||
not exists(this.getDeferStmtBody(i + 1))
|
||||
)
|
||||
}
|
||||
|
||||
/** Gets the body of the last `defer` statement to be executed. */
|
||||
private BraceStmt getLastDeferStmtBody() {
|
||||
exists(int i |
|
||||
result = getDeferStmtBody(i) and
|
||||
not exists(getDeferStmtBody(i - 1))
|
||||
result = this.getDeferStmtBody(i) and
|
||||
not exists(this.getDeferStmtBody(i - 1))
|
||||
)
|
||||
}
|
||||
|
||||
@@ -130,9 +130,9 @@ module Stmts {
|
||||
exists(int j |
|
||||
// The result is the j'th statement (where the index is less than or equal to i)
|
||||
result = this.getDeferStmtBody(j) and
|
||||
getDeferIndex(j) <= i and
|
||||
this.getDeferIndex(j) <= i and
|
||||
// and the next defer statement is _after_ the i'th statement.
|
||||
not getDeferIndex(j + 1) <= i
|
||||
not this.getDeferIndex(j + 1) <= i
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ predicate scopeLast(CfgScope scope, ControlFlowElement last, Completion c) {
|
||||
scope.(Impl::CfgScope::Range_).exit(last, c)
|
||||
}
|
||||
|
||||
/** The maximum number of splits allowed for a given node. */
|
||||
/** Gets the maximum number of splits allowed for a given node. */
|
||||
int maxSplits() { result = 5 }
|
||||
|
||||
class SplitKindBase = Splitting::TSplitKind;
|
||||
|
||||
@@ -2,9 +2,9 @@ private import codeql.swift.generated.expr.BinaryExpr
|
||||
private import codeql.swift.elements.expr.Expr
|
||||
|
||||
class BinaryExpr extends BinaryExprBase {
|
||||
Expr getLeftOperand() { result = getArgument(0).getExpr() }
|
||||
Expr getLeftOperand() { result = this.getArgument(0).getExpr() }
|
||||
|
||||
Expr getRightOperand() { result = getArgument(1).getExpr() }
|
||||
Expr getRightOperand() { result = this.getArgument(1).getExpr() }
|
||||
|
||||
Expr getAnOperand() { result = [this.getLeftOperand(), this.getRightOperand()] }
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
private import codeql.swift.generated.expr.Expr
|
||||
|
||||
class Expr extends ExprBase {
|
||||
final override Expr getResolveStep() { convertsFrom(result) }
|
||||
final override Expr getResolveStep() { this.convertsFrom(result) }
|
||||
|
||||
predicate convertsFrom(Expr e) { none() } // overridden by subclasses
|
||||
|
||||
Expr getConversion() { result.convertsFrom(this) }
|
||||
|
||||
predicate isConversion() { convertsFrom(_) }
|
||||
predicate isConversion() { this.convertsFrom(_) }
|
||||
|
||||
predicate hasConversions() { exists(getConversion()) }
|
||||
predicate hasConversions() { exists(this.getConversion()) }
|
||||
|
||||
Expr getFullyConverted() { result = this.getFullyUnresolved() }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user