mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[parse/sema] Give all case bodies their own var decls without using those var decls for anything.
This is a step in the direction of fixing the fallthrough bug. Specifically, in this commit I give case stmts a set of var decls for the bodies of the case statement. I have not wired them up to anything except the var decl list/typechecking. rdar://47467128
This commit is contained in:
@@ -235,9 +235,9 @@ deriveBodyCodingKey_enum_stringValue(AbstractFunctionDecl *strValDecl, void *) {
|
||||
auto *returnStmt = new (C) ReturnStmt(SourceLoc(), caseValue);
|
||||
auto *caseBody = BraceStmt::create(C, SourceLoc(), ASTNode(returnStmt),
|
||||
SourceLoc());
|
||||
cases.push_back(CaseStmt::create(C, SourceLoc(), labelItem,
|
||||
/*HasBoundDecls=*/false, SourceLoc(),
|
||||
SourceLoc(), caseBody));
|
||||
cases.push_back(CaseStmt::create(C, SourceLoc(), labelItem, SourceLoc(),
|
||||
SourceLoc(), caseBody,
|
||||
/*case body var decls*/ None));
|
||||
}
|
||||
|
||||
auto *selfRef = DerivedConformance::createSelfDeclRef(strValDecl);
|
||||
@@ -303,9 +303,9 @@ deriveBodyCodingKey_init_stringValue(AbstractFunctionDecl *initDecl, void *) {
|
||||
|
||||
auto *body = BraceStmt::create(C, SourceLoc(), ASTNode(assignment),
|
||||
SourceLoc());
|
||||
cases.push_back(CaseStmt::create(C, SourceLoc(), labelItem,
|
||||
/*HasBoundDecls=*/false, SourceLoc(),
|
||||
SourceLoc(), body));
|
||||
cases.push_back(CaseStmt::create(C, SourceLoc(), labelItem, SourceLoc(),
|
||||
SourceLoc(), body,
|
||||
/*case body var decls*/ None));
|
||||
}
|
||||
|
||||
auto *anyPat = new (C) AnyPattern(SourceLoc());
|
||||
@@ -315,9 +315,9 @@ deriveBodyCodingKey_init_stringValue(AbstractFunctionDecl *initDecl, void *) {
|
||||
auto *dfltReturnStmt = new (C) FailStmt(SourceLoc(), SourceLoc());
|
||||
auto *dfltBody = BraceStmt::create(C, SourceLoc(), ASTNode(dfltReturnStmt),
|
||||
SourceLoc());
|
||||
cases.push_back(CaseStmt::create(C, SourceLoc(), dfltLabelItem,
|
||||
/*HasBoundDecls=*/false, SourceLoc(),
|
||||
SourceLoc(), dfltBody));
|
||||
cases.push_back(CaseStmt::create(C, SourceLoc(), dfltLabelItem, SourceLoc(),
|
||||
SourceLoc(), dfltBody,
|
||||
/*case body var decls*/ None));
|
||||
|
||||
auto *stringValueDecl = initDecl->getParameters()->get(0);
|
||||
auto *stringValueRef = new (C) DeclRefExpr(stringValueDecl, DeclNameLoc(),
|
||||
|
||||
Reference in New Issue
Block a user