Cfg: Handle ExprStmt and BlockStmt in defaultStep.

This commit is contained in:
Anders Schack-Mulligen
2026-03-03 13:34:27 +01:00
parent e695477f4f
commit f02abb3e93

View File

@@ -1200,28 +1200,6 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
n2.isAfterValue(boollit, any(BooleanSuccessor t | t.getValue() = boollit.getValue()))
)
or
exists(ExprStmt exprstmt |
n1.isBefore(exprstmt) and
n2.isBefore(exprstmt.getExpr())
// the `isAfter(exprstmt.getExpr())` to `isAfter(exprstmt)` case is handled by `propagatesValue` above.
)
or
exists(BlockStmt blockstmt |
n1.isBefore(blockstmt) and
n2.isBefore(blockstmt.getStmt(0))
or
not exists(blockstmt.getStmt(_)) and
n1.isBefore(blockstmt) and
n2.isAfter(blockstmt) and
not simpleLeafNode(blockstmt)
or
exists(int i |
n1.isAfter(blockstmt.getStmt(i)) and
n2.isBefore(blockstmt.getStmt(i + 1))
)
// the `isAfter(blockstmt.getLastStmt())` to `isAfter(blockstmt)` case is handled by `propagatesValue` above.
)
or
exists(IfStmt ifstmt |
n1.isBefore(ifstmt) and
n2.isBefore(ifstmt.getCondition())
@@ -1525,8 +1503,11 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
(
n1.isBefore(ast) and not exists(getRankedChild(ast, _)) and not simpleLeafNode(ast)
or
exists(int i |
n1.isAfter(getRankedChild(ast, i)) and not exists(getRankedChild(ast, i + 1))
exists(int i, AstNode last |
last = getRankedChild(ast, i) and
not exists(getRankedChild(ast, i + 1)) and
n1.isAfter(last) and
not propagatesValue(last, ast)
)
) and
(if postOrInOrder(ast) then n2.isIn(ast) else n2.isAfter(ast))