Skip to content

Commit c26fdc3

Browse files
committed
PS: A few CFG bugfixes.
1 parent 645db5b commit c26fdc3

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

powershell/ql/lib/semmle/code/powershell/NamedBlock.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ class NamedBlock extends @named_block, Ast {
99

1010
int getNumTraps() { named_block(this, _, result) }
1111

12-
Stmt getStatement(int i) { named_block_statement(this, i, result) }
12+
Stmt getStmt(int i) { named_block_statement(this, i, result) }
1313

14-
Stmt getAStatement() { result = this.getStatement(_) }
14+
Stmt getAStmt() { result = this.getStmt(_) }
1515

1616
TrapStmt getTrap(int i) { named_block_trap(this, i, result) }
1717

powershell/ql/lib/semmle/code/powershell/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,12 @@ module Trees {
221221
final override predicate succEntry(Ast n, Completion c) { n = this and completionIsSimple(c) }
222222
}
223223

224-
class NamedBlockTree extends StandardPostOrderTree instanceof NamedBlock {
224+
class NamedBlockTree extends StandardPreOrderTree instanceof NamedBlock {
225225
// TODO: Handle trap
226-
override AstNode getChildNode(int i) { result = super.getStatement(i) }
226+
override AstNode getChildNode(int i) { result = super.getStmt(i) }
227227
}
228228

229-
class AssignStmtTree extends StandardPostOrderTree instanceof AssignStmt {
229+
class AssignStmtTree extends StandardPreOrderTree instanceof AssignStmt {
230230
override AstNode getChildNode(int i) {
231231
i = 0 and result = super.getLeftHandSide()
232232
or
@@ -348,6 +348,11 @@ module Trees {
348348
last(this.getBody(), pred, c) and
349349
completionIsNormal(c) and
350350
first(super.getIterator(), succ)
351+
or
352+
// Iterator -> condition
353+
last(super.getIterator(), pred, c) and
354+
completionIsNormal(c) and
355+
first(super.getCondition(), succ)
351356
}
352357
}
353358

@@ -381,7 +386,7 @@ module Trees {
381386
completionIsSimple(c)
382387
or
383388
// Variable declaration to body
384-
last(super.getVarAccess(), succ, c) and
389+
last(super.getVarAccess(), pred, c) and
385390
completionIsNormal(c) and
386391
first(this.getBody(), succ)
387392
or

0 commit comments

Comments
 (0)