Skip to content

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jketema
Copy link
Contributor

@jketema jketema commented Jun 12, 2025

No description provided.

@jketema jketema changed the title C++: Use SEH exception edges in IR and generate SEH exception edges for calls in __try, __except, and __finally blocks C++: Use SEH exception edges in IR and generate SEH exception edges for calls in __try blocks Jun 13, 2025
@jketema jketema marked this pull request as ready for review June 13, 2025 18:52
@Copilot Copilot AI review requested due to automatic review settings June 13, 2025 18:52
@jketema jketema requested a review from a team as a code owner June 13, 2025 18:52
@jketema jketema requested a review from MathiasVP June 13, 2025 18:52
Copy link
Contributor

@Copilot Copilot AI left a 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 an ExceptionEdge parameter to various mayThrowException/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., in TranslatedFunctionCall) to prefer AlwaysSehThrowingFunction, 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) {
Copy link
Preview

Copilot AI Jun 13, 2025

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.

Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant