Skip to content

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 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 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 {


final override predicate mayThrowException() {
expr.getTarget().(ThrowingFunction).mayThrowException(_)
final override predicate mayThrowException(ExceptionEdge e) {
Copy link

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.

Copy link
Contributor

@MathiasVP MathiasVP left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! 🚀

@MathiasVP MathiasVP merged commit 3d9d9fe into github:main Jun 16, 2025
15 checks passed
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.

2 participants