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
Coverage: fix handling of constructors and top-level decls (SR-7446) #15966
Conversation
We need to instrument constructor initializers, instead of the delegating constructors which just call them. rdar://39460313
This scheme of using a designated constructor for profiling purposes is a bit brittle. One concrete issue with this is that swift ends up attempting to create distinct SILProfilers for different constructors of a nominal type, and stored property initializers we want coverage for may not be emitted in the designated constructor. A simpler idea is to store a map from nominal types to SILProfilers, and to then create a single merged profiler instance for all constructors of a nominal type. |
9144c55
to
09f9207
Compare
@swift-ci test and merge |
1 similar comment
@swift-ci test and merge |
…zers This fixes coverage reporting for member initializers and cuts down on repeated AST traversals of pattern bindings within nominal type decls. This allows us to remove some defensive heuristic code which dealt with closures and if-exprs within member initializers.
09f9207
to
9fa0c85
Compare
@swift-ci smoke test and merge |
1 similar comment
@swift-ci smoke test and merge |
…pple#15966) * [Coverage] Instrument constructor initializers (SR-7446) We need to instrument constructor initializers, instead of the delegating constructors which just call them. rdar://39460313 * [Coverage] Remove dead code, NFC * [Coverage] Use a shared profiler for constructors and member initializers This fixes coverage reporting for member initializers and cuts down on repeated AST traversals of pattern bindings within nominal type decls. This allows us to remove some defensive heuristic code which dealt with closures and if-exprs within member initializers. (cherry picked from commit 8a003a4)
@vedantk What if a type has multiple designated initializers? |
Also unrelated, this caused a failure in the ASAN bot:
|
@slavapestov If a type has multiple designated initializers, coverage for each should be reported separately (each constructor decl is visited). I'm taking a look at the asan failure now. |
Here's a PR to address the asan issue: #16012 |
Instrument constructor initializers, instead of the delegating constructors which just call them.
Once that's done, make sure that a parent region is available inside of member initializers and top-level code decls. This fixes a reporting bug for if-exprs by getting rid of the RegionStack.empty() case.
Remove some defensive heuristic code which dealt with closures and if-exprs within member initializers.