Skip to content

Commit 245b727

Browse files
committed
Guards: Add support for assertions that exit rather than throw.
1 parent 727bdde commit 245b727

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. */
@@ -362,12 +362,19 @@ module Make<
362362
v.asConstantValue() = c.asConstantValue()
363363
}
364364

365+
/** Holds if `t` is an exception-like successor type. */
366+
private predicate exceptionLike(SuccessorType t) {
367+
t instanceof ExceptionSuccessor or
368+
t instanceof ExitSuccessor
369+
}
370+
365371
private predicate exceptionBranchPoint(BasicBlock bb1, BasicBlock normalSucc, BasicBlock excSucc) {
366-
exists(SuccessorType norm, ExceptionSuccessor exc |
372+
exists(SuccessorType norm, SuccessorType exc |
367373
bb1.getASuccessor(norm) = normalSucc and
368374
bb1.getASuccessor(exc) = excSucc and
369375
normalSucc != excSucc and
370-
not norm instanceof ExceptionSuccessor
376+
exceptionLike(exc) and
377+
not exceptionLike(norm)
371378
)
372379
}
373380

0 commit comments

Comments
 (0)