Skip to content

Commit b326ed8

Browse files
authored
Merge pull request #22317 from aschackmull/cfg/ruby-tweaks
Cfg: A few minor tweaks in preparation for Ruby
2 parents faf6280 + 5ffb8ec commit b326ed8

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

shared/controlflow/codeql/controlflow/ControlFlowGraph.qll

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,14 +1269,20 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
12691269
result = block.(Switch).getStmt(_)
12701270
}
12711271

1272+
private predicate callableHasParamDefault(Callable c, Expr defaultValue) {
1273+
exists(Parameter p | p.getDefaultValue() = defaultValue and c = getEnclosingCallable(p))
1274+
}
1275+
12721276
/**
12731277
* Holds if an abrupt completion `c` from within `ast` is caught with
12741278
* flow continuing at `n`.
12751279
*/
12761280
private predicate endAbruptCompletion(AstNode ast, PreControlFlowNode n, AbruptCompletion c) {
12771281
Input2::endAbruptCompletion(ast, n, c)
12781282
or
1279-
exists(Callable callable | callableHasBodyPart(callable, ast) |
1283+
exists(Callable callable |
1284+
callableHasBodyPart(callable, ast) or callableHasParamDefault(callable, ast)
1285+
|
12801286
c.getSuccessorType() instanceof ReturnSuccessor and
12811287
n.(NormalExitNodeImpl).getEnclosingCallable() = callable
12821288
or
@@ -1737,6 +1743,10 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
17371743
not exists(trystmt.getFinally()) and beforeFinally.isAfter(trystmt)
17381744
)
17391745
|
1746+
not exists(trystmt.getBody(_)) and
1747+
n1.isBefore(trystmt) and
1748+
n2 = beforeElse
1749+
or
17401750
exists(int i |
17411751
n1.isAfter(trystmt.getBody(i)) and
17421752
not exists(trystmt.getBody(i + 1)) and

0 commit comments

Comments
 (0)