[AST] Add some 'create' factory methods

This provides consistency with other AST nodes,
and will be useful for implementing ArgumentList
construction in the future.
This commit is contained in:
Hamish Knight
2021-07-28 23:14:44 +01:00
parent c70f280e4a
commit 72d4d9f1e9
12 changed files with 87 additions and 49 deletions

View File

@@ -856,8 +856,8 @@ deriveBodyEncodable_encode(AbstractFunctionDecl *encodeDecl, void *) {
auto *method = UnresolvedDeclRefExpr::createImplicit(C, C.Id_superEncoder);
// container.superEncoder()
auto *superEncoderRef = new (C) DotSyntaxCallExpr(containerExpr,
SourceLoc(), method);
auto *superEncoderRef =
DotSyntaxCallExpr::create(C, containerExpr, SourceLoc(), method);
// encode(to:) expr
auto *encodeDeclRef = new (C) DeclRefExpr(ConcreteDeclRef(encodeDecl),
@@ -868,8 +868,8 @@ deriveBodyEncodable_encode(AbstractFunctionDecl *encodeDecl, void *) {
SourceLoc(), /*Implicit=*/true);
// super.encode(to:)
auto *encodeCall = new (C) DotSyntaxCallExpr(superRef, SourceLoc(),
encodeDeclRef);
auto *encodeCall =
DotSyntaxCallExpr::create(C, superRef, SourceLoc(), encodeDeclRef);
// super.encode(to: container.superEncoder())
Expr *args[1] = {superEncoderRef};