[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:
Alex Hoppen
2021-04-20 20:29:36 +02:00
parent c8ba622532
commit aa69529809
7 changed files with 31 additions and 33 deletions

View File

@@ -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 };