Swift: Fix Code Scanning alerts.

This commit is contained in:
Mathias Vorreiter Pedersen
2022-05-23 15:18:36 +01:00
parent 2882c42698
commit 4ba29845e9
5 changed files with 13 additions and 13 deletions

View File

@@ -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

View File

@@ -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
)
}

View File

@@ -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;

View File

@@ -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()] }
}

View File

@@ -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() }