mirror of
https://github.com/github/codeql.git
synced 2026-05-04 13:15:21 +02:00
CPP: Make Handlers always begin a BasicBlock.
This commit is contained in:
@@ -240,16 +240,15 @@ class BasicBlock extends ControlFlowNodeBase {
|
||||
|
||||
/**
|
||||
* Holds if control flow may reach this basic block from a function entry
|
||||
* point or a `catch` clause of a reachable `try` statement.
|
||||
* point or any handler of a reachable `try` statement.
|
||||
*/
|
||||
predicate isReachable() {
|
||||
exists(Function f | f.getBlock() = this)
|
||||
or
|
||||
exists(TryStmt t, BasicBlock tryblock |
|
||||
(
|
||||
this = t.getACatchClause() or
|
||||
this.(Handler).getTryStmt() = t
|
||||
) and
|
||||
// a `Handler` preceeds the `CatchBlock`, and is always the beginning
|
||||
// of a new `BasicBlock` (see `primitive_basic_block_entry_node`).
|
||||
this.(Handler).getTryStmt() = t and
|
||||
tryblock.isReachable() and
|
||||
tryblock.contains(t)
|
||||
) or
|
||||
|
||||
@@ -44,6 +44,14 @@ private cached module Cached {
|
||||
// that the node have at least one successor.
|
||||
or
|
||||
(not successors_extended(_, node) and successors_extended(node, _))
|
||||
|
||||
// An exception handler is always the start of a new basic block. We
|
||||
// don't generate edges for [possible] exceptions, but in practice control
|
||||
// flow could reach the handler from anywhere inside the try block that
|
||||
// could throw an exception of a corresponding type. A `Handler` usually
|
||||
// needs to be considered reachable (see also `BasicBlock.isReachable`).
|
||||
or
|
||||
node instanceof Handler
|
||||
}
|
||||
|
||||
/** Holds if `n2` follows `n1` in a `PrimitiveBasicBlock`. */
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
| exceptions.cpp:25:13:30:9 | ExprStmt |
|
||||
| exceptions.cpp:25:13:25:19 | ExprStmt |
|
||||
| exceptions.cpp:26:13:26:13 | ExprStmt |
|
||||
|
||||
Reference in New Issue
Block a user