Skip to content

Commit 19454a5

Browse files
committed
PS: Small additions to the CFG classes and a small bugfix.
1 parent 18d94f2 commit 19454a5

File tree

1 file changed

+21
-1
lines changed
  • powershell/ql/lib/semmle/code/powershell/controlflow

1 file changed

+21
-1
lines changed

powershell/ql/lib/semmle/code/powershell/controlflow/CfgNodes.qll

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,26 @@ class ProcessBlockCfgNode extends NamedBlockCfgNode {
284284
ScriptBlockCfgNode getScriptBlock() { result.getProcessBlock() = this }
285285
}
286286

287+
private class CatchClauseChildMapping extends NonExprChildMapping, CatchClause {
288+
override predicate relevantChild(Ast child) {
289+
child = this.getBody() or child = this.getACatchType()
290+
}
291+
}
292+
293+
class CatchClauseCfgNode extends AstCfgNode {
294+
override string getAPrimaryQlClass() { result = "CatchClauseCfgNode" }
295+
296+
CatchClauseChildMapping s;
297+
298+
CatchClause getCatchClause() { result = s }
299+
300+
StmtCfgNode getBody() { s.hasCfgChild(s.getBody(), this, result) }
301+
302+
TypeConstraint getCatchType(int i) { result = s.getCatchType(i) }
303+
304+
TypeConstraint getACatchType() { result = this.getCatchType(_) }
305+
}
306+
287307
module ExprNodes {
288308
private class ArrayExprChildMapping extends ExprChildMapping, ArrayExpr {
289309
override predicate relevantChild(Ast child) {
@@ -747,7 +767,7 @@ module ExprNodes {
747767

748768
ExprCfgNode getAnKey() { result = this.getKey(_) }
749769

750-
ExprCfgNode getValue(int i) { e.hasCfgChild(e.getKey(i), this, result) }
770+
ExprCfgNode getValue(int i) { e.hasCfgChild(e.getValue(i), this, result) }
751771

752772
ExprCfgNode getValueFromKey(ExprCfgNode key) {
753773
exists(int i |

0 commit comments

Comments
 (0)