Skip to content

[Parse] Handle #if in brace skipping logic #74559

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
merged 2 commits into from
Jun 21, 2024

Conversation

hamishknight
Copy link
Contributor

Previously we would strictly match { + }, but that ignored the fact that when parsing we consider #if + #endif to be a stronger delimiter than { + }, so can ignore a stray } in a #if. Update the logic to also track opening and closing #if decls, ignoring any braces that happen within them.

rdar://129195380

Previously we would only diagnose and recover for
invalid tokens following a `#if` body for the decl
and postfix expression case. Sink this logic into
`parseIfConfigRaw`, ensuring that we do this for
all `#if` cases. This requires propagating the
context we're parsing in to customize the
diagnostic.
Previously we would strictly match `{` + `}`, but
that ignored the fact that when parsing we consider
`#if` + `#endif` to be a stronger delimiter than
`{` + `}`, so can ignore a stray `}` in a `#if`.
Update the logic to also track opening and closing
`#if` decls, ignoring any braces that happen within
them.

rdar://129195380
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please SourceKit stress test

@hamishknight hamishknight merged commit 2fbc8b3 into swiftlang:main Jun 21, 2024
6 checks passed
@hamishknight hamishknight deleted the pound-if-skip branch June 21, 2024 14:04
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