Skip to content

[6.0] [Coverage] Avoid recording regions from macro expansions #74119

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 4 commits into from
Jun 4, 2024

Conversation

hamishknight
Copy link
Contributor

6.0 cherry-pick of #74067

  • Explanation: Fixes an issue that could cause invalid coverage regions to be emitted for macro expansions in a non-asserts compiler, and a crash for an asserts compiler
  • Scope: Affects code coverage for macros
  • Issue: rdar://129081384
  • Risk: Low, the change has been run over the source compat suite with coverage enabled
  • Testing: Added tests to test suite
  • Reviewer: Alex Hoppen

Saves having to pass it as a parameter to
`emitSourceRegions`.
Ignore any regions recorded while inside a macro
expansion, but account for any control flow that
may have happened such that the exit count is
correctly adjusted. This allows e.g throwing function
calls to behave correctly within the expansion.

rdar://129081384
These replace the body of the function, and as such
shouldn't be profiled.
Make sure we walk macro expansion decls to handle
cases where e.g a binding introduces control flow.
This should be a pretty uncommon case since bindings
introduced by macros aren't actually usable when
expanded in local contexts, but handle it all the
same.
@hamishknight hamishknight added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.0 labels Jun 4, 2024
@hamishknight hamishknight requested a review from bnbarham June 4, 2024 18:00
@hamishknight hamishknight requested a review from a team as a code owner June 4, 2024 18:00
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight enabled auto-merge June 4, 2024 21:33
@hamishknight hamishknight merged commit 0c97e28 into swiftlang:release/6.0 Jun 4, 2024
5 checks passed
@hamishknight hamishknight deleted the macroscope-6.0 branch June 5, 2024 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants