Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[6.2][Macros] Don't include attr range when checking macro definition #81357

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

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented May 7, 2025

Cherry-pick #81346 into release/6.2

  • Explanation: For macro definition checking, we use the range of the macro declaration and re-parse it with SwiftParser. Previously it uses the range including the attributes, but that can result invalid code because the attribute can be in a #if ... #endif region. Since we don't use attributes for checking the definition, just use the range without the attributes instead.
  • Scope: Macros
  • Risk: Low. The change is simple enough
  • Testing: Added a regression test case
  • Issues: rdar://150805795
  • Reviewer: Stuart Montgomery (@stmontgomery)

For macro definition checking, we use the range of the `macro`
declaration and re-parse it with `SwiftParser`. Previously it uses the
range including the attributes, but that can result invalid code because
the attribute can be in a `#if ... #endif` region.

Since we don't use attributes for checking the definition, just use the
range without the attributes instead.

rdar://150805795
(cherry picked from commit 8519e71)
@rintaro rintaro requested a review from a team as a code owner May 7, 2025 16:33
@rintaro
Copy link
Member Author

rintaro commented May 7, 2025

@swift-ci Please test

Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

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

CC @DougGregor in case you know of a reason we were including attributes here. But as far as we can tell they end up being unused.

@rintaro rintaro enabled auto-merge May 7, 2025 21:17
@rintaro rintaro merged commit 5625db5 into swiftlang:release/6.2 May 8, 2025
5 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