Skip to content

Commit 1dff900

Browse files
committed
C#: Speed up throwMayBeUncaught() by not relying on definitelyHandles()
The `definitelyHandles()` predicate calculates the relation for all exception types, not just the ones that can actually be thrown (no automatic magic). This commit inlines the definition of `definitelyHandles()` to get the proper context (manual magic).
1 parent 4684bc9 commit 1dff900

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

csharp/ql/src/semmle/code/csharp/controlflow/ControlFlowGraph.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,13 @@ module Internal {
17141714
exists(TryStmt ts |
17151715
ts = last.getTryStmt() and
17161716
exists(lastTryStmtBlock(ts, c)) and
1717-
not ts.definitelyHandles(c.getExceptionClass(), _) and
1717+
not ts.getACatchClause() instanceof GeneralCatchClause and
1718+
forall(SpecificCatchClause scc |
1719+
scc = ts.getACatchClause() |
1720+
scc.hasFilterClause()
1721+
or
1722+
not c.getExceptionClass().getABaseType*() = scc.getCaughtExceptionType()
1723+
) and
17181724
last.isLast()
17191725
)
17201726
}

0 commit comments

Comments
 (0)