mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[AST] Introduce CaseStmt::createImplicit
This allows us to re-use the same logic to create the case body variables.
This commit is contained in:
@@ -222,10 +222,8 @@ deriveBodyCodingKey_enum_stringValue(AbstractFunctionDecl *strValDecl, void *) {
|
||||
auto *returnStmt = ReturnStmt::createImplicit(C, caseValue);
|
||||
auto *caseBody = BraceStmt::create(C, SourceLoc(), ASTNode(returnStmt),
|
||||
SourceLoc());
|
||||
cases.push_back(CaseStmt::create(C, CaseParentKind::Switch, SourceLoc(),
|
||||
labelItem, SourceLoc(), SourceLoc(),
|
||||
caseBody,
|
||||
/*case body var decls*/ std::nullopt));
|
||||
cases.push_back(CaseStmt::createImplicit(C, CaseParentKind::Switch,
|
||||
labelItem, caseBody));
|
||||
}
|
||||
|
||||
auto *selfRef = DerivedConformance::createSelfDeclRef(strValDecl);
|
||||
@@ -292,9 +290,8 @@ deriveBodyCodingKey_init_stringValue(AbstractFunctionDecl *initDecl, void *) {
|
||||
|
||||
auto *body = BraceStmt::create(C, SourceLoc(), ASTNode(assignment),
|
||||
SourceLoc());
|
||||
cases.push_back(CaseStmt::create(C, CaseParentKind::Switch, SourceLoc(),
|
||||
labelItem, SourceLoc(), SourceLoc(), body,
|
||||
/*case body var decls*/ std::nullopt));
|
||||
cases.push_back(
|
||||
CaseStmt::createImplicit(C, CaseParentKind::Switch, labelItem, body));
|
||||
}
|
||||
|
||||
auto *anyPat = AnyPattern::createImplicit(C);
|
||||
@@ -303,10 +300,8 @@ 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, CaseParentKind::Switch, SourceLoc(),
|
||||
dfltLabelItem, SourceLoc(), SourceLoc(),
|
||||
dfltBody,
|
||||
/*case body var decls*/ std::nullopt));
|
||||
cases.push_back(CaseStmt::createImplicit(C, CaseParentKind::Switch,
|
||||
dfltLabelItem, dfltBody));
|
||||
|
||||
auto *stringValueDecl = initDecl->getParameters()->get(0);
|
||||
auto *stringValueRef = new (C) DeclRefExpr(stringValueDecl, DeclNameLoc(),
|
||||
|
||||
Reference in New Issue
Block a user