Skip to content

Commit 500fdb8

Browse files
committed
Guards: Add support for assertions that exit rather than throw.
1 parent 72f1fe5 commit 500fdb8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

shared/controlflow/codeql/controlflow/Guards.qll

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ module Make<
297297
*/
298298
predicate isIntRange(int bound, boolean upper) { this = TIntRange(bound, upper) }
299299

300-
/** Holds if this value represents throwing an exception. */
300+
/** Holds if this value represents throwing an exception (or exiting). */
301301
predicate isThrowsException() { this = TException(true) }
302302

303303
/** Gets a textual representation of this value. */
@@ -368,12 +368,19 @@ module Make<
368368
e instanceof NonNullExpr and v.isNonNullValue()
369369
}
370370

371+
/** Holds if `t` is an exception-like successor type. */
372+
private predicate exceptionLike(SuccessorType t) {
373+
t instanceof ExceptionSuccessor or
374+
t instanceof ExitSuccessor
375+
}
376+
371377
private predicate exceptionBranchPoint(BasicBlock bb1, BasicBlock normalSucc, BasicBlock excSucc) {
372-
exists(SuccessorType norm, ExceptionSuccessor exc |
378+
exists(SuccessorType norm, SuccessorType exc |
373379
bb1.getASuccessor(norm) = normalSucc and
374380
bb1.getASuccessor(exc) = excSucc and
375381
normalSucc != excSucc and
376-
not norm instanceof ExceptionSuccessor
382+
exceptionLike(exc) and
383+
not exceptionLike(norm)
377384
)
378385
}
379386

0 commit comments

Comments
 (0)