FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Unified: Extract Swift macro calls by paldepind · Pull Request #22740 · github/codeql · GitHub

Repository navigation

Unified: Extract Swift macro calls - #22740

Open
paldepind wants to merge 3 commits into
mainfrom
unified/swift-macro
Open

paldepind wants to merge 3 commits into
mainfrom
unified/swift-macro

Conversation

Copy link
Copy Markdown
Contributor

This PR adds a new macro call expr to the AST and translates Swift's freestanding macro calls into it.

In Swift the arguments to a function are guaranteed to be valid Swift syntax, so we simply process all the arguments recursively and includes the result as arguments to the macro.

final F::Identifier getMacroNameNode() { unified_macro_call_expr_def(this, result) }

/** Gets the node corresponding to the field `type_argument`. */
final F::Expr getTypeArgument(int i) { unified_macro_call_expr_type_argument(this, i, result) }
paldepind marked this pull request as ready for review October 2, 2026 07:42
paldepind requested review from a team as code owners October 2, 2026 07:43
Copilot AI balanced review requested due to automatic review settings October 2, 2026 07:43
paldepind added the no-change-note-required This PR does not need a change note label Oct 2, 2026

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Copilot review overview

🟡 Changes recommended

The mapping drops Swift module qualifiers and incorrectly classifies compiler-provided expressions as macro calls.

Review effort: Balanced
Findings: 2

Open (2) What changed in this PR

Adds Swift freestanding macro expansion support to the Unified AST.

Changes:

  • Introduces macro_call_expr and generated QL/schema APIs.
  • Translates macro names, type arguments, arguments, and trailing closures.
  • Adds Swift corpus coverage and updates #line extraction.
File Description
unified/​extractor/​ast_types.yml Defines the macro-call AST shape.
unified/​extractor/​src/​languages/​swift/​swift.rs Maps Swift macro expansions.
unified/​extractor/​tests/​corpus/​swift/​expressions/​freestanding-macro-expansions.swift Adds macro syntax fixtures.
unified/​extractor/​tests/​corpus/​swift/​expressions/​freestanding-macro-expansions.output Records expected macro ASTs.
unified/​extractor/​tests/​corpus/​swift/​literals/​line-magic-literal.output Reclassifies #line.
unified/​ql/​lib/​unified.dbscheme Adds generated database relations.
unified/​ql/​lib/​codeql/​unified/​internal/​Ast.qll Adds generated QL classes and accessors.

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

(argument name_node: (identifier #{label}) value: {closure})
),
rule!(
(macroExpansionExpr

paldepind Oct 2, 2026 •
edited
Loading

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think handling these as macro calls might be just fine. And if not we can always tweak later.

Comment on lines +724 to +725
macroName: @@name
genericArgumentClause: (genericArgumentClause arguments: (genericArgument argument: @type_args)*)?

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We're not handling moduleSelector anywhere yet, so this is consistent.

paldepind requested a review from asgerf October 7, 2026 06:45

This branch has not been deployed

No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL