C++: Use SEH exception edges in IR and generate SEH exception edges for calls in __try blocks#19746
C++: Use SEH exception edges in IR and generate SEH exception edges for calls in __try blocks#19746MathiasVP merged 7 commits intogithub:mainfrom
__try blocks#19746Conversation
__try, __except, and __finally blocks__try blocks
There was a problem hiding this comment.
Pull Request Overview
This PR shifts the IR’s exception modeling from generic “C++ Exception” edges to SEH-specific edges and extends QL IR translation to handle SEH exception edges for calls inside __try blocks.
- Updated test expectations to label and route SEH exception edges instead of “C++ Exception”
- Deprecated the old
ThrowingFunctioninterface and added anExceptionEdgeparameter to variousmayThrowException/mustThrowExceptionpredicates - Adjusted
TranslatedCall‐family QL classes to generate and propagate SEH edges
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| cpp/ql/test/library-tests/ir/ir/raw_ir.expected | Replaced “C++ Exception” markers with “SEH Exception” in IR dump |
| cpp/ql/test/library-tests/ir/ir/raw_consistency.expected | Removed outdated consistency checks for C++ exception edges |
| cpp/ql/test/library-tests/ir/ir/aliased_ir.expected | Updated aliased IR tests to expect SEH Exception markers |
| cpp/ql/lib/semmle/code/cpp/models/interfaces/Throwing.qll | Marked ThrowingFunction as deprecated |
| cpp/ql/lib/semmle/code/cpp/change-notes/2014-12-13-deprecate-throwing.md | Added deprecation note for ThrowingFunction |
| cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedFunction.qll | Adjusted call site to mayThrowException(_) |
| cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedExpr.qll | Updated mayThrowException/mustThrowException signatures |
| cpp/ql/lib/semmle/code/cpp/ir/implementation/raw/internal/TranslatedCall.qll | Refactored exception‐edge predicates to take ExceptionEdge |
Comments suppressed due to low confidence (1)
cpp/ql/lib/semmle/code/cpp/models/interfaces/Throwing.qll:18
- [nitpick] After deprecating
ThrowingFunction, update any references (e.g., inTranslatedFunctionCall) to preferAlwaysSehThrowingFunction, or clearly document when each should be used.
abstract deprecated class ThrowingFunction extends Function {
|
|
||
| final override predicate mayThrowException() { | ||
| expr.getTarget().(ThrowingFunction).mayThrowException(_) | ||
| final override predicate mayThrowException(ExceptionEdge e) { |
There was a problem hiding this comment.
The override for mayThrowException in TranslatedFunctionCall no longer delegates to ThrowingFunction for C++ exception edges. You should add a branch such as e instanceof CppExceptionEdge and expr.getTarget().(ThrowingFunction).mayThrowException(e) to restore C++ exception support.
There was a problem hiding this comment.
That's on purpose, Copilot.
Fix formatting while here.
| this.mustThrowException(e) | ||
| or | ||
| exists(MicrosoftTryStmt tryStmt | tryStmt.getStmt().getAChild*() = expr) and | ||
| exists(MicrosoftTryStmt tryStmt | tryStmt.getStmt() = expr.getEnclosingStmt().getParent*()) and |
No description provided.