Skip to content

Unified: Extract defer statements - #22704

Merged
paldepind merged 1 commit into
mainfrom
unified/swift-defer
Sep 30, 2026
Merged

paldepind merged 1 commit into
mainfrom
unified/swift-defer

Conversation

@paldepind

@paldepind paldepind commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Adds a defer statement to the common AST and extracts Swift defer statements into it.

@paldepind
paldepind marked this pull request as ready for review September 30, 2026 08:09
@paldepind
paldepind requested review from a team as code owners September 30, 2026 08:09
Copilot AI balanced review requested due to automatic review settings September 30, 2026 08:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Deferred bodies are currently modeled as executing immediately instead of at scope exit.

Review effort: Balanced
Findings: 1 High severity

Open (1)
What changed in this PR

Adds unified AST extraction for Swift defer statements.

Changes:

  • Defines and extracts defer_stmt.
  • Regenerates QL/schema artifacts and test expectations.
  • Updates control-flow slices, though defer execution semantics remain incorrect.
File Description
unified/​extractor/​ast_types.yml Defines the common defer node.
unified/​extractor/​src/​languages/​swift/​swift.rs Maps Swift defer statements.
unified/​extractor/​tests/​corpus/​swift/​control-flow/​defer-statement.output Updates generated corpus output.
unified/​ql/​lib/​unified.dbscheme Adds generated database relations.
unified/​ql/​lib/​codeql/​unified/​internal/​Ast.qll Adds the generated QL class.
unified/​ql/​test/​library-tests/​controlflow/​basicblock-slices.expected Updates generated control-flow expectations.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

- for_each_stmt
- while_stmt
- do_while_stmt
- defer_stmt

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm pretty sure we can do the accurate CFG later.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I've added this to the language feature backlog

@paldepind paldepind added the no-change-note-required This PR does not need a change note label Sep 30, 2026

@asgerf asgerf left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, just have to resolve the conflict

@paldepind

Copy link
Copy Markdown
Contributor Author

I've rebased and fixed the conflicts.

@paldepind
paldepind requested a review from asgerf September 30, 2026 12:21
@paldepind
paldepind merged commit a97c850 into main Sep 30, 2026
16 checks passed
@paldepind
paldepind deleted the unified/swift-defer branch September 30, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-required This PR does not need a change note Unified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants