mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[AST] Add method to create an implicit SwitchStmt
There are a number of occurances that create implicit `Switch`s by passing `SourceLoc()` for all location paramters. Refactor those occurances out to a separate `createImplicit` method that automatically fills the locations with invalid source locations.
This commit is contained in:
@@ -233,9 +233,8 @@ deriveBodyCodingKey_enum_stringValue(AbstractFunctionDecl *strValDecl, void *) {
|
||||
}
|
||||
|
||||
auto *selfRef = DerivedConformance::createSelfDeclRef(strValDecl);
|
||||
auto *switchStmt = SwitchStmt::create(LabeledStmtInfo(), SourceLoc(),
|
||||
selfRef, SourceLoc(), cases,
|
||||
SourceLoc(), SourceLoc(), C);
|
||||
auto *switchStmt =
|
||||
SwitchStmt::createImplicit(LabeledStmtInfo(), selfRef, cases, C);
|
||||
body = BraceStmt::create(C, SourceLoc(), ASTNode(switchStmt), SourceLoc());
|
||||
}
|
||||
|
||||
@@ -313,9 +312,8 @@ deriveBodyCodingKey_init_stringValue(AbstractFunctionDecl *initDecl, void *) {
|
||||
auto *stringValueDecl = initDecl->getParameters()->get(0);
|
||||
auto *stringValueRef = new (C) DeclRefExpr(stringValueDecl, DeclNameLoc(),
|
||||
/*Implicit=*/true);
|
||||
auto *switchStmt = SwitchStmt::create(LabeledStmtInfo(), SourceLoc(),
|
||||
stringValueRef, SourceLoc(), cases,
|
||||
SourceLoc(), SourceLoc(), C);
|
||||
auto *switchStmt =
|
||||
SwitchStmt::createImplicit(LabeledStmtInfo(), stringValueRef, cases, C);
|
||||
auto *body = BraceStmt::create(C, SourceLoc(), ASTNode(switchStmt),
|
||||
SourceLoc());
|
||||
return { body, /*isTypeChecked=*/false };
|
||||
|
||||
Reference in New Issue
Block a user