Skip to content

[6.0][Macros] Fix column calculation in MacroExpansionContext for plugins #2657

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

Merged

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented May 17, 2024

Cherry-pick #2656 into release/6.0

rdar://128293478 (Source location column can be shifted by 1)

  • Explanation: When retrieving the location of a node at the first line, column calculation was incorrect. Diagnostics locations and MacroExpansionContext.location(of:at:filePathMode:) were often resulted wrong locations. Since column of PluginMessage.Syntax is 1-based, we need to -1 when using it as an offset.
  • Scope: Executable macro plugin expansion
  • Risk: Low. A simple and clear fix
  • Testing: Added an reproducing test case to Examples, and tested it locally.
  • Issue: rdar://128293478
  • Reviewer: Alex Hoppen (@ahoppen)

When retriving a location for a node at the first line, column
calculation was incorrect. 'column' of 'PluginMessage.Syntax' is
1-based, so we need to '-1' when using it as a offset.

(cherry picked from commit 9867998)
@rintaro rintaro requested review from ahoppen and bnbarham as code owners May 17, 2024 21:07
@rintaro
Copy link
Member Author

rintaro commented May 17, 2024

@swift-ci Please test

@rintaro rintaro merged commit 8a3386c into swiftlang:release/6.0 May 20, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants