Skip to content

Commit 891e244

Browse files
committed
unified: Add WhileStmt as a Conditional
1 parent c8eb207 commit 891e244

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

unified/ql/lib/codeql/unified/internal/Variables.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ private module LocalNameBindingInput implements LocalNameBindingInputSig<Locatio
121121
override AstNode getElse() { result = IfExpr.super.getElse() }
122122
}
123123

124+
private class WhileStmtConditional extends Conditional instanceof WhileStmt {
125+
override AstNode getCondition() { result = WhileStmt.super.getCondition() }
126+
127+
override AstNode getThen() { result = WhileStmt.super.getBody() }
128+
129+
override AstNode getElse() { none() }
130+
}
131+
124132
abstract class SiblingShadowingDecl extends AstNode {
125133
/**
126134
* Gets the right-hand side of this declaration.

unified/ql/test/library-tests/variables/test.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ func t34() {
311311
// While-let optional binding
312312
func t35(optional: Int?) { // name=optional1
313313
while let x = optional { // $ access=optional1 // name=x1
314-
print(x) // $ MISSING: access=x1
314+
print(x) // $ access=x1
315315
}
316316
}
317317

@@ -320,8 +320,8 @@ func t36(a: Int?, b: Int?) {
320320
while let x = a, // $ access=a
321321
let y = b, // $ access=b
322322
x < y { // $ $ access=x access=y
323-
print(x) // $ MISSING: access=x
324-
print(y) // $ MISSING: access=y
323+
print(x) // $ access=x
324+
print(y) // $ access=y
325325
}
326326
}
327327

@@ -331,6 +331,6 @@ func t37() {
331331
while let x = x, // $ access=x1 // name=x2
332332
let x = x, // $ access=x2 // name=x3
333333
x > 0 { // $ access=x3
334-
print(x) // $ MISSING: access=x3 SPURIOUS: access=x1
334+
print(x) // $ access=x3
335335
}
336336
}

0 commit comments

Comments
 (0)