-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Declaration checker cleanups #15408
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
Declaration checker cleanups #15408
Conversation
@@ -480,6 +480,7 @@ class StmtChecker : public StmtVisitor<StmtChecker, Stmt*> { | |||
} | |||
|
|||
Stmt *visitDeferStmt(DeferStmt *DS) { | |||
TC.typeCheckDecl(DS->getTempDecl(), /*isFirstPass*/true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these are deliberately not doing two passes because they are local, as you said.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hoping to get rid of the two passes altogether, but even then if we make two passes over local declarations it shouldn't make much of a difference since it's doing the same amount of work in the end.
1e6844c
to
ddee48e
Compare
…e init The importer would only synthesize its own memberwise init if the declaration had a zero initializer, which supresses Sema's automatic synthesis. Trouble is we cannot rely on Sema synthesizing the memberwise init in case we deserialize declarations after type checking. Some other changes caught this with an assert, so fix the importer to do the right thing here.
This avoids emitting a diagnostic twice with a subsequent change.
The DeclChecker had three possible states: - IsFirstPass true, IsSecondPass false. This is the 'first pass' for declarations that appear at the top-level, or are nested inside top-level types. - IsFirstPass false, IsSecondPass true. This is the 'second pass' for declarations that appear at the top-level, or are nested inside top-level types. - IsFirstPass false, IsSecondPass false. This was used for (some) local declarations. This is unnecessarily confusing. We can eliminate the third state by calling typeCheckDecl() twice in a few places. This allows IsSecondPass to be removed entirely since it's now always equal to !IsFirstPass.
We're going to visit it later after we type check it anyway.
ddee48e
to
6caa7b3
Compare
6caa7b3
to
a6ff282
Compare
@swift-ci Please smoke test |
@swift-ci Please test source compatibility |
@swift-ci Please smoke test compiler performance |
It started failing after swiftlang#15408. SR-7255 rdar://38751453
This causes a failure on some bots and PR testing https://ci.swift.org/job/oss-swift-pr-test/1659/ I am disabling the test until you get a chance to look at it: #15421 |
The test run you linked doesn't show that test failing. Can you find one where it does? (The test you named has very little to do with this change.) |
I will revert the disabling commit again since it only failed once on one bot: #15426 |
Yeah, that's definitely weird but it's very unlikely to be this change's fault. |
That yet has been flaky in the past. It’s not related to these changes |
Inspired by a forum post by @davezarzycki: https://forums.swift.org/t/is-decl-semantic-checking-two-or-three-pass/11231:
typeCheckDecl()
no longer hasIsSecondPass
validateDecl()
no longer callstypeCheckDecl()
Removing
IsFirstPass
is a bit trickier.