-
Notifications
You must be signed in to change notification settings - Fork 1.9k
C++: Use SEH exception edges in IR and generate SEH exception edges for calls in __try blocks
#19746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
__try, __except, and __finally blocks__try blocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) { |
Copilot
AI
Jun 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's on purpose, Copilot.
Fix formatting while here.
MathiasVP
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
| this.mustThrowException(e) | ||
| or | ||
| exists(MicrosoftTryStmt tryStmt | tryStmt.getStmt().getAChild*() = expr) and | ||
| exists(MicrosoftTryStmt tryStmt | tryStmt.getStmt() = expr.getEnclosingStmt().getParent*()) and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! 🚀
No description provided.