-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
base: main
Are you sure you want to change the base?
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
ThrowingFunction
interface and added anExceptionEdge
parameter to variousmayThrowException
/mustThrowException
predicates - 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 {
@@ -362,16 +361,16 @@ class TranslatedFunctionCall extends TranslatedCallExpr, TranslatedDirectCall { | |||
not exists(MemberFunction func | expr.getTarget() = func and func.isStatic()) | |||
} | |||
|
|||
final override predicate mayThrowException() { | |||
expr.getTarget().(ThrowingFunction).mayThrowException(_) | |||
final override predicate mayThrowException(ExceptionEdge e) { |
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.
Copilot uses AI. Check for mistakes.
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.
No description provided.