Skip to content

Commit f02abb3

Browse files
committed
Cfg: Handle ExprStmt and BlockStmt in defaultStep.
1 parent e695477 commit f02abb3

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

shared/controlflow/codeql/controlflow/ControlFlowGraph.qll

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,28 +1200,6 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
12001200
n2.isAfterValue(boollit, any(BooleanSuccessor t | t.getValue() = boollit.getValue()))
12011201
)
12021202
or
1203-
exists(ExprStmt exprstmt |
1204-
n1.isBefore(exprstmt) and
1205-
n2.isBefore(exprstmt.getExpr())
1206-
// the `isAfter(exprstmt.getExpr())` to `isAfter(exprstmt)` case is handled by `propagatesValue` above.
1207-
)
1208-
or
1209-
exists(BlockStmt blockstmt |
1210-
n1.isBefore(blockstmt) and
1211-
n2.isBefore(blockstmt.getStmt(0))
1212-
or
1213-
not exists(blockstmt.getStmt(_)) and
1214-
n1.isBefore(blockstmt) and
1215-
n2.isAfter(blockstmt) and
1216-
not simpleLeafNode(blockstmt)
1217-
or
1218-
exists(int i |
1219-
n1.isAfter(blockstmt.getStmt(i)) and
1220-
n2.isBefore(blockstmt.getStmt(i + 1))
1221-
)
1222-
// the `isAfter(blockstmt.getLastStmt())` to `isAfter(blockstmt)` case is handled by `propagatesValue` above.
1223-
)
1224-
or
12251203
exists(IfStmt ifstmt |
12261204
n1.isBefore(ifstmt) and
12271205
n2.isBefore(ifstmt.getCondition())
@@ -1525,8 +1503,11 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
15251503
(
15261504
n1.isBefore(ast) and not exists(getRankedChild(ast, _)) and not simpleLeafNode(ast)
15271505
or
1528-
exists(int i |
1529-
n1.isAfter(getRankedChild(ast, i)) and not exists(getRankedChild(ast, i + 1))
1506+
exists(int i, AstNode last |
1507+
last = getRankedChild(ast, i) and
1508+
not exists(getRankedChild(ast, i + 1)) and
1509+
n1.isAfter(last) and
1510+
not propagatesValue(last, ast)
15301511
)
15311512
) and
15321513
(if postOrInOrder(ast) then n2.isIn(ast) else n2.isAfter(ast))

0 commit comments

Comments
 (0)