Skip to content

Commit 77ddd48

Browse files
committed
Replace IfStmt.getCond with IfStmt.getCondition
1 parent d302fa7 commit 77ddd48

7 files changed

Lines changed: 12 additions & 9 deletions

File tree

go/ql/lib/semmle/go/Stmt.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,11 @@ class IfStmt extends @ifstmt, Stmt, ScopeNode {
710710
/** Gets the init statement of this `if` statement, if any. */
711711
Stmt getInit() { result = this.getChildStmt(0) }
712712

713+
/** DEPRECATED: Use `getCondition` instead. */
714+
deprecated Expr getCond() { result = this.getCondition() }
715+
713716
/** Gets the condition of this `if` statement. */
714-
Expr getCond() { result = this.getChildExpr(1) }
717+
Expr getCondition() { result = this.getChildExpr(1) }
715718

716719
/** Gets the "then" branch of this `if` statement. */
717720
BlockStmt getThen() { result = this.getChildStmt(2) }
@@ -721,7 +724,7 @@ class IfStmt extends @ifstmt, Stmt, ScopeNode {
721724

722725
override predicate mayHaveSideEffects() {
723726
this.getInit().mayHaveSideEffects() or
724-
this.getCond().mayHaveSideEffects() or
727+
this.getCondition().mayHaveSideEffects() or
725728
this.getThen().mayHaveSideEffects() or
726729
this.getElse().mayHaveSideEffects()
727730
}

go/ql/lib/semmle/go/controlflow/ControlFlowGraph.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ module ControlFlow {
118118
or
119119
expr = any(ForStmt fs).getCond()
120120
or
121-
expr = any(IfStmt is).getCond()
121+
expr = any(IfStmt is).getCondition()
122122
or
123123
isExpressionlessSwitchCaseCondition(expr)
124124
}

go/ql/lib/semmle/go/controlflow/IR.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module IR {
2929
* `LogicalBinaryExpr`.
3030
*/
3131
private predicate isInBooleanCondContext(Expr e) {
32-
e = any(IfStmt s).getCond()
32+
e = any(IfStmt s).getCondition()
3333
or
3434
e = any(ForStmt s).getCond()
3535
or

go/ql/src/RedundantCode/DuplicateBranches.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ where
2323
thenBranch = is.getThen() and
2424
elseBranch = is.getElse() and
2525
thenBranch.hash() = elseBranch.hash()
26-
select is.getCond(), "The 'then' and 'else' branches of this if statement are identical."
26+
select is.getCondition(), "The 'then' and 'else' branches of this if statement are identical."

go/ql/src/RedundantCode/DuplicateCondition.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import go
1616

1717
/** Gets the `i`th condition in the `if`-`else if` chain starting at `stmt`. */
1818
Expr getCondition(IfStmt stmt, int i) {
19-
i = 0 and result = stmt.getCond()
19+
i = 0 and result = stmt.getCondition()
2020
or
2121
exists(IfStmt elsif | elsif = stmt.getElse() |
2222
not exists(elsif.getInit()) and

go/ql/src/RedundantCode/UnreachableStatement.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ predicate allowlist(Stmt s) {
9090
or
9191
// statements deliberately made unreachable by a constant condition, such as the code
9292
// following `if true { return }`
93-
exists(getPreviousStmt(s).(IfStmt).getCond().getBoolValue())
93+
exists(getPreviousStmt(s).(IfStmt).getCondition().getBoolValue())
9494
}
9595

9696
from Stmt s

go/ql/src/experimental/CWE-942/CorsMisconfiguration.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ module FromUntrustedConfig implements DataFlow::ConfigSig {
176176
additional predicate isSinkCgn(DataFlow::Node sink, ControlFlow::ConditionGuardNode cgn) {
177177
exists(IfStmt ifs |
178178
exists(Expr operand |
179-
operand = ifs.getCond().getAChildExpr*() and
179+
operand = ifs.getCondition().getAChildExpr*() and
180180
(
181181
exists(DataFlow::CallExpr call | call = operand |
182182
call.getTarget().hasQualifiedName("strings", "HasSuffix") and
@@ -202,7 +202,7 @@ module FromUntrustedConfig implements DataFlow::ConfigSig {
202202
)
203203
)
204204
|
205-
cgn.getCondition() = ifs.getCond()
205+
cgn.getCondition() = ifs.getCondition()
206206
)
207207
}
208208
}

0 commit comments

Comments
 (0)