From bbefff63a34c76362630a2a2082a37d838e037cf Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Sat, 12 Dec 2020 11:58:44 +0000 Subject: [PATCH] ast: Remove statement constructors that don't take a Source Parsers need fixing up. Bug: tint:396 Bug: tint:390 Change-Id: I137f1017ca56125cf3d52ecbef2ff46d0574338b Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35161 Commit-Queue: Ben Clayton Reviewed-by: dan sinclair --- src/ast/assignment_statement.cc | 3 - src/ast/assignment_statement.h | 4 - src/ast/assignment_statement_test.cc | 16 +- src/ast/block_statement.cc | 2 - src/ast/block_statement.h | 2 - src/ast/block_statement_test.cc | 33 +++-- src/ast/break_statement.cc | 2 - src/ast/break_statement.h | 2 - src/ast/break_statement_test.cc | 6 +- src/ast/call_statement.cc | 6 +- src/ast/call_statement.h | 3 +- src/ast/call_statement_test.cc | 10 +- src/ast/case_statement.cc | 5 - src/ast/case_statement.h | 8 - src/ast/case_statement_test.cc | 67 +++++---- src/ast/continue_statement.cc | 2 - src/ast/continue_statement.h | 2 - src/ast/continue_statement_test.cc | 6 +- src/ast/discard_statement.cc | 2 - src/ast/discard_statement.h | 2 - src/ast/discard_statement_test.cc | 8 +- src/ast/else_statement.cc | 8 - src/ast/else_statement.h | 11 -- src/ast/else_statement_test.cc | 50 ++++--- src/ast/fallthrough_statement.cc | 2 - src/ast/fallthrough_statement.h | 2 - src/ast/fallthrough_statement_test.cc | 8 +- src/ast/function_test.cc | 61 ++++---- src/ast/if_statement_test.cc | 99 +++++++------ src/ast/loop_statement.cc | 3 - src/ast/loop_statement.h | 4 - src/ast/loop_statement_test.cc | 120 +++++++-------- src/ast/module_test.cc | 12 +- src/ast/statement.cc | 2 - src/ast/statement.h | 2 - src/ast/switch_statement.cc | 3 - src/ast/switch_statement.h | 4 - src/ast/switch_statement_test.cc | 44 +++--- src/ast/variable_decl_statement.cc | 3 - src/ast/variable_decl_statement.h | 3 - src/ast/variable_decl_statement_test.cc | 12 +- src/inspector/inspector_test.cc | 64 ++++---- src/reader/spirv/function.cc | 89 ++++++----- src/reader/wgsl/parser_impl.cc | 19 +-- src/transform/bound_array_accessors_test.cc | 4 +- src/transform/emit_vertex_point_size.cc | 6 +- src/transform/emit_vertex_point_size_test.cc | 4 +- src/transform/first_index_offset.cc | 2 +- src/transform/first_index_offset_test.cc | 2 +- src/transform/vertex_pulling.cc | 23 +-- src/transform/vertex_pulling_test.cc | 4 +- src/type_determiner_test.cc | 136 ++++++++++------- src/validator/validator_control_block_test.cc | 139 ++++++++++-------- src/validator/validator_function_test.cc | 40 ++--- src/validator/validator_test.cc | 56 +++---- src/validator/validator_type_test.cc | 2 +- src/writer/hlsl/generator_impl_assign_test.cc | 2 +- src/writer/hlsl/generator_impl_binary_test.cc | 40 ++--- src/writer/hlsl/generator_impl_block_test.cc | 8 +- src/writer/hlsl/generator_impl_break_test.cc | 2 +- src/writer/hlsl/generator_impl_call_test.cc | 24 +-- src/writer/hlsl/generator_impl_case_test.cc | 26 ++-- .../hlsl/generator_impl_continue_test.cc | 2 +- .../hlsl/generator_impl_discard_test.cc | 2 +- ...tor_impl_function_entry_point_data_test.cc | 27 +++- .../hlsl/generator_impl_function_test.cc | 81 +++++----- src/writer/hlsl/generator_impl_if_test.cc | 37 ++--- src/writer/hlsl/generator_impl_loop_test.cc | 41 +++--- .../generator_impl_member_accessor_test.cc | 16 +- src/writer/hlsl/generator_impl_switch_test.cc | 15 +- src/writer/hlsl/generator_impl_test.cc | 7 +- ...rator_impl_variable_decl_statement_test.cc | 16 +- src/writer/msl/generator_impl_assign_test.cc | 2 +- src/writer/msl/generator_impl_block_test.cc | 8 +- src/writer/msl/generator_impl_break_test.cc | 2 +- src/writer/msl/generator_impl_call_test.cc | 24 +-- src/writer/msl/generator_impl_case_test.cc | 26 ++-- .../msl/generator_impl_continue_test.cc | 2 +- src/writer/msl/generator_impl_discard_test.cc | 2 +- ...tor_impl_function_entry_point_data_test.cc | 27 +++- .../msl/generator_impl_function_test.cc | 77 +++++----- src/writer/msl/generator_impl_if_test.cc | 37 ++--- src/writer/msl/generator_impl_loop_test.cc | 41 +++--- src/writer/msl/generator_impl_switch_test.cc | 15 +- src/writer/msl/generator_impl_test.cc | 2 +- ...rator_impl_variable_decl_statement_test.cc | 18 +-- .../spirv/builder_accessor_expression_test.cc | 4 +- src/writer/spirv/builder_assign_test.cc | 14 +- src/writer/spirv/builder_block_test.cc | 9 +- src/writer/spirv/builder_call_test.cc | 19 +-- src/writer/spirv/builder_discard_test.cc | 2 +- .../spirv/builder_function_decoration_test.cc | 21 +-- src/writer/spirv/builder_function_test.cc | 28 ++-- src/writer/spirv/builder_if_test.cc | 97 +++++++----- src/writer/spirv/builder_intrinsic_test.cc | 58 ++++---- src/writer/spirv/builder_loop_test.cc | 52 ++++--- src/writer/spirv/builder_switch_test.cc | 106 ++++++++----- src/writer/wgsl/generator_impl_assign_test.cc | 2 +- src/writer/wgsl/generator_impl_block_test.cc | 8 +- src/writer/wgsl/generator_impl_break_test.cc | 2 +- src/writer/wgsl/generator_impl_call_test.cc | 3 +- src/writer/wgsl/generator_impl_case_test.cc | 18 +-- .../wgsl/generator_impl_continue_test.cc | 2 +- .../wgsl/generator_impl_discard_test.cc | 2 +- .../wgsl/generator_impl_fallthrough_test.cc | 2 +- .../wgsl/generator_impl_function_test.cc | 28 ++-- src/writer/wgsl/generator_impl_if_test.cc | 53 +++---- src/writer/wgsl/generator_impl_loop_test.cc | 16 +- src/writer/wgsl/generator_impl_switch_test.cc | 15 +- src/writer/wgsl/generator_impl_test.cc | 2 +- ...rator_impl_variable_decl_statement_test.cc | 6 +- 111 files changed, 1287 insertions(+), 1145 deletions(-) diff --git a/src/ast/assignment_statement.cc b/src/ast/assignment_statement.cc index 67d0b3067a..4561263fda 100644 --- a/src/ast/assignment_statement.cc +++ b/src/ast/assignment_statement.cc @@ -22,9 +22,6 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::AssignmentStatement); namespace tint { namespace ast { -AssignmentStatement::AssignmentStatement(Expression* lhs, Expression* rhs) - : Base(), lhs_(lhs), rhs_(rhs) {} - AssignmentStatement::AssignmentStatement(const Source& source, Expression* lhs, Expression* rhs) diff --git a/src/ast/assignment_statement.h b/src/ast/assignment_statement.h index 558ae426f9..a91b0000ae 100644 --- a/src/ast/assignment_statement.h +++ b/src/ast/assignment_statement.h @@ -28,10 +28,6 @@ namespace ast { /// An assignment statement class AssignmentStatement : public Castable { public: - /// Constructor - /// @param lhs the left side of the expression - /// @param rhs the right side of the expression - AssignmentStatement(Expression* lhs, Expression* rhs); /// Constructor /// @param source the assignment statement source /// @param lhs the left side of the expression diff --git a/src/ast/assignment_statement_test.cc b/src/ast/assignment_statement_test.cc index 5cb5954948..951e32c148 100644 --- a/src/ast/assignment_statement_test.cc +++ b/src/ast/assignment_statement_test.cc @@ -29,7 +29,7 @@ TEST_F(AssignmentStatementTest, Creation) { auto* rhs = create(Source{}, mod.RegisterSymbol("rhs"), "rhs"); - AssignmentStatement stmt(lhs, rhs); + AssignmentStatement stmt(Source{}, lhs, rhs); EXPECT_EQ(stmt.lhs(), lhs); EXPECT_EQ(stmt.rhs(), rhs); } @@ -52,7 +52,7 @@ TEST_F(AssignmentStatementTest, IsAssign) { auto* rhs = create(Source{}, mod.RegisterSymbol("rhs"), "rhs"); - AssignmentStatement stmt(lhs, rhs); + AssignmentStatement stmt(Source{}, lhs, rhs); EXPECT_TRUE(stmt.Is()); } @@ -62,7 +62,7 @@ TEST_F(AssignmentStatementTest, IsValid) { auto* rhs = create(Source{}, mod.RegisterSymbol("rhs"), "rhs"); - AssignmentStatement stmt(lhs, rhs); + AssignmentStatement stmt(Source{}, lhs, rhs); EXPECT_TRUE(stmt.IsValid()); } @@ -70,7 +70,7 @@ TEST_F(AssignmentStatementTest, IsValid_MissingLHS) { auto* rhs = create(Source{}, mod.RegisterSymbol("rhs"), "rhs"); - AssignmentStatement stmt(nullptr, rhs); + AssignmentStatement stmt(Source{}, nullptr, rhs); EXPECT_FALSE(stmt.IsValid()); } @@ -78,7 +78,7 @@ TEST_F(AssignmentStatementTest, IsValid_MissingRHS) { auto* lhs = create(Source{}, mod.RegisterSymbol("lhs"), "lhs"); - AssignmentStatement stmt(lhs, nullptr); + AssignmentStatement stmt(Source{}, lhs, nullptr); EXPECT_FALSE(stmt.IsValid()); } @@ -87,7 +87,7 @@ TEST_F(AssignmentStatementTest, IsValid_InvalidLHS) { create(Source{}, mod.RegisterSymbol(""), ""); auto* rhs = create(Source{}, mod.RegisterSymbol("rhs"), "rhs"); - AssignmentStatement stmt(lhs, rhs); + AssignmentStatement stmt(Source{}, lhs, rhs); EXPECT_FALSE(stmt.IsValid()); } @@ -96,7 +96,7 @@ TEST_F(AssignmentStatementTest, IsValid_InvalidRHS) { create(Source{}, mod.RegisterSymbol("lhs"), "lhs"); auto* rhs = create(Source{}, mod.RegisterSymbol(""), ""); - AssignmentStatement stmt(lhs, rhs); + AssignmentStatement stmt(Source{}, lhs, rhs); EXPECT_FALSE(stmt.IsValid()); } @@ -106,7 +106,7 @@ TEST_F(AssignmentStatementTest, ToStr) { auto* rhs = create(Source{}, mod.RegisterSymbol("rhs"), "rhs"); - AssignmentStatement stmt(lhs, rhs); + AssignmentStatement stmt(Source{}, lhs, rhs); std::ostringstream out; stmt.to_str(out, 2); diff --git a/src/ast/block_statement.cc b/src/ast/block_statement.cc index a851e37263..b0e5f4b3db 100644 --- a/src/ast/block_statement.cc +++ b/src/ast/block_statement.cc @@ -22,8 +22,6 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::BlockStatement); namespace tint { namespace ast { -BlockStatement::BlockStatement() : Base() {} - BlockStatement::BlockStatement(const Source& source) : Base(source) {} BlockStatement::BlockStatement(BlockStatement&&) = default; diff --git a/src/ast/block_statement.h b/src/ast/block_statement.h index 95290f9ff6..faa7aaa14f 100644 --- a/src/ast/block_statement.h +++ b/src/ast/block_statement.h @@ -27,8 +27,6 @@ namespace ast { /// A block statement class BlockStatement : public Castable { public: - /// Constructor - BlockStatement(); /// Constructor /// @param source the block statement source explicit BlockStatement(const Source& source); diff --git a/src/ast/block_statement_test.cc b/src/ast/block_statement_test.cc index fc2cb92364..086931ca28 100644 --- a/src/ast/block_statement_test.cc +++ b/src/ast/block_statement_test.cc @@ -28,10 +28,10 @@ namespace { using BlockStatementTest = TestHelper; TEST_F(BlockStatementTest, Creation) { - auto* d = create(); + auto* d = create(Source{}); auto* ptr = d; - BlockStatement b; + BlockStatement b(Source{}); b.append(d); ASSERT_EQ(b.size(), 1u); @@ -39,11 +39,11 @@ TEST_F(BlockStatementTest, Creation) { } TEST_F(BlockStatementTest, Creation_WithInsert) { - auto* s1 = create(); - auto* s2 = create(); - auto* s3 = create(); + auto* s1 = create(Source{}); + auto* s2 = create(Source{}); + auto* s3 = create(Source{}); - BlockStatement b; + BlockStatement b(Source{}); b.insert(0, s1); b.insert(0, s2); b.insert(1, s3); @@ -64,38 +64,39 @@ TEST_F(BlockStatementTest, Creation_WithSource) { } TEST_F(BlockStatementTest, IsBlock) { - BlockStatement b; + BlockStatement b(Source{}); EXPECT_TRUE(b.Is()); } TEST_F(BlockStatementTest, IsValid) { - BlockStatement b; - b.append(create()); + BlockStatement b(Source{}); + b.append(create(Source{})); EXPECT_TRUE(b.IsValid()); } TEST_F(BlockStatementTest, IsValid_Empty) { - BlockStatement b; + BlockStatement b(Source{}); EXPECT_TRUE(b.IsValid()); } TEST_F(BlockStatementTest, IsValid_NullBodyStatement) { - BlockStatement b; - b.append(create()); + BlockStatement b(Source{}); + b.append(create(Source{})); b.append(nullptr); EXPECT_FALSE(b.IsValid()); } TEST_F(BlockStatementTest, IsValid_InvalidBodyStatement) { - BlockStatement b; - b.append(create(Source{}, nullptr, create(), + BlockStatement b(Source{}); + b.append(create(Source{}, nullptr, + create(Source{}), ElseStatementList{})); EXPECT_FALSE(b.IsValid()); } TEST_F(BlockStatementTest, ToStr) { - BlockStatement b; - b.append(create()); + BlockStatement b(Source{}); + b.append(create(Source{})); std::ostringstream out; b.to_str(out, 2); diff --git a/src/ast/break_statement.cc b/src/ast/break_statement.cc index 1affc2790b..eba613e401 100644 --- a/src/ast/break_statement.cc +++ b/src/ast/break_statement.cc @@ -22,8 +22,6 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::BreakStatement); namespace tint { namespace ast { -BreakStatement::BreakStatement() : Base() {} - BreakStatement::BreakStatement(const Source& source) : Base(source) {} BreakStatement::BreakStatement(BreakStatement&&) = default; diff --git a/src/ast/break_statement.h b/src/ast/break_statement.h index 83d902eb4c..7c9bd917a2 100644 --- a/src/ast/break_statement.h +++ b/src/ast/break_statement.h @@ -23,8 +23,6 @@ namespace ast { /// An break statement class BreakStatement : public Castable { public: - /// Constructor - BreakStatement(); /// Constructor /// @param source the break statement source explicit BreakStatement(const Source& source); diff --git a/src/ast/break_statement_test.cc b/src/ast/break_statement_test.cc index 802134894a..27a7a8f3e0 100644 --- a/src/ast/break_statement_test.cc +++ b/src/ast/break_statement_test.cc @@ -30,17 +30,17 @@ TEST_F(BreakStatementTest, Creation_WithSource) { } TEST_F(BreakStatementTest, IsBreak) { - BreakStatement stmt; + BreakStatement stmt(Source{}); EXPECT_TRUE(stmt.Is()); } TEST_F(BreakStatementTest, IsValid) { - BreakStatement stmt; + BreakStatement stmt(Source{}); EXPECT_TRUE(stmt.IsValid()); } TEST_F(BreakStatementTest, ToStr) { - BreakStatement stmt; + BreakStatement stmt(Source{}); std::ostringstream out; stmt.to_str(out, 2); EXPECT_EQ(out.str(), R"( Break{} diff --git a/src/ast/call_statement.cc b/src/ast/call_statement.cc index d74df3dff5..43670f78fe 100644 --- a/src/ast/call_statement.cc +++ b/src/ast/call_statement.cc @@ -23,14 +23,16 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::CallStatement); namespace tint { namespace ast { -CallStatement::CallStatement(CallExpression* call) : Base(), call_(call) {} +CallStatement::CallStatement(const Source& source, CallExpression* call) + : Base(source), call_(call) {} CallStatement::CallStatement(CallStatement&&) = default; CallStatement::~CallStatement() = default; CallStatement* CallStatement::Clone(CloneContext* ctx) const { - return ctx->mod->create(ctx->Clone(call_)); + return ctx->mod->create(ctx->Clone(source()), + ctx->Clone(call_)); } bool CallStatement::IsValid() const { diff --git a/src/ast/call_statement.h b/src/ast/call_statement.h index 2af758258d..59f7bed14b 100644 --- a/src/ast/call_statement.h +++ b/src/ast/call_statement.h @@ -28,8 +28,9 @@ namespace ast { class CallStatement : public Castable { public: /// Constructor + /// @param source the input source for the statement /// @param call the function - explicit CallStatement(CallExpression* call); + CallStatement(const Source& source, CallExpression* call); /// Move constructor CallStatement(CallStatement&&); ~CallStatement() override; diff --git a/src/ast/call_statement_test.cc b/src/ast/call_statement_test.cc index dae79dc442..b6fcee2a0d 100644 --- a/src/ast/call_statement_test.cc +++ b/src/ast/call_statement_test.cc @@ -31,17 +31,18 @@ TEST_F(CallStatementTest, Creation) { Source{}, mod.RegisterSymbol("func"), "func"), ExpressionList{}); - CallStatement c(expr); + CallStatement c(Source{}, expr); EXPECT_EQ(c.expr(), expr); } TEST_F(CallStatementTest, IsCall) { - CallStatement c(nullptr); + CallStatement c(Source{}, nullptr); EXPECT_TRUE(c.Is()); } TEST_F(CallStatementTest, IsValid) { CallStatement c( + Source{}, create(Source{}, create( Source{}, mod.RegisterSymbol("func"), "func"), @@ -50,18 +51,19 @@ TEST_F(CallStatementTest, IsValid) { } TEST_F(CallStatementTest, IsValid_MissingExpr) { - CallStatement c(nullptr); + CallStatement c(Source{}, nullptr); EXPECT_FALSE(c.IsValid()); } TEST_F(CallStatementTest, IsValid_InvalidExpr) { CallExpression stmt(Source{}, nullptr, {}); - CallStatement c(&stmt); + CallStatement c(Source{}, &stmt); EXPECT_FALSE(c.IsValid()); } TEST_F(CallStatementTest, ToStr) { CallStatement c( + Source{}, create(Source{}, create( Source{}, mod.RegisterSymbol("func"), "func"), diff --git a/src/ast/case_statement.cc b/src/ast/case_statement.cc index 03c803e7b8..181a26341c 100644 --- a/src/ast/case_statement.cc +++ b/src/ast/case_statement.cc @@ -22,11 +22,6 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::CaseStatement); namespace tint { namespace ast { -CaseStatement::CaseStatement(BlockStatement* body) : Base(), body_(body) {} - -CaseStatement::CaseStatement(CaseSelectorList selectors, BlockStatement* body) - : Base(), selectors_(selectors), body_(body) {} - CaseStatement::CaseStatement(const Source& source, CaseSelectorList selectors, BlockStatement* body) diff --git a/src/ast/case_statement.h b/src/ast/case_statement.h index 35cb49534a..c9c424e8b8 100644 --- a/src/ast/case_statement.h +++ b/src/ast/case_statement.h @@ -33,14 +33,6 @@ using CaseSelectorList = std::vector; /// A case statement class CaseStatement : public Castable { public: - /// Constructor - /// Creates a default case statement - /// @param body the case body - explicit CaseStatement(BlockStatement* body); - /// Constructor - /// @param selectors the case selectors - /// @param body the case body - CaseStatement(CaseSelectorList selectors, BlockStatement* body); /// Constructor /// @param source the source information /// @param selectors the case selectors diff --git a/src/ast/case_statement_test.cc b/src/ast/case_statement_test.cc index 9ecf1bbae5..0473418133 100644 --- a/src/ast/case_statement_test.cc +++ b/src/ast/case_statement_test.cc @@ -35,11 +35,11 @@ TEST_F(CaseStatementTest, Creation_i32) { auto* selector = create(Source{}, &i32, 2); b.push_back(selector); - auto* body = create(); - auto* discard = create(); + auto* body = create(Source{}); + auto* discard = create(Source{}); body->append(discard); - CaseStatement c(b, body); + CaseStatement c(Source{}, b, body); ASSERT_EQ(c.selectors().size(), 1u); EXPECT_EQ(c.selectors()[0], selector); ASSERT_EQ(c.body()->size(), 1u); @@ -53,11 +53,11 @@ TEST_F(CaseStatementTest, Creation_u32) { auto* selector = create(Source{}, &u32, 2); b.push_back(selector); - auto* body = create(); - auto* discard = create(); + auto* body = create(Source{}); + auto* discard = create(Source{}); body->append(discard); - CaseStatement c(b, body); + CaseStatement c(Source{}, b, body); ASSERT_EQ(c.selectors().size(), 1u); EXPECT_EQ(c.selectors()[0], selector); ASSERT_EQ(c.body()->size(), 1u); @@ -69,8 +69,8 @@ TEST_F(CaseStatementTest, Creation_WithSource) { CaseSelectorList b; b.push_back(create(Source{}, &i32, 2)); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); CaseStatement c(Source{Source::Location{20, 2}}, b, body); auto src = c.source(); @@ -79,10 +79,10 @@ TEST_F(CaseStatementTest, Creation_WithSource) { } TEST_F(CaseStatementTest, IsDefault_WithoutSelectors) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - CaseStatement c(body); + CaseStatement c(Source{}, CaseSelectorList{}, body); EXPECT_TRUE(c.IsDefault()); } @@ -91,17 +91,19 @@ TEST_F(CaseStatementTest, IsDefault_WithSelectors) { CaseSelectorList b; b.push_back(create(Source{}, &i32, 2)); - CaseStatement c(b, create()); + CaseStatement c(Source{}, b, create(Source{})); EXPECT_FALSE(c.IsDefault()); } TEST_F(CaseStatementTest, IsCase) { - CaseStatement c(create()); + CaseStatement c(Source{}, CaseSelectorList{}, + create(Source{})); EXPECT_TRUE(c.Is()); } TEST_F(CaseStatementTest, IsValid) { - CaseStatement c(create()); + CaseStatement c(Source{}, CaseSelectorList{}, + create(Source{})); EXPECT_TRUE(c.IsValid()); } @@ -110,11 +112,11 @@ TEST_F(CaseStatementTest, IsValid_NullBodyStatement) { CaseSelectorList b; b.push_back(create(Source{}, &i32, 2)); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); body->append(nullptr); - CaseStatement c(b, body); + CaseStatement c(Source{}, b, body); EXPECT_FALSE(c.IsValid()); } @@ -123,11 +125,12 @@ TEST_F(CaseStatementTest, IsValid_InvalidBodyStatement) { CaseSelectorList b; b.push_back(create(Source{}, &i32, 2)); - auto* body = create(); - body->append(create(Source{}, nullptr, create(), + auto* body = create(Source{}); + body->append(create(Source{}, nullptr, + create(Source{}), ElseStatementList{})); - CaseStatement c({b}, body); + CaseStatement c(Source{}, {b}, body); EXPECT_FALSE(c.IsValid()); } @@ -136,9 +139,9 @@ TEST_F(CaseStatementTest, ToStr_WithSelectors_i32) { CaseSelectorList b; b.push_back(create(Source{}, &i32, -2)); - auto* body = create(); - body->append(create()); - CaseStatement c({b}, body); + auto* body = create(Source{}); + body->append(create(Source{})); + CaseStatement c(Source{}, {b}, body); std::ostringstream out; c.to_str(out, 2); @@ -153,9 +156,9 @@ TEST_F(CaseStatementTest, ToStr_WithSelectors_u32) { CaseSelectorList b; b.push_back(create(Source{}, &u32, 2)); - auto* body = create(); - body->append(create()); - CaseStatement c({b}, body); + auto* body = create(Source{}); + body->append(create(Source{})); + CaseStatement c(Source{}, {b}, body); std::ostringstream out; c.to_str(out, 2); @@ -172,9 +175,9 @@ TEST_F(CaseStatementTest, ToStr_WithMultipleSelectors) { b.push_back(create(Source{}, &i32, 1)); b.push_back(create(Source{}, &i32, 2)); - auto* body = create(); - body->append(create()); - CaseStatement c(b, body); + auto* body = create(Source{}); + body->append(create(Source{})); + CaseStatement c(Source{}, b, body); std::ostringstream out; c.to_str(out, 2); @@ -185,9 +188,9 @@ TEST_F(CaseStatementTest, ToStr_WithMultipleSelectors) { } TEST_F(CaseStatementTest, ToStr_WithoutSelectors) { - auto* body = create(); - body->append(create()); - CaseStatement c(CaseSelectorList{}, body); + auto* body = create(Source{}); + body->append(create(Source{})); + CaseStatement c(Source{}, CaseSelectorList{}, body); std::ostringstream out; c.to_str(out, 2); diff --git a/src/ast/continue_statement.cc b/src/ast/continue_statement.cc index 77377d4cfd..4d1597bbd0 100644 --- a/src/ast/continue_statement.cc +++ b/src/ast/continue_statement.cc @@ -22,8 +22,6 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::ContinueStatement); namespace tint { namespace ast { -ContinueStatement::ContinueStatement() : Base() {} - ContinueStatement::ContinueStatement(const Source& source) : Base(source) {} ContinueStatement::ContinueStatement(ContinueStatement&&) = default; diff --git a/src/ast/continue_statement.h b/src/ast/continue_statement.h index e68f9e6137..1d4de2442a 100644 --- a/src/ast/continue_statement.h +++ b/src/ast/continue_statement.h @@ -26,8 +26,6 @@ namespace ast { /// An continue statement class ContinueStatement : public Castable { public: - /// Constructor - ContinueStatement(); /// Constructor /// @param source the continue statement source explicit ContinueStatement(const Source& source); diff --git a/src/ast/continue_statement_test.cc b/src/ast/continue_statement_test.cc index 577d50b263..5c15b809a9 100644 --- a/src/ast/continue_statement_test.cc +++ b/src/ast/continue_statement_test.cc @@ -30,17 +30,17 @@ TEST_F(ContinueStatementTest, Creation_WithSource) { } TEST_F(ContinueStatementTest, IsContinue) { - ContinueStatement stmt; + ContinueStatement stmt(Source{}); EXPECT_TRUE(stmt.Is()); } TEST_F(ContinueStatementTest, IsValid) { - ContinueStatement stmt; + ContinueStatement stmt(Source{}); EXPECT_TRUE(stmt.IsValid()); } TEST_F(ContinueStatementTest, ToStr) { - ContinueStatement stmt; + ContinueStatement stmt(Source{}); std::ostringstream out; stmt.to_str(out, 2); EXPECT_EQ(out.str(), R"( Continue{} diff --git a/src/ast/discard_statement.cc b/src/ast/discard_statement.cc index 66c0e19948..cab164c94b 100644 --- a/src/ast/discard_statement.cc +++ b/src/ast/discard_statement.cc @@ -22,8 +22,6 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::DiscardStatement); namespace tint { namespace ast { -DiscardStatement::DiscardStatement() : Base() {} - DiscardStatement::DiscardStatement(const Source& source) : Base(source) {} DiscardStatement::DiscardStatement(DiscardStatement&&) = default; diff --git a/src/ast/discard_statement.h b/src/ast/discard_statement.h index c5afd77ab9..8f17fd7cfa 100644 --- a/src/ast/discard_statement.h +++ b/src/ast/discard_statement.h @@ -23,8 +23,6 @@ namespace ast { /// A discard statement class DiscardStatement : public Castable { public: - /// Constructor - DiscardStatement(); /// Constructor /// @param source the discard statement source explicit DiscardStatement(const Source& source); diff --git a/src/ast/discard_statement_test.cc b/src/ast/discard_statement_test.cc index fdf444fd36..3cd5256003 100644 --- a/src/ast/discard_statement_test.cc +++ b/src/ast/discard_statement_test.cc @@ -25,7 +25,7 @@ namespace { using DiscardStatementTest = TestHelper; TEST_F(DiscardStatementTest, Creation) { - DiscardStatement stmt; + DiscardStatement stmt(Source{}); EXPECT_EQ(stmt.source().range.begin.line, 0u); EXPECT_EQ(stmt.source().range.begin.column, 0u); EXPECT_EQ(stmt.source().range.end.line, 0u); @@ -42,17 +42,17 @@ TEST_F(DiscardStatementTest, Creation_WithSource) { } TEST_F(DiscardStatementTest, IsDiscard) { - DiscardStatement stmt; + DiscardStatement stmt(Source{}); EXPECT_TRUE(stmt.Is()); } TEST_F(DiscardStatementTest, IsValid) { - DiscardStatement stmt; + DiscardStatement stmt(Source{}); EXPECT_TRUE(stmt.IsValid()); } TEST_F(DiscardStatementTest, ToStr) { - DiscardStatement stmt; + DiscardStatement stmt(Source{}); std::ostringstream out; stmt.to_str(out, 2); EXPECT_EQ(out.str(), R"( Discard{} diff --git a/src/ast/else_statement.cc b/src/ast/else_statement.cc index fbcc2cac01..6a1a0147f5 100644 --- a/src/ast/else_statement.cc +++ b/src/ast/else_statement.cc @@ -22,14 +22,6 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::ElseStatement); namespace tint { namespace ast { -ElseStatement::ElseStatement(BlockStatement* body) : Base(), body_(body) {} - -ElseStatement::ElseStatement(Expression* condition, BlockStatement* body) - : Base(), condition_(condition), body_(body) {} - -ElseStatement::ElseStatement(const Source& source, BlockStatement* body) - : Base(source), body_(body) {} - ElseStatement::ElseStatement(const Source& source, Expression* condition, BlockStatement* body) diff --git a/src/ast/else_statement.h b/src/ast/else_statement.h index f39a1f0fe4..646672028d 100644 --- a/src/ast/else_statement.h +++ b/src/ast/else_statement.h @@ -29,17 +29,6 @@ namespace ast { /// An else statement class ElseStatement : public Castable { public: - /// Constructor - /// @param body the else body - explicit ElseStatement(BlockStatement* body); - /// Constructor - /// @param condition the else condition - /// @param body the else body - ElseStatement(Expression* condition, BlockStatement* body); - /// Constructor - /// @param source the source information - /// @param body the else body - ElseStatement(const Source& source, BlockStatement* body); /// Constructor /// @param source the source information /// @param condition the else condition diff --git a/src/ast/else_statement_test.cc b/src/ast/else_statement_test.cc index 633ae862e9..c2ea1e891b 100644 --- a/src/ast/else_statement_test.cc +++ b/src/ast/else_statement_test.cc @@ -31,26 +31,27 @@ TEST_F(ElseStatementTest, Creation) { type::Bool bool_type; auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); auto* discard = body->get(0); - ElseStatement e(cond, body); + ElseStatement e(Source{}, cond, body); EXPECT_EQ(e.condition(), cond); ASSERT_EQ(e.body()->size(), 1u); EXPECT_EQ(e.body()->get(0), discard); } TEST_F(ElseStatementTest, Creation_WithSource) { - ElseStatement e(Source{Source::Location{20, 2}}, create()); + ElseStatement e(Source{Source::Location{20, 2}}, nullptr, + create(Source{})); auto src = e.source(); EXPECT_EQ(src.range.begin.line, 20u); EXPECT_EQ(src.range.begin.column, 2u); } TEST_F(ElseStatementTest, IsElse) { - ElseStatement e(create()); + ElseStatement e(Source{}, nullptr, create(Source{})); EXPECT_TRUE(e.Is()); } @@ -58,49 +59,50 @@ TEST_F(ElseStatementTest, HasCondition) { type::Bool bool_type; auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - ElseStatement e(cond, create()); + ElseStatement e(Source{}, cond, create(Source{})); EXPECT_TRUE(e.HasCondition()); } TEST_F(ElseStatementTest, HasContition_NullCondition) { - ElseStatement e(create()); + ElseStatement e(Source{}, nullptr, create(Source{})); EXPECT_FALSE(e.HasCondition()); } TEST_F(ElseStatementTest, IsValid) { - ElseStatement e(create()); + ElseStatement e(Source{}, nullptr, create(Source{})); EXPECT_TRUE(e.IsValid()); } TEST_F(ElseStatementTest, IsValid_WithBody) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - ElseStatement e(body); + ElseStatement e(Source{}, nullptr, body); EXPECT_TRUE(e.IsValid()); } TEST_F(ElseStatementTest, IsValid_WithNullBodyStatement) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); body->append(nullptr); - ElseStatement e(body); + ElseStatement e(Source{}, nullptr, body); EXPECT_FALSE(e.IsValid()); } TEST_F(ElseStatementTest, IsValid_InvalidCondition) { auto* cond = create(Source{}, nullptr); - ElseStatement e(cond, create()); + ElseStatement e(Source{}, cond, create(Source{})); EXPECT_FALSE(e.IsValid()); } TEST_F(ElseStatementTest, IsValid_InvalidBodyStatement) { - auto* body = create(); - body->append(create(Source{}, nullptr, create(), + auto* body = create(Source{}); + body->append(create(Source{}, nullptr, + create(Source{}), ElseStatementList{})); - ElseStatement e(body); + ElseStatement e(Source{}, nullptr, body); EXPECT_FALSE(e.IsValid()); } @@ -108,10 +110,10 @@ TEST_F(ElseStatementTest, ToStr) { type::Bool bool_type; auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - ElseStatement e(cond, body); + ElseStatement e(Source{}, cond, body); std::ostringstream out; e.to_str(out, 2); EXPECT_EQ(out.str(), R"( Else{ @@ -126,10 +128,10 @@ TEST_F(ElseStatementTest, ToStr) { } TEST_F(ElseStatementTest, ToStr_NoCondition) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - ElseStatement e(body); + ElseStatement e(Source{}, nullptr, body); std::ostringstream out; e.to_str(out, 2); EXPECT_EQ(out.str(), R"( Else{ diff --git a/src/ast/fallthrough_statement.cc b/src/ast/fallthrough_statement.cc index 5aff216859..db51488d8e 100644 --- a/src/ast/fallthrough_statement.cc +++ b/src/ast/fallthrough_statement.cc @@ -22,8 +22,6 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::FallthroughStatement); namespace tint { namespace ast { -FallthroughStatement::FallthroughStatement() : Base() {} - FallthroughStatement::FallthroughStatement(const Source& source) : Base(source) {} diff --git a/src/ast/fallthrough_statement.h b/src/ast/fallthrough_statement.h index 5f652bda98..25d5870631 100644 --- a/src/ast/fallthrough_statement.h +++ b/src/ast/fallthrough_statement.h @@ -23,8 +23,6 @@ namespace ast { /// An fallthrough statement class FallthroughStatement : public Castable { public: - /// Constructor - FallthroughStatement(); /// Constructor /// @param source the source information explicit FallthroughStatement(const Source& source); diff --git a/src/ast/fallthrough_statement_test.cc b/src/ast/fallthrough_statement_test.cc index a41f5be15f..1e926dd272 100644 --- a/src/ast/fallthrough_statement_test.cc +++ b/src/ast/fallthrough_statement_test.cc @@ -23,7 +23,7 @@ namespace { using FallthroughStatementTest = TestHelper; TEST_F(FallthroughStatementTest, Creation) { - FallthroughStatement stmt; + FallthroughStatement stmt(Source{}); EXPECT_EQ(stmt.source().range.begin.line, 0u); EXPECT_EQ(stmt.source().range.begin.column, 0u); EXPECT_EQ(stmt.source().range.end.line, 0u); @@ -38,17 +38,17 @@ TEST_F(FallthroughStatementTest, Creation_WithSource) { } TEST_F(FallthroughStatementTest, IsFallthrough) { - FallthroughStatement stmt; + FallthroughStatement stmt(Source{}); EXPECT_TRUE(stmt.Is()); } TEST_F(FallthroughStatementTest, IsValid) { - FallthroughStatement stmt; + FallthroughStatement stmt(Source{}); EXPECT_TRUE(stmt.IsValid()); } TEST_F(FallthroughStatementTest, ToStr) { - FallthroughStatement stmt; + FallthroughStatement stmt(Source{}); std::ostringstream out; stmt.to_str(out, 2); EXPECT_EQ(out.str(), R"( Fallthrough{} diff --git a/src/ast/function_test.cc b/src/ast/function_test.cc index 89bc80a386..f3439cc797 100644 --- a/src/ast/function_test.cc +++ b/src/ast/function_test.cc @@ -44,7 +44,7 @@ TEST_F(FunctionTest, Creation) { auto* var = params[0]; Function f(Source{}, func_sym, "func", params, &void_type, - create(), FunctionDecorationList{}); + create(Source{}), FunctionDecorationList{}); EXPECT_EQ(f.symbol(), func_sym); EXPECT_EQ(f.name(), "func"); ASSERT_EQ(f.params().size(), 1u); @@ -64,7 +64,8 @@ TEST_F(FunctionTest, Creation_WithSource) { ast::VariableDecorationList{})); Function f(Source{Source::Location{20, 2}}, func_sym, "func", params, - &void_type, create(), FunctionDecorationList{}); + &void_type, create(Source{}), + FunctionDecorationList{}); auto src = f.source(); EXPECT_EQ(src.range.begin.line, 20u); EXPECT_EQ(src.range.begin.column, 2u); @@ -79,7 +80,7 @@ TEST_F(FunctionTest, AddDuplicateReferencedVariables) { Variable v(Source{}, "var", StorageClass::kInput, &i32, false, nullptr, ast::VariableDecorationList{}); Function f(Source{}, func_sym, "func", VariableList{}, &void_type, - create(), FunctionDecorationList{}); + create(Source{}), FunctionDecorationList{}); f.add_referenced_module_variable(&v); ASSERT_EQ(f.referenced_module_variables().size(), 1u); @@ -126,7 +127,7 @@ TEST_F(FunctionTest, GetReferenceLocations) { }); Function f(Source{}, func_sym, "func", VariableList{}, &void_type, - create(), FunctionDecorationList{}); + create(Source{}), FunctionDecorationList{}); f.add_referenced_module_variable(loc1); f.add_referenced_module_variable(builtin1); @@ -173,7 +174,7 @@ TEST_F(FunctionTest, GetReferenceBuiltins) { }); Function f(Source{}, func_sym, "func", VariableList{}, &void_type, - create(), FunctionDecorationList{}); + create(Source{}), FunctionDecorationList{}); f.add_referenced_module_variable(loc1); f.add_referenced_module_variable(builtin1); @@ -196,7 +197,7 @@ TEST_F(FunctionTest, AddDuplicateEntryPoints) { auto main_sym = mod.RegisterSymbol("main"); Function f(Source{}, func_sym, "func", VariableList{}, &void_type, - create(), FunctionDecorationList{}); + create(Source{}), FunctionDecorationList{}); f.add_ancestor_entry_point(main_sym); ASSERT_EQ(1u, f.ancestor_entry_points().size()); @@ -218,8 +219,8 @@ TEST_F(FunctionTest, IsValid) { false, nullptr, ast::VariableDecorationList{})); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); Function f(Source{}, func_sym, "func", params, &void_type, body, FunctionDecorationList{}); @@ -237,8 +238,8 @@ TEST_F(FunctionTest, IsValid_InvalidName) { false, nullptr, ast::VariableDecorationList{})); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); Function f(Source{}, func_sym, "", params, &void_type, body, FunctionDecorationList{}); @@ -256,7 +257,7 @@ TEST_F(FunctionTest, IsValid_MissingReturnType) { ast::VariableDecorationList{})); Function f(Source{}, func_sym, "func", params, nullptr, - create(), FunctionDecorationList{}); + create(Source{}), FunctionDecorationList{}); EXPECT_FALSE(f.IsValid()); } @@ -273,7 +274,7 @@ TEST_F(FunctionTest, IsValid_NullParam) { params.push_back(nullptr); Function f(Source{}, func_sym, "func", params, &void_type, - create(), FunctionDecorationList{}); + create(Source{}), FunctionDecorationList{}); EXPECT_FALSE(f.IsValid()); } @@ -288,7 +289,7 @@ TEST_F(FunctionTest, IsValid_InvalidParam) { ast::VariableDecorationList{})); Function f(Source{}, func_sym, "func", params, &void_type, - create(), FunctionDecorationList{}); + create(Source{}), FunctionDecorationList{}); EXPECT_FALSE(f.IsValid()); } @@ -303,8 +304,8 @@ TEST_F(FunctionTest, IsValid_NullBodyStatement) { false, nullptr, ast::VariableDecorationList{})); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); body->append(nullptr); Function f(Source{}, func_sym, "func", params, &void_type, body, @@ -324,8 +325,8 @@ TEST_F(FunctionTest, IsValid_InvalidBodyStatement) { false, nullptr, ast::VariableDecorationList{})); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); body->append(nullptr); Function f(Source{}, func_sym, "func", params, &void_type, body, @@ -339,8 +340,8 @@ TEST_F(FunctionTest, ToStr) { auto func_sym = mod.RegisterSymbol("func"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); Function f(Source{}, func_sym, "func", {}, &void_type, body, FunctionDecorationList{}); @@ -361,8 +362,8 @@ TEST_F(FunctionTest, ToStr_WithDecoration) { auto func_sym = mod.RegisterSymbol("func"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); Function f( Source{}, func_sym, "func", {}, &void_type, body, @@ -390,8 +391,8 @@ TEST_F(FunctionTest, ToStr_WithParams) { false, nullptr, ast::VariableDecorationList{})); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); Function f(Source{}, func_sym, "func", params, &void_type, body, FunctionDecorationList{}); @@ -418,7 +419,7 @@ TEST_F(FunctionTest, TypeName) { auto func_sym = mod.RegisterSymbol("func"); Function f(Source{}, func_sym, "func", {}, &void_type, - create(), FunctionDecorationList{}); + create(Source{}), FunctionDecorationList{}); EXPECT_EQ(f.type_name(), "__func__void"); } @@ -438,7 +439,7 @@ TEST_F(FunctionTest, TypeName_WithParams) { ast::VariableDecorationList{})); Function f(Source{}, func_sym, "func", params, &void_type, - create(), FunctionDecorationList{}); + create(Source{}), FunctionDecorationList{}); EXPECT_EQ(f.type_name(), "__func__void__i32__f32"); } @@ -448,8 +449,8 @@ TEST_F(FunctionTest, GetLastStatement) { auto func_sym = mod.RegisterSymbol("func"); VariableList params; - auto* body = create(); - auto* stmt = create(); + auto* body = create(Source{}); + auto* stmt = create(Source{}); body->append(stmt); Function f(Source{}, func_sym, "func", params, &void_type, body, FunctionDecorationList{}); @@ -463,7 +464,7 @@ TEST_F(FunctionTest, GetLastStatement_nullptr) { auto func_sym = mod.RegisterSymbol("func"); VariableList params; - auto* body = create(); + auto* body = create(Source{}); Function f(Source{}, func_sym, "func", params, &void_type, body, FunctionDecorationList{}); @@ -476,7 +477,7 @@ TEST_F(FunctionTest, WorkgroupSize_NoneSet) { auto func_sym = mod.RegisterSymbol("func"); Function f(Source{}, func_sym, "func", {}, &void_type, - create(), FunctionDecorationList{}); + create(Source{}), FunctionDecorationList{}); uint32_t x = 0; uint32_t y = 0; uint32_t z = 0; @@ -492,7 +493,7 @@ TEST_F(FunctionTest, WorkgroupSize) { auto func_sym = mod.RegisterSymbol("func"); Function f(Source{}, func_sym, "func", {}, &void_type, - create(), + create(Source{}), {create(2u, 4u, 6u, Source{})}); uint32_t x = 0; diff --git a/src/ast/if_statement_test.cc b/src/ast/if_statement_test.cc index b7814e41ae..7c7c777549 100644 --- a/src/ast/if_statement_test.cc +++ b/src/ast/if_statement_test.cc @@ -27,8 +27,8 @@ using IfStatementTest = TestHelper; TEST_F(IfStatementTest, Creation) { auto* cond = create(Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); IfStatement stmt(Source{Source::Location{20, 2}}, cond, body, ElseStatementList{}); @@ -38,7 +38,7 @@ TEST_F(IfStatementTest, Creation) { } TEST_F(IfStatementTest, IsIf) { - IfStatement stmt(Source{}, nullptr, create(), + IfStatement stmt(Source{}, nullptr, create(Source{}), ElseStatementList{}); EXPECT_TRUE(stmt.Is()); } @@ -46,8 +46,8 @@ TEST_F(IfStatementTest, IsIf) { TEST_F(IfStatementTest, IsValid) { auto* cond = create(Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); IfStatement stmt(Source{}, cond, body, ElseStatementList{}); EXPECT_TRUE(stmt.IsValid()); @@ -56,23 +56,25 @@ TEST_F(IfStatementTest, IsValid) { TEST_F(IfStatementTest, IsValid_WithElseStatements) { auto* cond = create(Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); IfStatement stmt(Source{}, cond, body, { create( + Source{}, create( Source{}, mod.RegisterSymbol("Ident"), "Ident"), - create()), - create(create()), + create(Source{})), + create(Source{}, nullptr, + create(Source{})), }); EXPECT_TRUE(stmt.IsValid()); } TEST_F(IfStatementTest, IsValid_MissingCondition) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); IfStatement stmt(Source{}, nullptr, body, ElseStatementList{}); EXPECT_FALSE(stmt.IsValid()); @@ -81,8 +83,8 @@ TEST_F(IfStatementTest, IsValid_MissingCondition) { TEST_F(IfStatementTest, IsValid_InvalidCondition) { auto* cond = create(Source{}, mod.RegisterSymbol(""), ""); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); IfStatement stmt(Source{}, cond, body, ElseStatementList{}); EXPECT_FALSE(stmt.IsValid()); @@ -91,8 +93,8 @@ TEST_F(IfStatementTest, IsValid_InvalidCondition) { TEST_F(IfStatementTest, IsValid_NullBodyStatement) { auto* cond = create(Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); body->append(nullptr); IfStatement stmt(Source{}, cond, body, ElseStatementList{}); @@ -102,9 +104,10 @@ TEST_F(IfStatementTest, IsValid_NullBodyStatement) { TEST_F(IfStatementTest, IsValid_InvalidBodyStatement) { auto* cond = create(Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); - body->append(create(Source{}, nullptr, create(), + auto* body = create(Source{}); + body->append(create(Source{})); + body->append(create(Source{}, nullptr, + create(Source{}), ast::ElseStatementList{})); IfStatement stmt(Source{}, cond, body, ElseStatementList{}); @@ -114,16 +117,18 @@ TEST_F(IfStatementTest, IsValid_InvalidBodyStatement) { TEST_F(IfStatementTest, IsValid_NullElseStatement) { auto* cond = create(Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); IfStatement stmt(Source{}, cond, body, { create( + Source{}, create( Source{}, mod.RegisterSymbol("Ident"), "Ident"), - create()), - create(create()), + create(Source{})), + create(Source{}, nullptr, + create(Source{})), nullptr, }); EXPECT_FALSE(stmt.IsValid()); @@ -132,15 +137,16 @@ TEST_F(IfStatementTest, IsValid_NullElseStatement) { TEST_F(IfStatementTest, IsValid_InvalidElseStatement) { auto* cond = create(Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); IfStatement stmt( Source{}, cond, body, { - create(create( + create(Source{}, + create( Source{}, mod.RegisterSymbol(""), ""), - create()), + create(Source{})), }); EXPECT_FALSE(stmt.IsValid()); } @@ -148,13 +154,15 @@ TEST_F(IfStatementTest, IsValid_InvalidElseStatement) { TEST_F(IfStatementTest, IsValid_MultipleElseWiththoutCondition) { auto* cond = create(Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); IfStatement stmt(Source{}, cond, body, { - create(create()), - create(create()), + create(Source{}, nullptr, + create(Source{})), + create(Source{}, nullptr, + create(Source{})), }); EXPECT_FALSE(stmt.IsValid()); } @@ -162,16 +170,18 @@ TEST_F(IfStatementTest, IsValid_MultipleElseWiththoutCondition) { TEST_F(IfStatementTest, IsValid_ElseNotLast) { auto* cond = create(Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); IfStatement stmt(Source{}, cond, body, { - create(create()), + create(Source{}, nullptr, + create(Source{})), create( + Source{}, create( Source{}, mod.RegisterSymbol("ident"), "ident"), - create()), + create(Source{})), }); EXPECT_FALSE(stmt.IsValid()); } @@ -179,8 +189,8 @@ TEST_F(IfStatementTest, IsValid_ElseNotLast) { TEST_F(IfStatementTest, ToStr) { auto* cond = create(Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); IfStatement stmt(Source{}, cond, body, ElseStatementList{}); @@ -200,23 +210,24 @@ TEST_F(IfStatementTest, ToStr) { TEST_F(IfStatementTest, ToStr_WithElseStatements) { auto* cond = create(Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - auto* else_if_body = create(); - else_if_body->append(create()); + auto* else_if_body = create(Source{}); + else_if_body->append(create(Source{})); - auto* else_body = create(); - else_body->append(create()); - else_body->append(create()); + auto* else_body = create(Source{}); + else_body->append(create(Source{})); + else_body->append(create(Source{})); IfStatement stmt(Source{}, cond, body, { create( + Source{}, create( Source{}, mod.RegisterSymbol("ident"), "ident"), else_if_body), - create(else_body), + create(Source{}, nullptr, else_body), }); std::ostringstream out; diff --git a/src/ast/loop_statement.cc b/src/ast/loop_statement.cc index 014d0aeaef..9549cc0df5 100644 --- a/src/ast/loop_statement.cc +++ b/src/ast/loop_statement.cc @@ -22,9 +22,6 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::LoopStatement); namespace tint { namespace ast { -LoopStatement::LoopStatement(BlockStatement* body, BlockStatement* continuing) - : Base(), body_(body), continuing_(continuing) {} - LoopStatement::LoopStatement(const Source& source, BlockStatement* body, BlockStatement* continuing) diff --git a/src/ast/loop_statement.h b/src/ast/loop_statement.h index 64e1140f25..6eb4b392b8 100644 --- a/src/ast/loop_statement.h +++ b/src/ast/loop_statement.h @@ -27,10 +27,6 @@ namespace ast { /// A loop statement class LoopStatement : public Castable { public: - /// Constructor - /// @param body the body statements - /// @param continuing the continuing statements - LoopStatement(BlockStatement* body, BlockStatement* continuing); /// Constructor /// @param source the loop statement source /// @param body the body statements diff --git a/src/ast/loop_statement_test.cc b/src/ast/loop_statement_test.cc index 63d4e13509..4588d0135a 100644 --- a/src/ast/loop_statement_test.cc +++ b/src/ast/loop_statement_test.cc @@ -28,14 +28,14 @@ namespace { using LoopStatementTest = TestHelper; TEST_F(LoopStatementTest, Creation) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); auto* b = body->last(); - auto* continuing = create(); - continuing->append(create()); + auto* continuing = create(Source{}); + continuing->append(create(Source{})); - LoopStatement l(body, continuing); + LoopStatement l(Source{}, body, continuing); ASSERT_EQ(l.body()->size(), 1u); EXPECT_EQ(l.body()->get(0), b); ASSERT_EQ(l.continuing()->size(), 1u); @@ -43,11 +43,11 @@ TEST_F(LoopStatementTest, Creation) { } TEST_F(LoopStatementTest, Creation_WithSource) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - auto* continuing = create(); - continuing->append(create()); + auto* continuing = create(Source{}); + continuing->append(create(Source{})); LoopStatement l(Source{Source::Location{20, 2}}, body, continuing); auto src = l.source(); @@ -56,108 +56,112 @@ TEST_F(LoopStatementTest, Creation_WithSource) { } TEST_F(LoopStatementTest, IsLoop) { - LoopStatement l(create(), create()); + LoopStatement l(Source{}, create(Source{}), + create(Source{})); EXPECT_TRUE(l.Is()); } TEST_F(LoopStatementTest, HasContinuing_WithoutContinuing) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - LoopStatement l(body, {}); + LoopStatement l(Source{}, body, {}); EXPECT_FALSE(l.has_continuing()); } TEST_F(LoopStatementTest, HasContinuing_WithContinuing) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - auto* continuing = create(); - continuing->append(create()); + auto* continuing = create(Source{}); + continuing->append(create(Source{})); - LoopStatement l(body, continuing); + LoopStatement l(Source{}, body, continuing); EXPECT_TRUE(l.has_continuing()); } TEST_F(LoopStatementTest, IsValid) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - auto* continuing = create(); - continuing->append(create()); + auto* continuing = create(Source{}); + continuing->append(create(Source{})); - LoopStatement l(body, continuing); + LoopStatement l(Source{}, body, continuing); EXPECT_TRUE(l.IsValid()); } TEST_F(LoopStatementTest, IsValid_WithoutContinuing) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - LoopStatement l(body, create()); + LoopStatement l(Source{}, body, create(Source{})); EXPECT_TRUE(l.IsValid()); } TEST_F(LoopStatementTest, IsValid_WithoutBody) { - LoopStatement l(create(), create()); + LoopStatement l(Source{}, create(Source{}), + create(Source{})); EXPECT_TRUE(l.IsValid()); } TEST_F(LoopStatementTest, IsValid_NullBodyStatement) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); body->append(nullptr); - auto* continuing = create(); - continuing->append(create()); + auto* continuing = create(Source{}); + continuing->append(create(Source{})); - LoopStatement l(body, continuing); + LoopStatement l(Source{}, body, continuing); EXPECT_FALSE(l.IsValid()); } TEST_F(LoopStatementTest, IsValid_InvalidBodyStatement) { - auto* body = create(); - body->append(create()); - body->append(create(Source{}, nullptr, create(), + auto* body = create(Source{}); + body->append(create(Source{})); + body->append(create(Source{}, nullptr, + create(Source{}), ElseStatementList{})); - auto* continuing = create(); - continuing->append(create()); + auto* continuing = create(Source{}); + continuing->append(create(Source{})); - LoopStatement l(body, continuing); + LoopStatement l(Source{}, body, continuing); EXPECT_FALSE(l.IsValid()); } TEST_F(LoopStatementTest, IsValid_NullContinuingStatement) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - auto* continuing = create(); - continuing->append(create()); + auto* continuing = create(Source{}); + continuing->append(create(Source{})); continuing->append(nullptr); - LoopStatement l(body, continuing); + LoopStatement l(Source{}, body, continuing); EXPECT_FALSE(l.IsValid()); } TEST_F(LoopStatementTest, IsValid_InvalidContinuingStatement) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - auto* continuing = create(); - continuing->append(create()); - continuing->append(create( - Source{}, nullptr, create(), ElseStatementList{})); + auto* continuing = create(Source{}); + continuing->append(create(Source{})); + continuing->append(create(Source{}, nullptr, + create(Source{}), + ElseStatementList{})); - LoopStatement l(body, continuing); + LoopStatement l(Source{}, body, continuing); EXPECT_FALSE(l.IsValid()); } TEST_F(LoopStatementTest, ToStr) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - LoopStatement l(body, {}); + LoopStatement l(Source{}, body, {}); std::ostringstream out; l.to_str(out, 2); EXPECT_EQ(out.str(), R"( Loop{ @@ -167,13 +171,13 @@ TEST_F(LoopStatementTest, ToStr) { } TEST_F(LoopStatementTest, ToStr_WithContinuing) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - auto* continuing = create(); - continuing->append(create()); + auto* continuing = create(Source{}); + continuing->append(create(Source{})); - LoopStatement l(body, continuing); + LoopStatement l(Source{}, body, continuing); std::ostringstream out; l.to_str(out, 2); EXPECT_EQ(out.str(), R"( Loop{ diff --git a/src/ast/module_test.cc b/src/ast/module_test.cc index 534a258ab2..cab119bcbc 100644 --- a/src/ast/module_test.cc +++ b/src/ast/module_test.cc @@ -49,9 +49,9 @@ TEST_F(ModuleTest, LookupFunction) { Module m; auto func_sym = m.RegisterSymbol("main"); - auto* func = - create(Source{}, func_sym, "main", VariableList{}, &f32, - create(), ast::FunctionDecorationList{}); + auto* func = create(Source{}, func_sym, "main", VariableList{}, + &f32, create(Source{}), + ast::FunctionDecorationList{}); m.AddFunction(func); EXPECT_EQ(func, m.FindFunctionBySymbol(func_sym)); } @@ -131,9 +131,9 @@ TEST_F(ModuleTest, IsValid_Function) { Module m; - auto* func = create(Source{}, m.RegisterSymbol("main"), "main", - VariableList(), &f32, create(), - ast::FunctionDecorationList{}); + auto* func = create( + Source{}, m.RegisterSymbol("main"), "main", VariableList(), &f32, + create(Source{}), ast::FunctionDecorationList{}); m.AddFunction(func); EXPECT_TRUE(m.IsValid()); } diff --git a/src/ast/statement.cc b/src/ast/statement.cc index 9abbba024f..cef7a9a1ec 100644 --- a/src/ast/statement.cc +++ b/src/ast/statement.cc @@ -36,8 +36,6 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::Statement); namespace tint { namespace ast { -Statement::Statement() = default; - Statement::Statement(const Source& source) : Base(source) {} Statement::Statement(Statement&&) = default; diff --git a/src/ast/statement.h b/src/ast/statement.h index b38c74c5c6..baff8d9bc3 100644 --- a/src/ast/statement.h +++ b/src/ast/statement.h @@ -32,8 +32,6 @@ class Statement : public Castable { const char* Name() const; protected: - /// Constructor - Statement(); /// Constructor /// @param source the source of the expression explicit Statement(const Source& source); diff --git a/src/ast/switch_statement.cc b/src/ast/switch_statement.cc index 8634ed4a9f..51cc0bfad7 100644 --- a/src/ast/switch_statement.cc +++ b/src/ast/switch_statement.cc @@ -23,9 +23,6 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::SwitchStatement); namespace tint { namespace ast { -SwitchStatement::SwitchStatement(Expression* condition, CaseStatementList body) - : condition_(condition), body_(body) {} - SwitchStatement::SwitchStatement(const Source& source, Expression* condition, CaseStatementList body) diff --git a/src/ast/switch_statement.h b/src/ast/switch_statement.h index 22f0b3e7b5..917d6aada8 100644 --- a/src/ast/switch_statement.h +++ b/src/ast/switch_statement.h @@ -29,10 +29,6 @@ namespace ast { /// A switch statement class SwitchStatement : public Castable { public: - /// Constructor - /// @param condition the switch condition - /// @param body the switch body - SwitchStatement(Expression* condition, CaseStatementList body); /// Constructor /// @param source the source information /// @param condition the switch condition diff --git a/src/ast/switch_statement_test.cc b/src/ast/switch_statement_test.cc index e0746f0a62..9a73e39aad 100644 --- a/src/ast/switch_statement_test.cc +++ b/src/ast/switch_statement_test.cc @@ -37,10 +37,11 @@ TEST_F(SwitchStatementTest, Creation) { auto* ident = create( Source{}, mod.RegisterSymbol("ident"), "ident"); CaseStatementList body; - auto* case_stmt = create(lit, create()); + auto* case_stmt = + create(Source{}, lit, create(Source{})); body.push_back(case_stmt); - SwitchStatement stmt(ident, body); + SwitchStatement stmt(Source{}, ident, body); EXPECT_EQ(stmt.condition(), ident); ASSERT_EQ(stmt.body().size(), 1u); EXPECT_EQ(stmt.body()[0], case_stmt); @@ -66,9 +67,10 @@ TEST_F(SwitchStatementTest, IsSwitch) { auto* ident = create( Source{}, mod.RegisterSymbol("ident"), "ident"); CaseStatementList body; - body.push_back(create(lit, create())); + body.push_back( + create(Source{}, lit, create(Source{}))); - SwitchStatement stmt(ident, body); + SwitchStatement stmt(Source{}, ident, body); EXPECT_TRUE(stmt.Is()); } @@ -81,9 +83,10 @@ TEST_F(SwitchStatementTest, IsValid) { auto* ident = create( Source{}, mod.RegisterSymbol("ident"), "ident"); CaseStatementList body; - body.push_back(create(lit, create())); + body.push_back( + create(Source{}, lit, create(Source{}))); - SwitchStatement stmt(ident, body); + SwitchStatement stmt(Source{}, ident, body); EXPECT_TRUE(stmt.IsValid()); } @@ -94,9 +97,10 @@ TEST_F(SwitchStatementTest, IsValid_Null_Condition) { lit.push_back(create(Source{}, &i32, 2)); CaseStatementList body; - body.push_back(create(lit, create())); + body.push_back( + create(Source{}, lit, create(Source{}))); - SwitchStatement stmt(nullptr, body); + SwitchStatement stmt(Source{}, nullptr, body); EXPECT_FALSE(stmt.IsValid()); } @@ -109,9 +113,10 @@ TEST_F(SwitchStatementTest, IsValid_Invalid_Condition) { auto* ident = create(Source{}, mod.RegisterSymbol(""), ""); CaseStatementList body; - body.push_back(create(lit, create())); + body.push_back( + create(Source{}, lit, create(Source{}))); - SwitchStatement stmt(ident, body); + SwitchStatement stmt(Source{}, ident, body); EXPECT_FALSE(stmt.IsValid()); } @@ -124,10 +129,11 @@ TEST_F(SwitchStatementTest, IsValid_Null_BodyStatement) { auto* ident = create( Source{}, mod.RegisterSymbol("ident"), "ident"); CaseStatementList body; - body.push_back(create(lit, create())); + body.push_back( + create(Source{}, lit, create(Source{}))); body.push_back(nullptr); - SwitchStatement stmt(ident, body); + SwitchStatement stmt(Source{}, ident, body); EXPECT_FALSE(stmt.IsValid()); } @@ -135,13 +141,14 @@ TEST_F(SwitchStatementTest, IsValid_Invalid_BodyStatement) { auto* ident = create( Source{}, mod.RegisterSymbol("ident"), "ident"); - auto* case_body = create(); + auto* case_body = create(Source{}); case_body->append(nullptr); CaseStatementList body; - body.push_back(create(CaseSelectorList{}, case_body)); + body.push_back( + create(Source{}, CaseSelectorList{}, case_body)); - SwitchStatement stmt(ident, body); + SwitchStatement stmt(Source{}, ident, body); EXPECT_FALSE(stmt.IsValid()); } @@ -149,7 +156,7 @@ TEST_F(SwitchStatementTest, ToStr_Empty) { auto* ident = create( Source{}, mod.RegisterSymbol("ident"), "ident"); - SwitchStatement stmt(ident, {}); + SwitchStatement stmt(Source{}, ident, {}); std::ostringstream out; stmt.to_str(out, 2); EXPECT_EQ(demangle(out.str()), R"( Switch{ @@ -169,9 +176,10 @@ TEST_F(SwitchStatementTest, ToStr) { auto* ident = create( Source{}, mod.RegisterSymbol("ident"), "ident"); CaseStatementList body; - body.push_back(create(lit, create())); + body.push_back( + create(Source{}, lit, create(Source{}))); - SwitchStatement stmt(ident, body); + SwitchStatement stmt(Source{}, ident, body); std::ostringstream out; stmt.to_str(out, 2); EXPECT_EQ(demangle(out.str()), R"( Switch{ diff --git a/src/ast/variable_decl_statement.cc b/src/ast/variable_decl_statement.cc index 83b4b7c421..f5eb50f451 100644 --- a/src/ast/variable_decl_statement.cc +++ b/src/ast/variable_decl_statement.cc @@ -22,9 +22,6 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::VariableDeclStatement); namespace tint { namespace ast { -VariableDeclStatement::VariableDeclStatement(Variable* variable) - : Base(), variable_(variable) {} - VariableDeclStatement::VariableDeclStatement(const Source& source, Variable* variable) : Base(source), variable_(variable) {} diff --git a/src/ast/variable_decl_statement.h b/src/ast/variable_decl_statement.h index 6ec374864d..88bef800c4 100644 --- a/src/ast/variable_decl_statement.h +++ b/src/ast/variable_decl_statement.h @@ -29,9 +29,6 @@ namespace ast { class VariableDeclStatement : public Castable { public: - /// Constructor - /// @param variable the variable - explicit VariableDeclStatement(Variable* variable); /// Constructor /// @param source the variable statement source /// @param variable the variable diff --git a/src/ast/variable_decl_statement_test.cc b/src/ast/variable_decl_statement_test.cc index 3ef7a4bc73..edc7d97aeb 100644 --- a/src/ast/variable_decl_statement_test.cc +++ b/src/ast/variable_decl_statement_test.cc @@ -29,7 +29,7 @@ TEST_F(VariableDeclStatementTest, Creation) { auto* var = create(Source{}, "a", StorageClass::kNone, &f32, false, nullptr, ast::VariableDecorationList{}); - VariableDeclStatement stmt(var); + VariableDeclStatement stmt(Source{}, var); EXPECT_EQ(stmt.variable(), var); } @@ -49,15 +49,15 @@ TEST_F(VariableDeclStatementTest, IsVariableDecl) { auto* var = create(Source{}, "a", StorageClass::kNone, &f32, false, nullptr, ast::VariableDecorationList{}); - VariableDeclStatement s(var); - EXPECT_TRUE(s.Is()); + VariableDeclStatement stmt(Source{}, var); + EXPECT_TRUE(stmt.Is()); } TEST_F(VariableDeclStatementTest, IsValid) { type::F32 f32; auto* var = create(Source{}, "a", StorageClass::kNone, &f32, false, nullptr, ast::VariableDecorationList{}); - VariableDeclStatement stmt(var); + VariableDeclStatement stmt(Source{}, var); EXPECT_TRUE(stmt.IsValid()); } @@ -65,12 +65,12 @@ TEST_F(VariableDeclStatementTest, IsValid_InvalidVariable) { type::F32 f32; auto* var = create(Source{}, "", StorageClass::kNone, &f32, false, nullptr, ast::VariableDecorationList{}); - VariableDeclStatement stmt(var); + VariableDeclStatement stmt(Source{}, var); EXPECT_FALSE(stmt.IsValid()); } TEST_F(VariableDeclStatementTest, IsValid_NullVariable) { - VariableDeclStatement stmt(nullptr); + VariableDeclStatement stmt(Source{}, nullptr); EXPECT_FALSE(stmt.IsValid()); } diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index 6600f73641..5c7904e0d8 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -81,7 +81,7 @@ class InspectorHelper { ast::Function* MakeEmptyBodyFunction( std::string name, ast::FunctionDecorationList decorations = {}) { - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); return create(Source{}, mod()->RegisterSymbol(name), name, ast::VariableList(), void_type(), body, @@ -97,12 +97,12 @@ class InspectorHelper { std::string caller, std::string callee, ast::FunctionDecorationList decorations = {}) { - auto* body = create(); + auto* body = create(Source{}); auto* ident_expr = create( Source{}, mod()->RegisterSymbol(callee), callee); auto* call_expr = create(Source{}, ident_expr, ast::ExpressionList()); - body->append(create(call_expr)); + body->append(create(Source{}, call_expr)); body->append(create(Source{})); return create(Source{}, mod()->RegisterSymbol(caller), caller, ast::VariableList(), void_type(), body, @@ -148,11 +148,12 @@ class InspectorHelper { std::string name, std::vector> inout_vars, ast::FunctionDecorationList decorations = {}) { - auto* body = create(); + auto* body = create(Source{}); for (auto inout : inout_vars) { std::string in, out; std::tie(in, out) = inout; body->append(create( + Source{}, create(Source{}, mod()->RegisterSymbol(out), out), create(Source{}, mod()->RegisterSymbol(in), @@ -177,11 +178,12 @@ class InspectorHelper { std::string callee, std::vector> inout_vars, ast::FunctionDecorationList decorations = {}) { - auto* body = create(); + auto* body = create(Source{}); for (auto inout : inout_vars) { std::string in, out; std::tie(in, out) = inout; body->append(create( + Source{}, create(Source{}, mod()->RegisterSymbol(out), out), create(Source{}, mod()->RegisterSymbol(in), @@ -191,7 +193,7 @@ class InspectorHelper { Source{}, mod()->RegisterSymbol(callee), callee); auto* call_expr = create(Source{}, ident_expr, ast::ExpressionList()); - body->append(create(call_expr)); + body->append(create(Source{}, call_expr)); body->append(create(Source{})); return create(Source{}, mod()->RegisterSymbol(caller), caller, ast::VariableList(), void_type(), body, @@ -425,21 +427,22 @@ class InspectorHelper { std::string func_name, std::string struct_name, std::vector> members) { - auto* body = create(); + auto* body = create(Source{}); for (auto member : members) { size_t member_idx; ast::type::Type* member_type; std::tie(member_idx, member_type) = member; std::string member_name = StructMemberName(member_idx, member_type); - body->append(create(create( - Source{}, // source - "local" + member_name, // name - ast::StorageClass::kNone, // storage_class - member_type, // type - false, // is_const - nullptr, // constructor - ast::VariableDecorationList{}))); // decorations + body->append(create( + Source{}, create( + Source{}, // source + "local" + member_name, // name + ast::StorageClass::kNone, // storage_class + member_type, // type + false, // is_const + nullptr, // constructor + ast::VariableDecorationList{}))); // decorations } for (auto member : members) { @@ -448,10 +451,12 @@ class InspectorHelper { std::tie(member_idx, member_type) = member; std::string member_name = StructMemberName(member_idx, member_type); body->append(create( + Source{}, create( Source{}, mod()->RegisterSymbol("local" + member_name), "local" + member_name), - create(Source{}, + create( + Source{}, create( Source{}, mod()->RegisterSymbol(struct_name), struct_name), create( @@ -578,7 +583,7 @@ class InspectorHelper { ast::FunctionDecorationList decorations = {}) { std::string result_name = "sampler_result"; - auto* body = create(); + auto* body = create(Source{}); auto* call_result = create(Source{}, // source @@ -588,7 +593,7 @@ class InspectorHelper { false, // is_const nullptr, // constructor ast::VariableDecorationList{}); // decorations - body->append(create(call_result)); + body->append(create(Source{}, call_result)); ast::ExpressionList call_params; call_params.push_back(create( @@ -604,6 +609,7 @@ class InspectorHelper { call_params); body->append(create( + Source{}, create( Source{}, mod()->RegisterSymbol("sampler_result"), "sampler_result"), @@ -634,7 +640,7 @@ class InspectorHelper { ast::FunctionDecorationList decorations = {}) { std::string result_name = "sampler_result"; - auto* body = create(); + auto* body = create(Source{}); auto* call_result = create(Source{}, // source @@ -644,7 +650,7 @@ class InspectorHelper { false, // is_const nullptr, // constructor ast::VariableDecorationList{}); // decorations - body->append(create(call_result)); + body->append(create(Source{}, call_result)); ast::ExpressionList call_params; call_params.push_back(create( @@ -662,6 +668,7 @@ class InspectorHelper { call_params); body->append(create( + Source{}, create( Source{}, mod()->RegisterSymbol("sampler_result"), "sampler_result"), @@ -693,7 +700,7 @@ class InspectorHelper { ast::FunctionDecorationList decorations = {}) { std::string result_name = "sampler_result"; - auto* body = create(); + auto* body = create(Source{}); auto* call_result = create(Source{}, // source @@ -703,7 +710,7 @@ class InspectorHelper { false, // is_const nullptr, // constructor ast::VariableDecorationList{}); // decorations - body->append(create(call_result)); + body->append(create(Source{}, call_result)); ast::ExpressionList call_params; call_params.push_back(create( @@ -722,6 +729,7 @@ class InspectorHelper { call_params); body->append(create( + Source{}, create( Source{}, mod()->RegisterSymbol("sampler_result"), "sampler_result"), @@ -1551,9 +1559,9 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) { Source{}, mod()->RegisterSymbol(callee), callee); auto* call_expr = create(Source{}, ident_expr, ast::ExpressionList()); - body->append(create(call_expr)); + body->append(create(Source{}, call_expr)); }; - auto* body = create(); + auto* body = create(Source{}); AddFuncCall(body, "ub_foo_func"); AddFuncCall(body, "ub_bar_func"); @@ -1699,9 +1707,9 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) { Source{}, mod()->RegisterSymbol(callee), callee); auto* call_expr = create(Source{}, ident_expr, ast::ExpressionList()); - body->append(create(call_expr)); + body->append(create(Source{}, call_expr)); }; - auto* body = create(); + auto* body = create(Source{}); AddFuncCall(body, "sb_foo_func"); AddFuncCall(body, "sb_bar_func"); @@ -1874,9 +1882,9 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Source{}, mod()->RegisterSymbol(callee), callee); auto* call_expr = create(Source{}, ident_expr, ast::ExpressionList()); - body->append(create(call_expr)); + body->append(create(Source{}, call_expr)); }; - auto* body = create(); + auto* body = create(Source{}); AddFuncCall(body, "sb_foo_func"); AddFuncCall(body, "sb_bar_func"); diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index cd2cb54629..9f24f00c9c 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -667,7 +667,7 @@ void FunctionEmitter::PushNewStatementBlock(const Construct* construct, ast::CaseStatementList* cases, CompletionAction action) { if (block == nullptr) { - block = create(); + block = create(Source{}); } statements_stack_.emplace_back( @@ -685,7 +685,7 @@ void FunctionEmitter::PushGuard(const std::string& guard_name, auto* cond = create( Source{}, ast_module_.RegisterSymbol(guard_name), guard_name); - auto* body = create(); + auto* body = create(Source{}); AddStatement( create(Source{}, cond, body, ast::ElseStatementList{})); PushNewStatementBlock(top.construct_, end_id, body, nullptr, nullptr); @@ -696,7 +696,7 @@ void FunctionEmitter::PushTrueGuard(uint32_t end_id) { const auto& top = statements_stack_.back(); auto* cond = MakeTrue(Source{}); - auto* body = create(); + auto* body = create(Source{}); AddStatement( create(Source{}, cond, body, ast::ElseStatementList{})); PushNewStatementBlock(top.construct_, end_id, body, nullptr, nullptr); @@ -1865,7 +1865,7 @@ bool FunctionEmitter::EmitFunctionVariables() { auto* var = parser_impl_.MakeVariable( inst.result_id(), ast::StorageClass::kFunction, var_store_type, false, constructor, ast::VariableDecorationList{}); - auto* var_decl_stmt = create(var); + auto* var_decl_stmt = create(Source{}, var); AddStatement(var_decl_stmt); // Save this as an already-named value. identifier_values_.insert(inst.result_id()); @@ -2145,14 +2145,14 @@ bool FunctionEmitter::EmitIfStart(const BlockInfo& block_info) { false, // is_const MakeTrue(Source{}), // constructor ast::VariableDecorationList{}); // decorations - auto* guard_decl = create(guard_var); + auto* guard_decl = create(Source{}, guard_var); AddStatement(guard_decl); } const auto condition_id = block_info.basic_block->terminator()->GetSingleWordInOperand(0); auto* cond = MakeExpression(condition_id).expr; - auto* body = create(); + auto* body = create(Source{}); // Generate the code for the condition. // Use the IfBuilder to create the if-statement. The IfBuilder is constructed @@ -2227,7 +2227,7 @@ bool FunctionEmitter::EmitIfStart(const BlockInfo& block_info) { // But make sure we do it in the right order. auto push_else = [this, if_builder, else_end, construct]() { // Push the else clause onto the stack first. - auto* else_body = create(); + auto* else_body = create(Source{}); PushNewStatementBlock( construct, else_end, else_body, nullptr, [this, if_builder, else_body]() { @@ -2236,7 +2236,7 @@ bool FunctionEmitter::EmitIfStart(const BlockInfo& block_info) { // The "else" consists of the statement list from the top of // statements stack, without an elseif condition. if_builder->else_stmts_.emplace_back( - create(nullptr, else_body)); + create(Source{}, nullptr, else_body)); } }); }; @@ -2294,7 +2294,7 @@ bool FunctionEmitter::EmitSwitchStart(const BlockInfo& block_info) { // First, push the statement block for the entire switch. ast::CaseStatementList case_list; - auto* swch = create(selector.expr, case_list); + auto* swch = create(Source{}, selector.expr, case_list); AddStatement(swch)->As(); // Grab a pointer to the case list. It will get buried in the statement block @@ -2369,17 +2369,18 @@ bool FunctionEmitter::EmitSwitchStart(const BlockInfo& block_info) { // Create the case clause. Temporarily put it in the wrong order // on the case statement list. - auto* body = create(); - cases->emplace_back(create(selectors, body)); + auto* body = create(Source{}); + cases->emplace_back(create(Source{}, selectors, body)); PushNewStatementBlock(construct, end_id, body, nullptr, nullptr); if ((default_info == clause_heads[i]) && has_selectors && construct->ContainsPos(default_info->pos)) { // Generate a default clause with a just fallthrough. - auto* stmts = create(); - stmts->append(create()); - auto* case_stmt = create(stmts); + auto* stmts = create(Source{}); + stmts->append(create(Source{})); + auto* case_stmt = + create(Source{}, ast::CaseSelectorList{}, stmts); cases->emplace_back(case_stmt); } @@ -2396,8 +2397,9 @@ bool FunctionEmitter::EmitSwitchStart(const BlockInfo& block_info) { } bool FunctionEmitter::EmitLoopStart(const Construct* construct) { - auto* body = create(); - AddStatement(create(body, create())); + auto* body = create(Source{}); + AddStatement(create( + Source{}, body, create(Source{}))); PushNewStatementBlock(construct, construct->end_id, body, nullptr, nullptr); return success(); } @@ -2431,7 +2433,7 @@ bool FunctionEmitter::EmitNormalTerminator(const BlockInfo& block_info) { case SpvOpKill: // For now, assume SPIR-V OpKill has same semantics as WGSL discard. // TODO(dneto): https://github.com/gpuweb/gpuweb/issues/676 - AddStatement(create()); + AddStatement(create(Source{})); return true; case SpvOpUnreachable: // Translate as if it's a return. This avoids the problem where WGSL @@ -2525,7 +2527,7 @@ ast::Statement* FunctionEmitter::MakeBranchDetailed( break; case EdgeKind::kSwitchBreak: { if (forced) { - return create(); + return create(Source{}); } // Unless forced, don't bother with a break at the end of a case/default // clause. @@ -2550,10 +2552,10 @@ ast::Statement* FunctionEmitter::MakeBranchDetailed( } } // We need a break. - return create(); + return create(Source{}); } case EdgeKind::kLoopBreak: - return create(); + return create(Source{}); case EdgeKind::kLoopContinue: // An unconditional continue to the next block is redundant and ugly. // Skip it in that case. @@ -2561,7 +2563,7 @@ ast::Statement* FunctionEmitter::MakeBranchDetailed( break; } // Otherwise, emit a regular continue statement. - return create(); + return create(Source{}); case EdgeKind::kIfBreak: { const auto& flow_guard = GetBlockInfo(dest_info.header_for_merge)->flow_guard_name; @@ -2571,6 +2573,7 @@ ast::Statement* FunctionEmitter::MakeBranchDetailed( } // Signal an exit from the branch. return create( + Source{}, create( Source{}, ast_module_.RegisterSymbol(flow_guard), flow_guard), MakeFalse(Source{})); @@ -2581,7 +2584,7 @@ ast::Statement* FunctionEmitter::MakeBranchDetailed( break; } case EdgeKind::kCaseFallThrough: - return create(); + return create(Source{}); case EdgeKind::kForward: // Unconditional forward branch is implicit. break; @@ -2597,11 +2600,12 @@ ast::Statement* FunctionEmitter::MakeSimpleIf(ast::Expression* condition, } ast::ElseStatementList else_stmts; if (else_stmt != nullptr) { - auto* stmts = create(); + auto* stmts = create(Source{}); stmts->append(else_stmt); - else_stmts.emplace_back(create(nullptr, stmts)); + else_stmts.emplace_back( + create(Source{}, nullptr, stmts)); } - auto* if_block = create(); + auto* if_block = create(Source{}); auto* if_stmt = create(Source{}, condition, if_block, else_stmts); if (then_stmt != nullptr) { @@ -2649,7 +2653,7 @@ bool FunctionEmitter::EmitConditionalCaseFallThrough( } else { AddStatement(MakeSimpleIf(cond, other_branch, nullptr)); } - AddStatement(create()); + AddStatement(create(Source{})); return success(); } @@ -2676,9 +2680,10 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info, assert(def_inst); auto* ast_type = RemapStorageClass(parser_impl_.ConvertType(def_inst->type_id()), id); - AddStatement(create(parser_impl_.MakeVariable( - id, ast::StorageClass::kFunction, ast_type, false, nullptr, - ast::VariableDecorationList{}))); + AddStatement(create( + Source{}, parser_impl_.MakeVariable(id, ast::StorageClass::kFunction, + ast_type, false, nullptr, + ast::VariableDecorationList{}))); // Save this as an already-named value. identifier_values_.insert(id); } @@ -2696,7 +2701,7 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info, false, // is_const nullptr, // constructor ast::VariableDecorationList{}); // decorations - AddStatement(create(var)); + AddStatement(create(Source{}, var)); } // Emit regular statements. @@ -2727,6 +2732,7 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info, const auto var_name = GetDefInfo(assignment.phi_id)->phi_var; auto expr = MakeExpression(assignment.value); AddStatement(create( + Source{}, create( Source{}, ast_module_.RegisterSymbol(var_name), var_name), expr.expr)); @@ -2749,7 +2755,7 @@ bool FunctionEmitter::EmitConstDefinition( if (!ast_const) { return false; } - AddStatement(create(ast_const)); + AddStatement(create(Source{}, ast_const)); // Save this as an already-named value. identifier_values_.insert(inst.result_id()); return success(); @@ -2764,6 +2770,7 @@ bool FunctionEmitter::EmitConstDefOrWriteToHoistedVar( auto name = namer_.Name(result_id); // Emit an assignment of the expression to the hoisted variable. AddStatement(create( + Source{}, create( Source{}, ast_module_.RegisterSymbol(name), namer_.Name(result_id)), ast_expr.expr)); @@ -2833,7 +2840,8 @@ bool FunctionEmitter::EmitStatement(const spvtools::opt::Instruction& inst) { // TODO(dneto): Order of evaluation? auto lhs = MakeExpression(ptr_id); auto rhs = MakeExpression(value_id); - AddStatement(create(lhs.expr, rhs.expr)); + AddStatement( + create(Source{}, lhs.expr, rhs.expr)); return success(); } case SpvOpLoad: { @@ -3743,7 +3751,8 @@ bool FunctionEmitter::EmitFunctionCall(const spvtools::opt::Instruction& inst) { } if (result_type->Is()) { - return nullptr != AddStatement(create(call_expr)); + return nullptr != + AddStatement(create(Source{}, call_expr)); } return EmitConstDefOrWriteToHoistedVar(inst, {result_type, call_expr}); @@ -3800,7 +3809,8 @@ TypedExpression FunctionEmitter::MakeSimpleSelect( // The condition goes last. params.push_back(condition.expr); return {operand1.type, - create(Source{}, + create( + Source{}, create( Source{}, ast_module_.RegisterSymbol("select"), "select"), std::move(params))}; @@ -4014,7 +4024,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) { } else { // It's an image write. No value is returned, so make a statement out // of the call. - AddStatement(create(call_expr)); + AddStatement(create(Source{}, call_expr)); } return success(); } @@ -4182,10 +4192,11 @@ ast::Expression* FunctionEmitter::ConvertTexelForStorage( } // If the texel has more components than necessary, then we will ignore the // higher-numbered components. - auto* texel_prefix = (src_count == dest_count) - ? texel.expr - : create(Source{}, - texel.expr, PrefixSwizzle(dest_count)); + auto* texel_prefix = + (src_count == dest_count) + ? texel.expr + : create(Source{}, texel.expr, + PrefixSwizzle(dest_count)); if (!(dest_type->is_float_scalar_or_vector() || dest_type->is_unsigned_scalar_or_vector() || diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 706187587f..65fb63a063 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -1438,7 +1438,7 @@ Expect ParserImpl::expect_paren_rhs_stmt() { // : statement* Expect ParserImpl::expect_statements() { bool errored = false; - auto* ret = create(); + auto* ret = create(Source{}); while (synchronized_) { auto stmt = statement(); @@ -1724,7 +1724,7 @@ Maybe ParserImpl::else_stmt() { if (body.errored) return Failure::kErrored; - return create(source, body.value); + return create(source, nullptr, body.value); } // switch_stmt @@ -1827,7 +1827,7 @@ Expect ParserImpl::expect_case_selectors() { // | statement case_body // | FALLTHROUGH SEMICOLON Maybe ParserImpl::case_body() { - auto* ret = create(); + auto* ret = create(Source{}); for (;;) { Source source; if (match(Token::Type::kFallthrough, &source)) { @@ -2026,11 +2026,12 @@ Maybe ParserImpl::func_call_stmt() { if (!expect("call statement", Token::Type::kParenRight)) return Failure::kErrored; - return create(create( - source, - create(Source{}, module_.RegisterSymbol(name), - name), - std::move(params))); + return create( + Source{}, create( + source, + create( + source, module_.RegisterSymbol(name), name), + std::move(params))); } // break_stmt @@ -2057,7 +2058,7 @@ Maybe ParserImpl::continue_stmt() { // : CONTINUING body_stmt Maybe ParserImpl::continuing_stmt() { if (!match(Token::Type::kContinuing)) - return create(); + return create(Source{}); return expect_body_stmt(); } diff --git a/src/transform/bound_array_accessors_test.cc b/src/transform/bound_array_accessors_test.cc index 24a7242c49..2f878d025d 100644 --- a/src/transform/bound_array_accessors_test.cc +++ b/src/transform/bound_array_accessors_test.cc @@ -91,7 +91,7 @@ class BoundArrayAccessorsTest : public testing::Test { }; struct ModuleBuilder : public ast::BuilderWithModule { - ModuleBuilder() : body_(create()) { + ModuleBuilder() : body_(create(Source{})) { mod->AddFunction(create( Source{}, mod->RegisterSymbol("func"), "func", ast::VariableList{}, ty.void_, body_, ast::FunctionDecorationList{})); @@ -106,7 +106,7 @@ struct ModuleBuilder : public ast::BuilderWithModule { virtual void Build() = 0; void OnVariableBuilt(ast::Variable* var) override { ASSERT_NE(body_, nullptr); - body_->append(create(var)); + body_->append(create(Source{}, var)); } ast::BlockStatement* body_ = nullptr; }; diff --git a/src/transform/emit_vertex_point_size.cc b/src/transform/emit_vertex_point_size.cc index 14d79e259e..1d22a26ea0 100644 --- a/src/transform/emit_vertex_point_size.cc +++ b/src/transform/emit_vertex_point_size.cc @@ -65,12 +65,12 @@ Transform::Output EmitVertexPointSize::Run(ast::Module* in) { mod->AddGlobalVariable(pointsize_var); // Build the AST expression & statement for assigning pointsize one. - auto* one = mod->create(Source{}, - mod->create(Source{}, f32, 1.0f)); + auto* one = mod->create( + Source{}, mod->create(Source{}, f32, 1.0f)); auto* pointsize_ident = mod->create( Source{}, mod->RegisterSymbol(kPointSizeVar), kPointSizeVar); auto* pointsize_assign = - mod->create(pointsize_ident, one); + mod->create(Source{}, pointsize_ident, one); // Add the pointsize assignment statement to the front of all vertex stages. for (auto* func : mod->functions()) { diff --git a/src/transform/emit_vertex_point_size_test.cc b/src/transform/emit_vertex_point_size_test.cc index f0d6ba8ba7..d6f56273bd 100644 --- a/src/transform/emit_vertex_point_size_test.cc +++ b/src/transform/emit_vertex_point_size_test.cc @@ -56,8 +56,8 @@ TEST_F(EmitVertexPointSizeTest, VertexStageBasic) { auto* block = create(Source{}); block->append(create( - Var("builtin_assignments_should_happen_before_this", - tint::ast::StorageClass::kFunction, ty.f32))); + Source{}, Var("builtin_assignments_should_happen_before_this", + tint::ast::StorageClass::kFunction, ty.f32))); auto a_sym = mod->RegisterSymbol("non_entry_a"); mod->AddFunction(create( diff --git a/src/transform/first_index_offset.cc b/src/transform/first_index_offset.cc index 5f1e0266f3..81e9bc32f3 100644 --- a/src/transform/first_index_offset.cc +++ b/src/transform/first_index_offset.cc @@ -270,7 +270,7 @@ ast::VariableDeclStatement* FirstIndexOffset::CreateFirstIndexOffset( true, // is_const constructor, // constructor ast::VariableDecorationList{}); // decorations - return mod->create(var); + return mod->create(Source{}, var); } } // namespace transform diff --git a/src/transform/first_index_offset_test.cc b/src/transform/first_index_offset_test.cc index 0ac7cfcc62..88196b39cd 100644 --- a/src/transform/first_index_offset_test.cc +++ b/src/transform/first_index_offset_test.cc @@ -61,7 +61,7 @@ struct ModuleBuilder : public ast::BuilderWithModule { ast::VariableList params = {}) { auto* func = create( Source{}, mod->RegisterSymbol(name), name, std::move(params), ty.u32, - create(), ast::FunctionDecorationList()); + create(Source{}), ast::FunctionDecorationList()); mod->AddFunction(func); return func; } diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc index 96f7588f10..41a42c2fe9 100644 --- a/src/transform/vertex_pulling.cc +++ b/src/transform/vertex_pulling.cc @@ -292,18 +292,18 @@ void VertexPulling::State::AddVertexPullingPreamble( // location. // A block statement allowing us to use append instead of insert - auto* block = mod->create(); + auto* block = mod->create(Source{}); // Declare the |kPullingPosVarName| variable in the shader - auto* pos_declaration = - mod->create(mod->create( - Source{}, // source - kPullingPosVarName, // name - ast::StorageClass::kFunction, // storage_class - GetI32Type(), // type - false, // is_const - nullptr, // constructor - ast::VariableDecorationList{})); // decorations + auto* pos_declaration = mod->create( + Source{}, mod->create( + Source{}, // source + kPullingPosVarName, // name + ast::StorageClass::kFunction, // storage_class + GetI32Type(), // type + false, // is_const + nullptr, // constructor + ast::VariableDecorationList{})); // decorations // |kPullingPosVarName| refers to the byte location of the current read. We // declare a variable in the shader to avoid having to reuse Expression @@ -338,10 +338,11 @@ void VertexPulling::State::AddVertexPullingPreamble( // Update position of the read auto* set_pos_expr = mod->create( - CreatePullingPositionIdent(), pos_value); + Source{}, CreatePullingPositionIdent(), pos_value); block->append(set_pos_expr); block->append(mod->create( + Source{}, mod->create( Source{}, mod->RegisterSymbol(v->name()), v->name()), AccessByFormat(i, attribute_desc.format))); diff --git a/src/transform/vertex_pulling_test.cc b/src/transform/vertex_pulling_test.cc index 8d950d5446..b066e16563 100644 --- a/src/transform/vertex_pulling_test.cc +++ b/src/transform/vertex_pulling_test.cc @@ -48,7 +48,7 @@ class VertexPullingHelper { void InitBasicModule() { auto* func = create( Source{}, mod_->RegisterSymbol("main"), "main", ast::VariableList{}, - mod_->create(), create(), + mod_->create(), create(Source{}), ast::FunctionDecorationList{create( ast::PipelineStage::kVertex, Source{})}); mod()->AddFunction(func); @@ -135,7 +135,7 @@ TEST_F(VertexPullingTest, Error_InvalidEntryPoint) { TEST_F(VertexPullingTest, Error_EntryPointWrongStage) { auto* func = create( Source{}, mod()->RegisterSymbol("main"), "main", ast::VariableList{}, - mod()->create(), create(), + mod()->create(), create(Source{}), ast::FunctionDecorationList{ create(ast::PipelineStage::kFragment, Source{}), }); diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index db2bed68df..182f77bbda 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -132,7 +132,7 @@ TEST_F(TypeDeterminerTest, Stmt_Assign) { auto* rhs = create( Source{}, create(Source{}, &f32, 2.3f)); - ast::AssignmentStatement assign(lhs, rhs); + ast::AssignmentStatement assign(Source{}, lhs, rhs); EXPECT_TRUE(td()->DetermineResultType(&assign)); ASSERT_NE(lhs->result_type(), nullptr); @@ -151,12 +151,12 @@ TEST_F(TypeDeterminerTest, Stmt_Case) { auto* rhs = create( Source{}, create(Source{}, &f32, 2.3f)); - auto* body = create(); - body->append(create(lhs, rhs)); + auto* body = create(Source{}); + body->append(create(Source{}, lhs, rhs)); ast::CaseSelectorList lit; lit.push_back(create(Source{}, &i32, 3)); - ast::CaseStatement cse(lit, body); + ast::CaseStatement cse(Source{}, lit, body); EXPECT_TRUE(td()->DetermineResultType(&cse)); ASSERT_NE(lhs->result_type(), nullptr); @@ -174,8 +174,8 @@ TEST_F(TypeDeterminerTest, Stmt_Block) { auto* rhs = create( Source{}, create(Source{}, &f32, 2.3f)); - ast::BlockStatement block; - block.append(create(lhs, rhs)); + ast::BlockStatement block(Source{}); + block.append(create(Source{}, lhs, rhs)); EXPECT_TRUE(td()->DetermineResultType(&block)); ASSERT_NE(lhs->result_type(), nullptr); @@ -193,10 +193,11 @@ TEST_F(TypeDeterminerTest, Stmt_Else) { auto* rhs = create( Source{}, create(Source{}, &f32, 2.3f)); - auto* body = create(); - body->append(create(lhs, rhs)); + auto* body = create(Source{}); + body->append(create(Source{}, lhs, rhs)); ast::ElseStatement stmt( + Source{}, create( Source{}, create(Source{}, &i32, 3)), body); @@ -219,10 +220,12 @@ TEST_F(TypeDeterminerTest, Stmt_If) { auto* else_rhs = create( Source{}, create(Source{}, &f32, 2.3f)); - auto* else_body = create(); - else_body->append(create(else_lhs, else_rhs)); + auto* else_body = create(Source{}); + else_body->append( + create(Source{}, else_lhs, else_rhs)); auto* else_stmt = create( + Source{}, create( Source{}, create(Source{}, &i32, 3)), else_body); @@ -232,8 +235,8 @@ TEST_F(TypeDeterminerTest, Stmt_If) { auto* rhs = create( Source{}, create(Source{}, &f32, 2.3f)); - auto* body = create(); - body->append(create(lhs, rhs)); + auto* body = create(Source{}); + body->append(create(Source{}, lhs, rhs)); ast::IfStatement stmt( Source{}, @@ -263,19 +266,19 @@ TEST_F(TypeDeterminerTest, Stmt_Loop) { auto* body_rhs = create( Source{}, create(Source{}, &f32, 2.3f)); - auto* body = create(); - body->append(create(body_lhs, body_rhs)); + auto* body = create(Source{}); + body->append(create(Source{}, body_lhs, body_rhs)); auto* continuing_lhs = create( Source{}, create(Source{}, &i32, 2)); auto* continuing_rhs = create( Source{}, create(Source{}, &f32, 2.3f)); - auto* continuing = create(); - continuing->append( - create(continuing_lhs, continuing_rhs)); + auto* continuing = create(Source{}); + continuing->append(create(Source{}, continuing_lhs, + continuing_rhs)); - ast::LoopStatement stmt(body, continuing); + ast::LoopStatement stmt(Source{}, body, continuing); EXPECT_TRUE(td()->DetermineResultType(&stmt)); ASSERT_NE(body_lhs->result_type(), nullptr); @@ -316,16 +319,17 @@ TEST_F(TypeDeterminerTest, Stmt_Switch) { auto* rhs = create( Source{}, create(Source{}, &f32, 2.3f)); - auto* body = create(); - body->append(create(lhs, rhs)); + auto* body = create(Source{}); + body->append(create(Source{}, lhs, rhs)); ast::CaseSelectorList lit; lit.push_back(create(Source{}, &i32, 3)); ast::CaseStatementList cases; - cases.push_back(create(lit, body)); + cases.push_back(create(Source{}, lit, body)); ast::SwitchStatement stmt( + Source{}, create( Source{}, create(Source{}, &i32, 2)), cases); @@ -346,7 +350,7 @@ TEST_F(TypeDeterminerTest, Stmt_Call) { ast::VariableList params; auto* func = create( Source{}, mod->RegisterSymbol("my_func"), "my_func", params, &f32, - create(), ast::FunctionDecorationList{}); + create(Source{}), ast::FunctionDecorationList{}); mod->AddFunction(func); // Register the function @@ -359,7 +363,7 @@ TEST_F(TypeDeterminerTest, Stmt_Call) { Source{}, mod->RegisterSymbol("my_func"), "my_func"), call_params); - ast::CallStatement call(expr); + ast::CallStatement call(Source{}, expr); EXPECT_TRUE(td()->DetermineResultType(&call)); ASSERT_NE(expr->result_type(), nullptr); EXPECT_TRUE(expr->result_type()->Is()); @@ -376,15 +380,15 @@ TEST_F(TypeDeterminerTest, Stmt_Call_undeclared) { mod->RegisterSymbol("func"), "func"), call_params); ast::VariableList params0; - auto* main_body = create(); - main_body->append(create(call_expr)); + auto* main_body = create(Source{}); + main_body->append(create(Source{}, call_expr)); main_body->append(create(Source{})); auto* func_main = create(Source{}, mod->RegisterSymbol("main"), "main", params0, &f32, main_body, ast::FunctionDecorationList{}); mod->AddFunction(func_main); - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create(Source{}, mod->RegisterSymbol("func"), "func", @@ -410,7 +414,7 @@ TEST_F(TypeDeterminerTest, Stmt_VariableDecl) { ast::VariableDecorationList{}); // decorations auto* init = var->constructor(); - ast::VariableDeclStatement decl(var); + ast::VariableDeclStatement decl(Source{}, var); EXPECT_TRUE(td()->DetermineResultType(&decl)); ASSERT_NE(init->result_type(), nullptr); @@ -671,7 +675,7 @@ TEST_F(TypeDeterminerTest, Expr_Call) { ast::VariableList params; auto* func = create( Source{}, mod->RegisterSymbol("my_func"), "my_func", params, &f32, - create(), ast::FunctionDecorationList{}); + create(Source{}), ast::FunctionDecorationList{}); mod->AddFunction(func); // Register the function @@ -694,7 +698,7 @@ TEST_F(TypeDeterminerTest, Expr_Call_WithParams) { ast::VariableList params; auto* func = create( Source{}, mod->RegisterSymbol("my_func"), "my_func", params, &f32, - create(), ast::FunctionDecorationList{}); + create(Source{}), ast::FunctionDecorationList{}); mod->AddFunction(func); // Register the function @@ -847,11 +851,12 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable_Const) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create( - my_var, create( - Source{}, mod->RegisterSymbol("my_var"), "my_var"))); + Source{}, my_var, + create(Source{}, mod->RegisterSymbol("my_var"), + "my_var"))); ast::Function f(Source{}, mod->RegisterSymbol("my_func"), "my_func", {}, &f32, body, ast::FunctionDecorationList{}); @@ -868,8 +873,9 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable) { auto* my_var = create( Source{}, mod->RegisterSymbol("my_var"), "my_var"); - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, // source "my_var", // name ast::StorageClass::kNone, // storage_class @@ -879,8 +885,9 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable) { ast::VariableDecorationList{}))); // decorations body->append(create( - my_var, create( - Source{}, mod->RegisterSymbol("my_var"), "my_var"))); + Source{}, my_var, + create(Source{}, mod->RegisterSymbol("my_var"), + "my_var"))); ast::Function f(Source{}, mod->RegisterSymbol("myfunc"), "my_func", {}, &f32, body, ast::FunctionDecorationList{}); @@ -902,8 +909,9 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) { auto* my_var = create( Source{}, mod->RegisterSymbol("my_var"), "my_var"); - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, // source "my_var", // name ast::StorageClass::kNone, // storage_class @@ -913,8 +921,9 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) { ast::VariableDecorationList{}))); // decorations body->append(create( - my_var, create( - Source{}, mod->RegisterSymbol("my_var"), "my_var"))); + Source{}, my_var, + create(Source{}, mod->RegisterSymbol("my_var"), + "my_var"))); ast::Function f(Source{}, mod->RegisterSymbol("my_func"), "my_func", {}, &f32, body, ast::FunctionDecorationList{}); @@ -935,7 +944,7 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Function) { ast::VariableList params; auto* func = create( Source{}, mod->RegisterSymbol("my_func"), "my_func", params, &f32, - create(), ast::FunctionDecorationList{}); + create(Source{}), ast::FunctionDecorationList{}); mod->AddFunction(func); // Register the function @@ -1004,23 +1013,27 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) { mod->AddGlobalVariable(priv_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create( Source{}, mod->RegisterSymbol("out_var"), "out_var"), create(Source{}, mod->RegisterSymbol("in_var"), "in_var"))); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("wg_var"), "wg_var"), create(Source{}, mod->RegisterSymbol("wg_var"), "wg_var"))); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("sb_var"), "sb_var"), create(Source{}, mod->RegisterSymbol("sb_var"), "sb_var"))); body->append(create( + Source{}, create( Source{}, mod->RegisterSymbol("priv_var"), "priv_var"), create( @@ -1093,23 +1106,27 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) { mod->AddGlobalVariable(wg_var); mod->AddGlobalVariable(priv_var); - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create( Source{}, mod->RegisterSymbol("out_var"), "out_var"), create(Source{}, mod->RegisterSymbol("in_var"), "in_var"))); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("wg_var"), "wg_var"), create(Source{}, mod->RegisterSymbol("wg_var"), "wg_var"))); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("sb_var"), "sb_var"), create(Source{}, mod->RegisterSymbol("sb_var"), "sb_var"))); body->append(create( + Source{}, create( Source{}, mod->RegisterSymbol("priv_var"), "priv_var"), create( @@ -1121,8 +1138,9 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) { mod->AddFunction(func); - body = create(); + body = create(Source{}); body->append(create( + Source{}, create( Source{}, mod->RegisterSymbol("out_var"), "out_var"), create( @@ -1160,9 +1178,10 @@ TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("var"), "var"), create( @@ -2839,9 +2858,9 @@ TEST_F(TypeDeterminerTest, StorageClass_SetsIfMissing) { false, // is_const nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* stmt = create(var); + auto* stmt = create(Source{}, var); - auto* body = create(); + auto* body = create(Source{}); body->append(stmt); auto* func = create(Source{}, mod->RegisterSymbol("func"), "func", ast::VariableList{}, &i32, body, @@ -2864,9 +2883,9 @@ TEST_F(TypeDeterminerTest, StorageClass_DoesNotSetOnConst) { true, // is_const nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* stmt = create(var); + auto* stmt = create(Source{}, var); - auto* body = create(); + auto* body = create(Source{}); body->append(stmt); auto* func = create(Source{}, mod->RegisterSymbol("func"), "func", ast::VariableList{}, &i32, body, @@ -2889,9 +2908,9 @@ TEST_F(TypeDeterminerTest, StorageClass_NonFunctionClassError) { false, // is_const nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* stmt = create(var); + auto* stmt = create(Source{}, var); - auto* body = create(); + auto* body = create(Source{}); body->append(stmt); auto* func = create(Source{}, mod->RegisterSymbol("func"), "func", ast::VariableList{}, &i32, body, @@ -5209,13 +5228,14 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) { // ep_2 -> {} ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); auto* func_b = create(Source{}, mod->RegisterSymbol("b"), "b", params, &f32, body, ast::FunctionDecorationList{}); - body = create(); + body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("second"), "second"), create(Source{}, @@ -5226,8 +5246,9 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) { create(Source{}, mod->RegisterSymbol("c"), "c", params, &f32, body, ast::FunctionDecorationList{}); - body = create(); + body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("first"), "first"), create(Source{}, @@ -5238,8 +5259,9 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) { create(Source{}, mod->RegisterSymbol("a"), "a", params, &f32, body, ast::FunctionDecorationList{}); - body = create(); + body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("call_a"), "call_a"), create(Source{}, @@ -5247,6 +5269,7 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) { Source{}, mod->RegisterSymbol("a"), "a"), ast::ExpressionList{}))); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("call_b"), "call_b"), create(Source{}, @@ -5259,8 +5282,9 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) { create(ast::PipelineStage::kVertex, Source{}), }); - body = create(); + body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("call_c"), "call_c"), create(Source{}, diff --git a/src/validator/validator_control_block_test.cc b/src/validator/validator_control_block_test.cc index 4076fba1a6..55a44acef9 100644 --- a/src/validator/validator_control_block_test.cc +++ b/src/validator/validator_control_block_test.cc @@ -57,13 +57,14 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) { auto* cond = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList default_csl; - auto* block_default = create(); + auto* block_default = create(Source{}); ast::CaseStatementList body; - body.push_back(create(default_csl, block_default)); + body.push_back( + create(Source{}, default_csl, block_default)); - auto* block = create(); - block->append(create(var)); - block->append(create(cond, body)); + auto* block = create(Source{}); + block->append(create(Source{}, var)); + block->append(create(Source{}, cond, body)); EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error(); EXPECT_FALSE(v()->ValidateStatements(block)); @@ -94,11 +95,11 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_Fail) { ast::CaseSelectorList csl; csl.push_back(create(Source{}, &i32, 1)); ast::CaseStatementList body; - body.push_back( - create(csl, create())); + body.push_back(create( + Source{}, csl, create(Source{}))); - auto* block = create(); - block->append(create(var)); + auto* block = create(Source{}); + block->append(create(Source{}, var)); block->append(create(Source{Source::Location{12, 34}}, cond, body)); @@ -133,22 +134,23 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) { Source{}, mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList default_csl_1; - auto* block_default_1 = create(); + auto* block_default_1 = create(Source{}); switch_body.push_back( - create(default_csl_1, block_default_1)); + create(Source{}, default_csl_1, block_default_1)); ast::CaseSelectorList csl_case_1; csl_case_1.push_back(create(Source{}, &i32, 1)); - auto* block_case_1 = create(); - switch_body.push_back(create(csl_case_1, block_case_1)); + auto* block_case_1 = create(Source{}); + switch_body.push_back( + create(Source{}, csl_case_1, block_case_1)); ast::CaseSelectorList default_csl_2; - auto* block_default_2 = create(); + auto* block_default_2 = create(Source{}); switch_body.push_back( - create(default_csl_2, block_default_2)); + create(Source{}, default_csl_2, block_default_2)); - auto* block = create(); - block->append(create(var)); + auto* block = create(Source{}); + block->append(create(Source{}, var)); block->append(create(Source{Source::Location{12, 34}}, cond, switch_body)); @@ -185,16 +187,18 @@ TEST_F(ValidateControlBlockTest, ast::CaseSelectorList csl; csl.push_back(create(Source{}, &u32, 1)); - switch_body.push_back(create( - Source{Source::Location{12, 34}}, csl, create())); + switch_body.push_back( + create(Source{Source::Location{12, 34}}, csl, + create(Source{}))); ast::CaseSelectorList default_csl; - auto* block_default = create(); - switch_body.push_back(create(default_csl, block_default)); + auto* block_default = create(Source{}); + switch_body.push_back( + create(Source{}, default_csl, block_default)); - auto* block = create(); - block->append(create(var)); - block->append(create(cond, switch_body)); + auto* block = create(Source{}); + block->append(create(Source{}, var)); + block->append(create(Source{}, cond, switch_body)); EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error(); EXPECT_FALSE(v()->ValidateStatements(block)); @@ -229,16 +233,18 @@ TEST_F(ValidateControlBlockTest, ast::CaseSelectorList csl; csl.push_back(create(Source{}, &i32, -1)); - switch_body.push_back(create( - Source{Source::Location{12, 34}}, csl, create())); + switch_body.push_back( + create(Source{Source::Location{12, 34}}, csl, + create(Source{}))); ast::CaseSelectorList default_csl; - auto* block_default = create(); - switch_body.push_back(create(default_csl, block_default)); + auto* block_default = create(Source{}); + switch_body.push_back( + create(Source{}, default_csl, block_default)); - auto* block = create(); - block->append(create(var)); - block->append(create(cond, switch_body)); + auto* block = create(Source{}); + block->append(create(Source{}, var)); + block->append(create(Source{}, cond, switch_body)); EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error(); EXPECT_FALSE(v()->ValidateStatements(block)); @@ -272,22 +278,24 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) { ast::CaseSelectorList csl_1; csl_1.push_back(create(Source{}, &u32, 0)); - switch_body.push_back( - create(csl_1, create())); + switch_body.push_back(create( + Source{}, csl_1, create(Source{}))); ast::CaseSelectorList csl_2; csl_2.push_back(create(Source{}, &u32, 2)); csl_2.push_back(create(Source{}, &u32, 2)); - switch_body.push_back(create( - Source{Source::Location{12, 34}}, csl_2, create())); + switch_body.push_back( + create(Source{Source::Location{12, 34}}, csl_2, + create(Source{}))); ast::CaseSelectorList default_csl; - auto* block_default = create(); - switch_body.push_back(create(default_csl, block_default)); + auto* block_default = create(Source{}); + switch_body.push_back( + create(Source{}, default_csl, block_default)); - auto* block = create(); - block->append(create(var)); - block->append(create(cond, switch_body)); + auto* block = create(Source{}); + block->append(create(Source{}, var)); + block->append(create(Source{}, cond, switch_body)); EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error(); EXPECT_FALSE(v()->ValidateStatements(block)); @@ -321,24 +329,26 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) { ast::CaseSelectorList csl_1; csl_1.push_back(create(Source{}, &i32, 10)); - switch_body.push_back( - create(csl_1, create())); + switch_body.push_back(create( + Source{}, csl_1, create(Source{}))); ast::CaseSelectorList csl_2; csl_2.push_back(create(Source{}, &i32, 0)); csl_2.push_back(create(Source{}, &i32, 1)); csl_2.push_back(create(Source{}, &i32, 2)); csl_2.push_back(create(Source{}, &i32, 10)); - switch_body.push_back(create( - Source{Source::Location{12, 34}}, csl_2, create())); + switch_body.push_back( + create(Source{Source::Location{12, 34}}, csl_2, + create(Source{}))); ast::CaseSelectorList default_csl; - auto* block_default = create(); - switch_body.push_back(create(default_csl, block_default)); + auto* block_default = create(Source{}); + switch_body.push_back( + create(Source{}, default_csl, block_default)); - auto* block = create(); - block->append(create(var)); - block->append(create(cond, switch_body)); + auto* block = create(Source{}); + block->append(create(Source{}, var)); + block->append(create(Source{}, cond, switch_body)); EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error(); EXPECT_FALSE(v()->ValidateStatements(block)); @@ -367,15 +377,16 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) { auto* cond = create( Source{}, mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList default_csl; - auto* block_default = create(); + auto* block_default = create(Source{}); block_default->append( create(Source{Source::Location{12, 34}})); ast::CaseStatementList body; - body.push_back(create(default_csl, block_default)); + body.push_back( + create(Source{}, default_csl, block_default)); - auto* block = create(); - block->append(create(var)); - block->append(create(cond, body)); + auto* block = create(Source{}); + block->append(create(Source{}, var)); + block->append(create(Source{}, cond, body)); EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error(); EXPECT_FALSE(v()->ValidateStatements(block)); @@ -405,18 +416,18 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) { auto* cond = create( Source{}, mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList default_csl; - auto* block_default = create(); + auto* block_default = create(Source{}); ast::CaseStatementList body; body.push_back(create(Source{Source::Location{12, 34}}, default_csl, block_default)); ast::CaseSelectorList case_csl; case_csl.push_back(create(Source{}, &i32, 5)); - auto* block_case = create(); - body.push_back(create(case_csl, block_case)); + auto* block_case = create(Source{}); + body.push_back(create(Source{}, case_csl, block_case)); - auto* block = create(); - block->append(create(var)); - block->append(create(cond, body)); + auto* block = create(Source{}); + block->append(create(Source{}, var)); + block->append(create(Source{}, cond, body)); EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error(); EXPECT_TRUE(v()->ValidateStatements(block)) << v()->error(); @@ -446,14 +457,14 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) { auto* cond = create( Source{}, mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList default_csl; - auto* block_default = create(); + auto* block_default = create(Source{}); ast::CaseStatementList body; body.push_back(create(Source{Source::Location{12, 34}}, default_csl, block_default)); - auto* block = create(); - block->append(create(var)); - block->append(create(cond, body)); + auto* block = create(Source{}); + block->append(create(Source{}, var)); + block->append(create(Source{}, cond, body)); mod()->AddConstructedType(&my_int); diff --git a/src/validator/validator_function_test.cc b/src/validator/validator_function_test.cc index 2078a1a21b..50420bc249 100644 --- a/src/validator/validator_function_test.cc +++ b/src/validator/validator_function_test.cc @@ -52,8 +52,8 @@ TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) { ast::VariableList params; ast::type::Void void_type; - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); auto* func = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("func"), "func", params, &void_type, body, @@ -74,7 +74,7 @@ TEST_F(ValidateFunctionTest, ast::VariableList params; auto* func = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("func"), "func", - params, &void_type, create(), + params, &void_type, create(Source{}), ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex, Source{}), }); @@ -101,8 +101,8 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) { ast::VariableList params; ast::type::Void void_type; - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); auto* func = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("func"), "func", params, &i32, body, ast::FunctionDecorationList{}); @@ -121,7 +121,7 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatementEmptyBody_Fail) { ast::VariableList params; auto* func = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("func"), "func", - params, &i32, create(), + params, &i32, create(Source{}), ast::FunctionDecorationList{}); mod()->AddFunction(func); @@ -137,7 +137,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) { ast::type::Void void_type; ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create( Source{}, mod()->RegisterSymbol("func"), "func", params, &void_type, body, @@ -155,7 +155,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) { ast::type::Void void_type; ast::type::I32 i32; ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); auto* return_expr = create( Source{}, create(Source{}, &i32, 2)); @@ -179,7 +179,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) { ast::type::I32 i32; ast::type::F32 f32; ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); auto* return_expr = create( Source{}, create(Source{}, &i32, 2)); @@ -205,7 +205,7 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) { ast::type::I32 i32; ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); auto* return_expr = create( Source{}, create(Source{}, &i32, 2)); @@ -215,7 +215,7 @@ TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) { params, &i32, body, ast::FunctionDecorationList{}); ast::VariableList params_copy; - auto* body_copy = create(); + auto* body_copy = create(Source{}); auto* return_expr_copy = create( Source{}, create(Source{}, &i32, 2)); @@ -243,8 +243,8 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) { "func"), call_params); ast::VariableList params0; - auto* body0 = create(); - body0->append(create(call_expr)); + auto* body0 = create(Source{}); + body0->append(create(Source{}, call_expr)); body0->append(create(Source{})); auto* func0 = create(Source{}, mod()->RegisterSymbol("func"), "func", params0, &f32, body0, @@ -275,8 +275,8 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) { ast::VariableDecorationList{}); // decorations ast::VariableList params0; - auto* body0 = create(); - body0->append(create(var)); + auto* body0 = create(Source{}); + body0->append(create(Source{}, var)); auto* return_expr = create( Source{}, create(Source{}, &i32, 2)); @@ -299,7 +299,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) { auto* return_expr = create( Source{}, create(Source{}, &i32, 0)); - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{}, return_expr)); auto* func = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("vtx_main"), @@ -329,7 +329,7 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_WithParams_Fail) { false, // is_const nullptr, // constructor ast::VariableDecorationList{})); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("vtx_func"), @@ -352,7 +352,7 @@ TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) { // fn main() -> void { return; } ast::type::Void void_type; ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("main"), "main", @@ -375,7 +375,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) { // fn vtx_func() -> void { return; } ast::type::Void void_type; ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create( Source{}, mod()->RegisterSymbol("vtx_func"), "vtx_func", params, @@ -393,7 +393,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Fail) { // fn vtx_func() -> void { return; } ast::type::Void void_type; ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create( Source{}, mod()->RegisterSymbol("vtx_func"), "vtx_func", params, diff --git a/src/validator/validator_test.cc b/src/validator/validator_test.cc index a3cac0e308..765ebee210 100644 --- a/src/validator/validator_test.cc +++ b/src/validator/validator_test.cc @@ -103,7 +103,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInBlockStatement_Fail) { auto* rhs = create( Source{}, create(Source{}, &i32, 2)); - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{Source::Location{12, 34}}, lhs, rhs)); @@ -199,8 +199,8 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) { auto* rhs = create( Source{}, create(Source{}, &i32, 2)); - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create( Source{Source::Location{12, 34}}, lhs, rhs)); @@ -234,8 +234,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) { auto* rhs = create( Source{}, create(Source{}, &f32, 2.3f)); - ast::BlockStatement block; - block.append(create(var)); + ast::BlockStatement block(Source{}); + block.append(create(Source{}, var)); block.append(create( Source{Source::Location{12, 34}}, lhs, rhs)); @@ -339,7 +339,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) { Source{}, create(Source{}, &f32, 3.14f)); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{Source::Location{12, 34}}, lhs, rhs)); @@ -379,7 +379,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) { ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{Source::Location{12, 34}}, lhs, rhs)); body->append(create(Source{})); @@ -415,15 +415,15 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) { ast::type::Bool bool_type; auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); auto* lhs = create( Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a"); auto* rhs = create( Source{}, create(Source{}, &f32, 3.14f)); - auto* outer_body = create(); + auto* outer_body = create(Source{}); outer_body->append( create(Source{}, cond, body, ast::ElseStatementList{})); outer_body->append(create( @@ -461,12 +461,12 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) { ast::type::Bool bool_type; auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{Source::Location{12, 34}}, lhs, rhs)); - auto* outer_body = create(); - outer_body->append(create(var)); + auto* outer_body = create(Source{}); + outer_body->append(create(Source{}, var)); outer_body->append( create(Source{}, cond, body, ast::ElseStatementList{})); EXPECT_TRUE(td()->DetermineStatements(outer_body)) << td()->error(); @@ -564,8 +564,8 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) { auto* rhs = create( Source{}, create(Source{}, &i32, 2)); - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create( Source{Source::Location{12, 34}}, lhs, rhs)); @@ -609,7 +609,7 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) { create(Source{}, &f32, 2.0)), // constructor ast::VariableDecorationList{}); // decorations ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{Source::Location{12, 34}}, var)); auto* func = create(Source{}, mod()->RegisterSymbol("my_func"), @@ -655,8 +655,8 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) { ast::VariableDecorationList{}); // decorations ast::VariableList params; - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create( Source{Source::Location{12, 34}}, var_a_float)); auto* func = create(Source{}, mod()->RegisterSymbol("my_func"), @@ -691,8 +691,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) { ast::type::Bool bool_type; auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); auto* var_a_float = create( Source{}, // source @@ -705,7 +705,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) { create(Source{}, &f32, 3.14)), // constructor ast::VariableDecorationList{}); // decorations - auto* outer_body = create(); + auto* outer_body = create(Source{}); outer_body->append( create(Source{}, cond, body, ast::ElseStatementList{})); outer_body->append(create( @@ -748,12 +748,12 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) { ast::type::Bool bool_type; auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{Source::Location{12, 34}}, var)); - auto* outer_body = create(); - outer_body->append(create(var_a_float)); + auto* outer_body = create(Source{}); + outer_body->append(create(Source{}, var_a_float)); outer_body->append( create(Source{}, cond, body, ast::ElseStatementList{})); @@ -790,7 +790,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) { ast::VariableDecorationList{}); // decorations ast::VariableList params0; - auto* body0 = create(); + auto* body0 = create(Source{}); body0->append(create( Source{Source::Location{12, 34}}, var0)); body0->append(create(Source{})); @@ -799,7 +799,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) { ast::FunctionDecorationList{}); ast::VariableList params1; - auto* body1 = create(); + auto* body1 = create(Source{}); body1->append(create( Source{Source::Location{13, 34}}, var1)); body1->append(create(Source{})); @@ -838,8 +838,8 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) { auto* rhs = create( Source{}, create(Source{}, &i32, 2)); - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create( Source{Source::Location{12, 34}}, lhs, rhs)); diff --git a/src/validator/validator_type_test.cc b/src/validator/validator_type_test.cc index 0687ed9479..6cb0a7c9dc 100644 --- a/src/validator/validator_type_test.cc +++ b/src/validator/validator_type_test.cc @@ -203,7 +203,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) { ast::VariableDecorationList{}); // decorations ast::VariableList params; ast::type::Void void_type; - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{Source::Location{12, 34}}, var)); diff --git a/src/writer/hlsl/generator_impl_assign_test.cc b/src/writer/hlsl/generator_impl_assign_test.cc index 46e08bbdff..fcf37e87b7 100644 --- a/src/writer/hlsl/generator_impl_assign_test.cc +++ b/src/writer/hlsl/generator_impl_assign_test.cc @@ -32,7 +32,7 @@ TEST_F(HlslGeneratorImplTest_Assign, Emit_Assign) { Source{}, mod.RegisterSymbol("lhs"), "lhs"); auto* rhs = create( Source{}, mod.RegisterSymbol("rhs"), "rhs"); - ast::AssignmentStatement assign(lhs, rhs); + ast::AssignmentStatement assign(Source{}, lhs, rhs); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_binary_test.cc b/src/writer/hlsl/generator_impl_binary_test.cc index b32ae91d03..3c52f9de5d 100644 --- a/src/writer/hlsl/generator_impl_binary_test.cc +++ b/src/writer/hlsl/generator_impl_binary_test.cc @@ -464,17 +464,18 @@ TEST_F(HlslGeneratorImplTest_Binary, If_WithLogical) { ast::type::I32 i32; - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{}, create( Source{}, create(Source{}, &i32, 3)))); - auto* else_stmt = create(body); + auto* else_stmt = create(Source{}, nullptr, body); - body = create(); + body = create(Source{}); body->append(create( Source{}, create( Source{}, create(Source{}, &i32, 2)))); auto* else_if_stmt = create( + Source{}, create( Source{}, ast::BinaryOp::kLogicalOr, create(Source{}, mod.RegisterSymbol("b"), @@ -483,7 +484,7 @@ TEST_F(HlslGeneratorImplTest_Binary, If_WithLogical) { "c")), body); - body = create(); + body = create(Source{}); body->append(create( Source{}, create( Source{}, create(Source{}, &i32, 1)))); @@ -563,11 +564,12 @@ TEST_F(HlslGeneratorImplTest_Binary, Assign_WithLogical) { create(Source{}, mod.RegisterSymbol("d"), "d"); ast::AssignmentStatement expr( - a, create( - Source{}, ast::BinaryOp::kLogicalAnd, - create(Source{}, ast::BinaryOp::kLogicalOr, - b, c), - d)); + Source{}, a, + create( + Source{}, ast::BinaryOp::kLogicalAnd, + create(Source{}, ast::BinaryOp::kLogicalOr, b, + c), + d)); ASSERT_TRUE(gen.EmitStatement(out, &expr)) << gen.error(); EXPECT_EQ(result(), R"(bool _tint_tmp = b; @@ -606,7 +608,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Decl_WithLogical) { d), // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement expr(var); + ast::VariableDeclStatement expr(Source{}, var); ASSERT_TRUE(gen.EmitStatement(out, &expr)) << gen.error(); EXPECT_EQ(result(), R"(bool _tint_tmp = b; @@ -657,9 +659,10 @@ TEST_F(HlslGeneratorImplTest_Binary, Call_WithLogical) { ast::type::Void void_type; - auto* func = create( - Source{}, mod.RegisterSymbol("foo"), "foo", ast::VariableList{}, - &void_type, create(), ast::FunctionDecorationList{}); + auto* func = create(Source{}, mod.RegisterSymbol("foo"), "foo", + ast::VariableList{}, &void_type, + create(Source{}), + ast::FunctionDecorationList{}); mod.AddFunction(func); ast::ExpressionList params; @@ -688,11 +691,12 @@ TEST_F(HlslGeneratorImplTest_Binary, Call_WithLogical) { create(Source{}, mod.RegisterSymbol("d"), "d")))); - ast::CallStatement expr(create( - Source{}, - create(Source{}, mod.RegisterSymbol("foo"), - "foo"), - params)); + ast::CallStatement expr(Source{}, + create( + Source{}, + create( + Source{}, mod.RegisterSymbol("foo"), "foo"), + params)); ASSERT_TRUE(gen.EmitStatement(out, &expr)) << gen.error(); EXPECT_EQ(result(), R"(bool _tint_tmp = a; diff --git a/src/writer/hlsl/generator_impl_block_test.cc b/src/writer/hlsl/generator_impl_block_test.cc index 7f0194e2d4..01865880cd 100644 --- a/src/writer/hlsl/generator_impl_block_test.cc +++ b/src/writer/hlsl/generator_impl_block_test.cc @@ -26,8 +26,8 @@ namespace { using HlslGeneratorImplTest_Block = TestHelper; TEST_F(HlslGeneratorImplTest_Block, Emit_Block) { - ast::BlockStatement b; - b.append(create()); + ast::BlockStatement b(Source{}); + b.append(create(Source{})); gen.increment_indent(); @@ -39,8 +39,8 @@ TEST_F(HlslGeneratorImplTest_Block, Emit_Block) { } TEST_F(HlslGeneratorImplTest_Block, Emit_Block_WithoutNewline) { - ast::BlockStatement b; - b.append(create()); + ast::BlockStatement b(Source{}); + b.append(create(Source{})); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_break_test.cc b/src/writer/hlsl/generator_impl_break_test.cc index 3eb2f7faa7..d5a6e34660 100644 --- a/src/writer/hlsl/generator_impl_break_test.cc +++ b/src/writer/hlsl/generator_impl_break_test.cc @@ -27,7 +27,7 @@ namespace { using HlslGeneratorImplTest_Break = TestHelper; TEST_F(HlslGeneratorImplTest_Break, Emit_Break) { - ast::BreakStatement b; + ast::BreakStatement b(Source{}); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_call_test.cc b/src/writer/hlsl/generator_impl_call_test.cc index 60b9c22442..50d06d6002 100644 --- a/src/writer/hlsl/generator_impl_call_test.cc +++ b/src/writer/hlsl/generator_impl_call_test.cc @@ -36,9 +36,10 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) { Source{}, mod.RegisterSymbol("my_func"), "my_func"); ast::CallExpression call(Source{}, id, {}); - auto* func = create( - Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{}, - &void_type, create(), ast::FunctionDecorationList{}); + auto* func = create(Source{}, mod.RegisterSymbol("my_func"), + "my_func", ast::VariableList{}, &void_type, + create(Source{}), + ast::FunctionDecorationList{}); mod.AddFunction(func); ASSERT_TRUE(gen.EmitExpression(pre, out, &call)) << gen.error(); @@ -57,9 +58,10 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) { Source{}, mod.RegisterSymbol("param2"), "param2")); ast::CallExpression call(Source{}, id, params); - auto* func = create( - Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{}, - &void_type, create(), ast::FunctionDecorationList{}); + auto* func = create(Source{}, mod.RegisterSymbol("my_func"), + "my_func", ast::VariableList{}, &void_type, + create(Source{}), + ast::FunctionDecorationList{}); mod.AddFunction(func); ASSERT_TRUE(gen.EmitExpression(pre, out, &call)) << gen.error(); @@ -76,11 +78,13 @@ TEST_F(HlslGeneratorImplTest_Call, EmitStatement_Call) { Source{}, mod.RegisterSymbol("param1"), "param1")); params.push_back(create( Source{}, mod.RegisterSymbol("param2"), "param2")); - ast::CallStatement call(create(Source{}, id, params)); + ast::CallStatement call(Source{}, + create(Source{}, id, params)); - auto* func = create( - Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{}, - &void_type, create(), ast::FunctionDecorationList{}); + auto* func = create(Source{}, mod.RegisterSymbol("my_func"), + "my_func", ast::VariableList{}, &void_type, + create(Source{}), + ast::FunctionDecorationList{}); mod.AddFunction(func); gen.increment_indent(); ASSERT_TRUE(gen.EmitStatement(out, &call)) << gen.error(); diff --git a/src/writer/hlsl/generator_impl_case_test.cc b/src/writer/hlsl/generator_impl_case_test.cc index c6117bb2ca..55105f8e2a 100644 --- a/src/writer/hlsl/generator_impl_case_test.cc +++ b/src/writer/hlsl/generator_impl_case_test.cc @@ -33,12 +33,12 @@ using HlslGeneratorImplTest_Case = TestHelper; TEST_F(HlslGeneratorImplTest_Case, Emit_Case) { ast::type::I32 i32; - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); ast::CaseSelectorList lit; lit.push_back(create(Source{}, &i32, 5)); - ast::CaseStatement c(lit, body); + ast::CaseStatement c(Source{}, lit, body); gen.increment_indent(); @@ -54,7 +54,7 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) { ast::CaseSelectorList lit; lit.push_back(create(Source{}, &i32, 5)); - ast::CaseStatement c(lit, create()); + ast::CaseStatement c(Source{}, lit, create(Source{})); gen.increment_indent(); @@ -68,12 +68,12 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_BreaksByDefault) { TEST_F(HlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) { ast::type::I32 i32; - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); ast::CaseSelectorList lit; lit.push_back(create(Source{}, &i32, 5)); - ast::CaseStatement c(lit, body); + ast::CaseStatement c(Source{}, lit, body); gen.increment_indent(); @@ -87,13 +87,13 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_WithFallthrough) { TEST_F(HlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) { ast::type::I32 i32; - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); ast::CaseSelectorList lit; lit.push_back(create(Source{}, &i32, 5)); lit.push_back(create(Source{}, &i32, 6)); - ast::CaseStatement c(lit, body); + ast::CaseStatement c(Source{}, lit, body); gen.increment_indent(); @@ -106,9 +106,9 @@ TEST_F(HlslGeneratorImplTest_Case, Emit_Case_MultipleSelectors) { } TEST_F(HlslGeneratorImplTest_Case, Emit_Case_Default) { - auto* body = create(); - body->append(create()); - ast::CaseStatement c(body); + auto* body = create(Source{}); + body->append(create(Source{})); + ast::CaseStatement c(Source{}, ast::CaseSelectorList{}, body); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_continue_test.cc b/src/writer/hlsl/generator_impl_continue_test.cc index 7b548b93e4..0502ea6099 100644 --- a/src/writer/hlsl/generator_impl_continue_test.cc +++ b/src/writer/hlsl/generator_impl_continue_test.cc @@ -27,7 +27,7 @@ namespace { using HlslGeneratorImplTest_Continue = TestHelper; TEST_F(HlslGeneratorImplTest_Continue, Emit_Continue) { - ast::ContinueStatement c; + ast::ContinueStatement c(Source{}); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_discard_test.cc b/src/writer/hlsl/generator_impl_discard_test.cc index 422d39c515..5e7a13c8b9 100644 --- a/src/writer/hlsl/generator_impl_discard_test.cc +++ b/src/writer/hlsl/generator_impl_discard_test.cc @@ -24,7 +24,7 @@ namespace { using HlslGeneratorImplTest_Discard = TestHelper; TEST_F(HlslGeneratorImplTest_Discard, Emit_Discard) { - ast::DiscardStatement stmt; + ast::DiscardStatement stmt(Source{}); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc b/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc index a61d36609a..2deaf623ff 100644 --- a/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc +++ b/src/writer/hlsl/generator_impl_function_entry_point_data_test.cc @@ -82,13 +82,15 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, mod.AddGlobalVariable(bar_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("foo"), "foo"), create(Source{}, mod.RegisterSymbol("foo"), "foo"))); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("bar"), @@ -159,13 +161,15 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("foo"), "foo"), create(Source{}, mod.RegisterSymbol("foo"), "foo"))); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("bar"), @@ -236,13 +240,15 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("foo"), "foo"), create(Source{}, mod.RegisterSymbol("foo"), "foo"))); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("bar"), @@ -312,13 +318,15 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, mod.AddGlobalVariable(bar_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("foo"), "foo"), create(Source{}, mod.RegisterSymbol("foo"), "foo"))); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("bar"), @@ -385,13 +393,15 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, mod.AddGlobalVariable(bar_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("foo"), "foo"), create(Source{}, mod.RegisterSymbol("foo"), "foo"))); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("bar"), @@ -453,13 +463,15 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, mod.AddGlobalVariable(bar_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("foo"), "foo"), create(Source{}, mod.RegisterSymbol("foo"), "foo"))); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("bar"), @@ -528,8 +540,9 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, mod.AddGlobalVariable(depth_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("depth"), "depth"), create( diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc index 619b7ec073..6a5cecc5ab 100644 --- a/src/writer/hlsl/generator_impl_function_test.cc +++ b/src/writer/hlsl/generator_impl_function_test.cc @@ -55,7 +55,7 @@ using HlslGeneratorImplTest_Function = TestHelper; TEST_F(HlslGeneratorImplTest_Function, Emit_Function) { ast::type::Void void_type; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create(Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{}, &void_type, @@ -75,7 +75,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function) { TEST_F(HlslGeneratorImplTest_Function, Emit_Function_Name_Collision) { ast::type::Void void_type; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create( Source{}, mod.RegisterSymbol("GeometryShader"), "GeometryShader", @@ -116,7 +116,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) { ast::type::Void void_type; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create(Source{}, mod.RegisterSymbol("my_func"), "my_func", params, &void_type, body, @@ -169,8 +169,9 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(bar_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("foo"), @@ -241,8 +242,9 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(depth_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("depth"), "depth"), create( @@ -317,8 +319,8 @@ TEST_F(HlslGeneratorImplTest_Function, "x")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( Source{}, mod.RegisterSymbol("frag_main"), "frag_main", params, @@ -394,8 +396,8 @@ TEST_F(HlslGeneratorImplTest_Function, "x")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( Source{}, mod.RegisterSymbol("frag_main"), "frag_main", params, @@ -473,8 +475,8 @@ TEST_F(HlslGeneratorImplTest_Function, "b")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( Source{}, mod.RegisterSymbol("frag_main"), "frag_main", params, @@ -548,8 +550,8 @@ TEST_F(HlslGeneratorImplTest_Function, "b")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( Source{}, mod.RegisterSymbol("frag_main"), "frag_main", params, @@ -621,7 +623,7 @@ TEST_F(HlslGeneratorImplTest_Function, create( Source{}, create(Source{}, &f32, 2.0f))); - auto* body = create(); + auto* body = create(Source{}); body->append(assign); body->append(create(Source{})); auto* func = create( @@ -705,13 +707,15 @@ TEST_F( nullptr, // constructor ast::VariableDecorationList{})); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("foo"), "foo"))); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("val"), "val"), create(Source{}, mod.RegisterSymbol("param"), @@ -729,8 +733,9 @@ TEST_F( expr.push_back(create( Source{}, create(Source{}, &f32, 1.0f))); - body = create(); + body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create( @@ -805,7 +810,7 @@ TEST_F(HlslGeneratorImplTest_Function, nullptr, // constructor ast::VariableDecorationList{})); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{}, create( Source{}, mod.RegisterSymbol("param"), "param"))); @@ -819,8 +824,9 @@ TEST_F(HlslGeneratorImplTest_Function, expr.push_back(create( Source{}, create(Source{}, &f32, 1.0f))); - body = create(); + body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("depth"), "depth"), create( @@ -903,8 +909,9 @@ TEST_F( nullptr, // constructor ast::VariableDecorationList{})); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("depth"), "depth"), create( @@ -926,8 +933,9 @@ TEST_F( expr.push_back(create( Source{}, create(Source{}, &f32, 1.0f))); - body = create(); + body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("depth"), "depth"), create( @@ -1001,7 +1009,7 @@ TEST_F(HlslGeneratorImplTest_Function, nullptr, // constructor ast::VariableDecorationList{})); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{}, create( Source{}, @@ -1032,8 +1040,8 @@ TEST_F(HlslGeneratorImplTest_Function, expr), // constructor ast::VariableDecorationList{}); // decorations - body = create(); - body->append(create(var)); + body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( Source{}, mod.RegisterSymbol("frag_main"), "frag_main", params, @@ -1095,7 +1103,7 @@ TEST_F(HlslGeneratorImplTest_Function, nullptr, // constructor ast::VariableDecorationList{})); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{}, create( Source{}, @@ -1126,8 +1134,8 @@ TEST_F(HlslGeneratorImplTest_Function, expr), // constructor ast::VariableDecorationList{}); // decorations - body = create(); - body->append(create(var)); + body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( Source{}, mod.RegisterSymbol("frag_main"), "frag_main", params, @@ -1176,14 +1184,15 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(bar_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create( Source{}, create(Source{}, &f32, 1.0f)))); - auto* list = create(); + auto* list = create(Source{}); list->append(create(Source{})); body->append(create( @@ -1229,7 +1238,7 @@ TEST_F(HlslGeneratorImplTest_Function, auto* func = create( Source{}, mod.RegisterSymbol("GeometryShader"), "GeometryShader", - ast::VariableList{}, &void_type, create(), + ast::VariableList{}, &void_type, create(Source{}), ast::FunctionDecorationList{ create(ast::PipelineStage::kFragment, Source{}), }); @@ -1248,7 +1257,7 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::Void void_type; ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create( Source{}, mod.RegisterSymbol("main"), "main", params, &void_type, body, @@ -1273,7 +1282,7 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::Void void_type; ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create( Source{}, mod.RegisterSymbol("main"), "main", params, &void_type, body, @@ -1310,7 +1319,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) { ast::type::Void void_type; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create(Source{}, mod.RegisterSymbol("my_func"), "my_func", params, &void_type, body, @@ -1394,8 +1403,8 @@ TEST_F(HlslGeneratorImplTest_Function, "d")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( Source{}, mod.RegisterSymbol("a"), "a", params, &void_type, body, @@ -1423,8 +1432,8 @@ TEST_F(HlslGeneratorImplTest_Function, "d")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( Source{}, mod.RegisterSymbol("b"), "b", params, &void_type, body, diff --git a/src/writer/hlsl/generator_impl_if_test.cc b/src/writer/hlsl/generator_impl_if_test.cc index 6da8512cbe..664a76ac99 100644 --- a/src/writer/hlsl/generator_impl_if_test.cc +++ b/src/writer/hlsl/generator_impl_if_test.cc @@ -29,7 +29,7 @@ using HlslGeneratorImplTest_If = TestHelper; TEST_F(HlslGeneratorImplTest_If, Emit_If) { auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); ast::IfStatement i(Source{}, cond, body, ast::ElseStatementList{}); @@ -45,16 +45,17 @@ TEST_F(HlslGeneratorImplTest_If, Emit_If) { TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElseIf) { auto* else_cond = create( Source{}, mod.RegisterSymbol("else_cond"), "else_cond"); - auto* else_body = create(); + auto* else_body = create(Source{}); else_body->append(create(Source{})); auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); - ast::IfStatement i(Source{}, cond, body, - {create(else_cond, else_body)}); + ast::IfStatement i( + Source{}, cond, body, + {create(Source{}, else_cond, else_body)}); gen.increment_indent(); @@ -70,16 +71,17 @@ TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElseIf) { } TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElse) { - auto* else_body = create(); + auto* else_body = create(Source{}); else_body->append(create(Source{})); auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); - ast::IfStatement i(Source{}, cond, body, - {create(else_body)}); + ast::IfStatement i( + Source{}, cond, body, + {create(Source{}, nullptr, else_body)}); gen.increment_indent(); @@ -96,22 +98,23 @@ TEST_F(HlslGeneratorImplTest_If, Emit_IfWithMultiple) { auto* else_cond = create( Source{}, mod.RegisterSymbol("else_cond"), "else_cond"); - auto* else_body = create(); + auto* else_body = create(Source{}); else_body->append(create(Source{})); - auto* else_body_2 = create(); + auto* else_body_2 = create(Source{}); else_body_2->append(create(Source{})); auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); - ast::IfStatement i(Source{}, cond, body, - { - create(else_cond, else_body), - create(else_body_2), - }); + ast::IfStatement i( + Source{}, cond, body, + { + create(Source{}, else_cond, else_body), + create(Source{}, nullptr, else_body_2), + }); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_loop_test.cc b/src/writer/hlsl/generator_impl_loop_test.cc index 6afc94727a..c413a5283a 100644 --- a/src/writer/hlsl/generator_impl_loop_test.cc +++ b/src/writer/hlsl/generator_impl_loop_test.cc @@ -34,10 +34,10 @@ namespace { using HlslGeneratorImplTest_Loop = TestHelper; TEST_F(HlslGeneratorImplTest_Loop, Emit_Loop) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - ast::LoopStatement l(body, {}); + ast::LoopStatement l(Source{}, body, {}); gen.increment_indent(); ASSERT_TRUE(gen.EmitStatement(out, &l)) << gen.error(); @@ -48,13 +48,13 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_Loop) { } TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithContinuing) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - auto* continuing = create(); + auto* continuing = create(Source{}); continuing->append(create(Source{})); - ast::LoopStatement l(body, continuing); + ast::LoopStatement l(Source{}, body, continuing); gen.increment_indent(); ASSERT_TRUE(gen.EmitStatement(out, &l)) << gen.error(); @@ -75,15 +75,15 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithContinuing) { TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) { ast::type::F32 f32; - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - auto* continuing = create(); + auto* continuing = create(Source{}); continuing->append(create(Source{})); - auto* inner = create(body, continuing); + auto* inner = create(Source{}, body, continuing); - body = create(); + body = create(Source{}); body->append(inner); auto* lhs = create( @@ -91,10 +91,10 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) { auto* rhs = create( Source{}, mod.RegisterSymbol("rhs"), "rhs"); - continuing = create(); - continuing->append(create(lhs, rhs)); + continuing = create(Source{}); + continuing->append(create(Source{}, lhs, rhs)); - ast::LoopStatement outer(body, continuing); + ast::LoopStatement outer(Source{}, body, continuing); gen.increment_indent(); ASSERT_TRUE(gen.EmitStatement(out, &outer)) << gen.error(); @@ -157,9 +157,10 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) { create(Source{}, &f32, 2.4)), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create( + Source{}, create(Source{}, // source "other", // name ast::StorageClass::kFunction, // storage_class @@ -173,10 +174,10 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) { auto* rhs = create( Source{}, mod.RegisterSymbol("rhs"), "rhs"); - auto* continuing = create(); - continuing->append(create(lhs, rhs)); + auto* continuing = create(Source{}); + continuing->append(create(Source{}, lhs, rhs)); - ast::LoopStatement outer(body, continuing); + ast::LoopStatement outer(Source{}, body, continuing); gen.increment_indent(); ASSERT_TRUE(gen.EmitStatement(out, &outer)) << gen.error(); diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc index f689fb6c37..e21b210375 100644 --- a/src/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc @@ -244,7 +244,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* rhs = create(Source{}, mod.RegisterSymbol("b"), "b"); - ast::AssignmentStatement assign(lhs, rhs); + ast::AssignmentStatement assign(Source{}, lhs, rhs); td.RegisterVariableForTesting(coord_var); td.RegisterVariableForTesting(b_var); @@ -311,7 +311,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* rhs = create(Source{}, &mat, ast::ExpressionList{}); - ast::AssignmentStatement assign(lhs, rhs); + ast::AssignmentStatement assign(Source{}, lhs, rhs); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -730,7 +730,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, "b")); auto* rhs = create( Source{}, create(Source{}, &f32, 2.0f)); - ast::AssignmentStatement assign(lhs, rhs); + ast::AssignmentStatement assign(Source{}, lhs, rhs); ASSERT_TRUE(td.DetermineResultType(&assign)); ASSERT_TRUE(gen.EmitStatement(out, &assign)) << gen.error(); @@ -791,7 +791,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, Source{}, create(Source{}, &i32, 2))); auto* rhs = create( Source{}, create(Source{}, &i32, 2)); - ast::AssignmentStatement assign(lhs, rhs); + ast::AssignmentStatement assign(Source{}, lhs, rhs); ASSERT_TRUE(td.DetermineResultType(&assign)) << td.error(); ASSERT_TRUE(gen.EmitStatement(out, &assign)) << gen.error(); @@ -849,7 +849,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, "a")); auto* rhs = create( Source{}, create(Source{}, &i32, 2)); - ast::AssignmentStatement assign(lhs, rhs); + ast::AssignmentStatement assign(Source{}, lhs, rhs); ASSERT_TRUE(td.DetermineResultType(&assign)); ASSERT_TRUE(gen.EmitStatement(out, &assign)) << gen.error(); @@ -973,7 +973,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, "b")); auto* rhs = create(Source{}, &fvec3, values); - ast::AssignmentStatement assign(lhs, rhs); + ast::AssignmentStatement assign(Source{}, lhs, rhs); ASSERT_TRUE(td.DetermineResultType(&assign)); ASSERT_TRUE(gen.EmitStatement(out, &assign)) << gen.error(); @@ -1408,7 +1408,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* rhs = create(Source{}, &fvec3, values); - ast::AssignmentStatement assign(lhs, rhs); + ast::AssignmentStatement assign(Source{}, lhs, rhs); ASSERT_TRUE(td.DetermineResultType(&assign)); ASSERT_TRUE(gen.EmitStatement(out, &assign)) << gen.error(); @@ -1500,7 +1500,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* rhs = create( Source{}, create(Source{}, &i32, 1.f)); - ast::AssignmentStatement assign(lhs, rhs); + ast::AssignmentStatement assign(Source{}, lhs, rhs); ASSERT_TRUE(td.DetermineResultType(&assign)); ASSERT_TRUE(gen.EmitStatement(out, &assign)) << gen.error(); diff --git a/src/writer/hlsl/generator_impl_switch_test.cc b/src/writer/hlsl/generator_impl_switch_test.cc index e2b053d315..aed18332f3 100644 --- a/src/writer/hlsl/generator_impl_switch_test.cc +++ b/src/writer/hlsl/generator_impl_switch_test.cc @@ -31,18 +31,19 @@ namespace { using HlslGeneratorImplTest_Switch = TestHelper; TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) { - auto* def_body = create(); - def_body->append(create()); - auto* def = create(def_body); + auto* def_body = create(Source{}); + def_body->append(create(Source{})); + auto* def = + create(Source{}, ast::CaseSelectorList{}, def_body); ast::type::I32 i32; ast::CaseSelectorList case_val; case_val.push_back(create(Source{}, &i32, 5)); - auto* case_body = create(); - case_body->append(create()); + auto* case_body = create(Source{}); + case_body->append(create(Source{})); - auto* case_stmt = create(case_val, case_body); + auto* case_stmt = create(Source{}, case_val, case_body); ast::CaseStatementList body; body.push_back(case_stmt); @@ -50,7 +51,7 @@ TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) { auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - ast::SwitchStatement s(cond, body); + ast::SwitchStatement s(Source{}, cond, body); gen.increment_indent(); ASSERT_TRUE(gen.EmitStatement(out, &s)) << gen.error(); diff --git a/src/writer/hlsl/generator_impl_test.cc b/src/writer/hlsl/generator_impl_test.cc index b7bb46ac3d..19931af240 100644 --- a/src/writer/hlsl/generator_impl_test.cc +++ b/src/writer/hlsl/generator_impl_test.cc @@ -29,9 +29,10 @@ using HlslGeneratorImplTest = TestHelper; TEST_F(HlslGeneratorImplTest, Generate) { ast::type::Void void_type; - auto* func = create( - Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{}, - &void_type, create(), ast::FunctionDecorationList{}); + auto* func = create(Source{}, mod.RegisterSymbol("my_func"), + "my_func", ast::VariableList{}, &void_type, + create(Source{}), + ast::FunctionDecorationList{}); mod.AddFunction(func); ASSERT_TRUE(gen.Generate(out)) << gen.error(); diff --git a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc index 469725fa90..b0a21e977f 100644 --- a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc @@ -43,7 +43,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent(); ASSERT_TRUE(gen.EmitStatement(out, &stmt)) << gen.error(); @@ -61,7 +61,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent(); ASSERT_TRUE(gen.EmitStatement(out, &stmt)) << gen.error(); @@ -81,7 +81,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent(); ASSERT_TRUE(gen.EmitStatement(out, &stmt)) << gen.error(); @@ -100,7 +100,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent(); ASSERT_TRUE(gen.EmitStatement(out, &stmt)) << gen.error(); @@ -118,7 +118,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent(); ASSERT_TRUE(gen.EmitStatement(out, &stmt)) << gen.error(); @@ -140,7 +140,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, ident, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); ASSERT_TRUE(gen.EmitStatement(out, &stmt)) << gen.error(); EXPECT_EQ(result(), R"(float a = initializer; )"); @@ -164,7 +164,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, zero_vec, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); ASSERT_TRUE(gen.EmitStatement(out, &stmt)) << gen.error(); EXPECT_EQ(result(), R"(float3 a = float3(0.0f); )"); @@ -188,7 +188,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, zero_mat, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); ASSERT_TRUE(gen.EmitStatement(out, &stmt)) << gen.error(); EXPECT_EQ(result(), R"(float3x2 a = float3x2(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); diff --git a/src/writer/msl/generator_impl_assign_test.cc b/src/writer/msl/generator_impl_assign_test.cc index 9fcdddfcad..2db16f477a 100644 --- a/src/writer/msl/generator_impl_assign_test.cc +++ b/src/writer/msl/generator_impl_assign_test.cc @@ -34,7 +34,7 @@ TEST_F(MslGeneratorImplTest, Emit_Assign) { Source{}, mod.RegisterSymbol("lhs"), "lhs"); auto* rhs = create( Source{}, mod.RegisterSymbol("rhs"), "rhs"); - ast::AssignmentStatement assign(lhs, rhs); + ast::AssignmentStatement assign(Source{}, lhs, rhs); gen.increment_indent(); diff --git a/src/writer/msl/generator_impl_block_test.cc b/src/writer/msl/generator_impl_block_test.cc index 4e4cf2b0ab..a7b8ec312b 100644 --- a/src/writer/msl/generator_impl_block_test.cc +++ b/src/writer/msl/generator_impl_block_test.cc @@ -28,8 +28,8 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_Block) { - ast::BlockStatement b; - b.append(create()); + ast::BlockStatement b(Source{}); + b.append(create(Source{})); gen.increment_indent(); @@ -41,8 +41,8 @@ TEST_F(MslGeneratorImplTest, Emit_Block) { } TEST_F(MslGeneratorImplTest, Emit_Block_WithoutNewline) { - ast::BlockStatement b; - b.append(create()); + ast::BlockStatement b(Source{}); + b.append(create(Source{})); gen.increment_indent(); diff --git a/src/writer/msl/generator_impl_break_test.cc b/src/writer/msl/generator_impl_break_test.cc index daf276c2f8..186091027d 100644 --- a/src/writer/msl/generator_impl_break_test.cc +++ b/src/writer/msl/generator_impl_break_test.cc @@ -29,7 +29,7 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_Break) { - ast::BreakStatement b; + ast::BreakStatement b(Source{}); gen.increment_indent(); diff --git a/src/writer/msl/generator_impl_call_test.cc b/src/writer/msl/generator_impl_call_test.cc index 55623815d7..4092f73052 100644 --- a/src/writer/msl/generator_impl_call_test.cc +++ b/src/writer/msl/generator_impl_call_test.cc @@ -38,9 +38,10 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) { Source{}, mod.RegisterSymbol("my_func"), "my_func"); ast::CallExpression call(Source{}, id, {}); - auto* func = create( - Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{}, - &void_type, create(), ast::FunctionDecorationList{}); + auto* func = create(Source{}, mod.RegisterSymbol("my_func"), + "my_func", ast::VariableList{}, &void_type, + create(Source{}), + ast::FunctionDecorationList{}); mod.AddFunction(func); ASSERT_TRUE(gen.EmitExpression(&call)) << gen.error(); @@ -59,9 +60,10 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) { Source{}, mod.RegisterSymbol("param2"), "param2")); ast::CallExpression call(Source{}, id, params); - auto* func = create( - Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{}, - &void_type, create(), ast::FunctionDecorationList{}); + auto* func = create(Source{}, mod.RegisterSymbol("my_func"), + "my_func", ast::VariableList{}, &void_type, + create(Source{}), + ast::FunctionDecorationList{}); mod.AddFunction(func); ASSERT_TRUE(gen.EmitExpression(&call)) << gen.error(); @@ -78,11 +80,13 @@ TEST_F(MslGeneratorImplTest, EmitStatement_Call) { Source{}, mod.RegisterSymbol("param1"), "param1")); params.push_back(create( Source{}, mod.RegisterSymbol("param2"), "param2")); - ast::CallStatement call(create(Source{}, id, params)); + ast::CallStatement call(Source{}, + create(Source{}, id, params)); - auto* func = create( - Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{}, - &void_type, create(), ast::FunctionDecorationList{}); + auto* func = create(Source{}, mod.RegisterSymbol("my_func"), + "my_func", ast::VariableList{}, &void_type, + create(Source{}), + ast::FunctionDecorationList{}); mod.AddFunction(func); gen.increment_indent(); diff --git a/src/writer/msl/generator_impl_case_test.cc b/src/writer/msl/generator_impl_case_test.cc index 5740d2add4..f8570c699e 100644 --- a/src/writer/msl/generator_impl_case_test.cc +++ b/src/writer/msl/generator_impl_case_test.cc @@ -35,12 +35,12 @@ using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_Case) { ast::type::I32 i32; - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); ast::CaseSelectorList lit; lit.push_back(create(Source{}, &i32, 5)); - ast::CaseStatement c(lit, body); + ast::CaseStatement c(Source{}, lit, body); gen.increment_indent(); @@ -56,7 +56,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case_BreaksByDefault) { ast::CaseSelectorList lit; lit.push_back(create(Source{}, &i32, 5)); - ast::CaseStatement c(lit, create()); + ast::CaseStatement c(Source{}, lit, create(Source{})); gen.increment_indent(); @@ -70,12 +70,12 @@ TEST_F(MslGeneratorImplTest, Emit_Case_BreaksByDefault) { TEST_F(MslGeneratorImplTest, Emit_Case_WithFallthrough) { ast::type::I32 i32; - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); ast::CaseSelectorList lit; lit.push_back(create(Source{}, &i32, 5)); - ast::CaseStatement c(lit, body); + ast::CaseStatement c(Source{}, lit, body); gen.increment_indent(); @@ -89,13 +89,13 @@ TEST_F(MslGeneratorImplTest, Emit_Case_WithFallthrough) { TEST_F(MslGeneratorImplTest, Emit_Case_MultipleSelectors) { ast::type::I32 i32; - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); ast::CaseSelectorList lit; lit.push_back(create(Source{}, &i32, 5)); lit.push_back(create(Source{}, &i32, 6)); - ast::CaseStatement c(lit, body); + ast::CaseStatement c(Source{}, lit, body); gen.increment_indent(); @@ -108,9 +108,9 @@ TEST_F(MslGeneratorImplTest, Emit_Case_MultipleSelectors) { } TEST_F(MslGeneratorImplTest, Emit_Case_Default) { - auto* body = create(); - body->append(create()); - ast::CaseStatement c(body); + auto* body = create(Source{}); + body->append(create(Source{})); + ast::CaseStatement c(Source{}, ast::CaseSelectorList{}, body); gen.increment_indent(); diff --git a/src/writer/msl/generator_impl_continue_test.cc b/src/writer/msl/generator_impl_continue_test.cc index 95220bcca3..2edb0738a9 100644 --- a/src/writer/msl/generator_impl_continue_test.cc +++ b/src/writer/msl/generator_impl_continue_test.cc @@ -29,7 +29,7 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_Continue) { - ast::ContinueStatement c; + ast::ContinueStatement c(Source{}); gen.increment_indent(); diff --git a/src/writer/msl/generator_impl_discard_test.cc b/src/writer/msl/generator_impl_discard_test.cc index 182dc10955..1aefa7d2f1 100644 --- a/src/writer/msl/generator_impl_discard_test.cc +++ b/src/writer/msl/generator_impl_discard_test.cc @@ -26,7 +26,7 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_Discard) { - ast::DiscardStatement stmt; + ast::DiscardStatement stmt(Source{}); gen.increment_indent(); diff --git a/src/writer/msl/generator_impl_function_entry_point_data_test.cc b/src/writer/msl/generator_impl_function_entry_point_data_test.cc index e6bf9f66d4..2d2c6282a1 100644 --- a/src/writer/msl/generator_impl_function_entry_point_data_test.cc +++ b/src/writer/msl/generator_impl_function_entry_point_data_test.cc @@ -81,13 +81,15 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Input) { mod.AddGlobalVariable(bar_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("foo"), "foo"), create(Source{}, mod.RegisterSymbol("foo"), "foo"))); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("bar"), @@ -155,13 +157,15 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Output) { mod.AddGlobalVariable(bar_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("foo"), "foo"), create(Source{}, mod.RegisterSymbol("foo"), "foo"))); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("bar"), @@ -229,13 +233,15 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Input) { mod.AddGlobalVariable(bar_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("foo"), "foo"), create(Source{}, mod.RegisterSymbol("foo"), "foo"))); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("bar"), @@ -302,13 +308,15 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Output) { mod.AddGlobalVariable(bar_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("foo"), "foo"), create(Source{}, mod.RegisterSymbol("foo"), "foo"))); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("bar"), @@ -373,13 +381,15 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Input) { mod.AddGlobalVariable(bar_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("foo"), "foo"), create(Source{}, mod.RegisterSymbol("foo"), "foo"))); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("bar"), @@ -439,13 +449,15 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Output) { mod.AddGlobalVariable(bar_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("foo"), "foo"), create(Source{}, mod.RegisterSymbol("foo"), "foo"))); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("bar"), @@ -512,8 +524,9 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Builtins) { ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("depth"), "depth"), create( diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc index 66b3143679..7155a10000 100644 --- a/src/writer/msl/generator_impl_function_test.cc +++ b/src/writer/msl/generator_impl_function_test.cc @@ -58,7 +58,7 @@ using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_Function) { ast::type::Void void_type; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create(Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{}, &void_type, @@ -80,7 +80,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function) { TEST_F(MslGeneratorImplTest, Emit_Function_Name_Collision) { ast::type::Void void_type; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create(Source{}, mod.RegisterSymbol("main"), "main", ast::VariableList{}, &void_type, @@ -123,7 +123,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithParams) { ast::type::Void void_type; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create(Source{}, mod.RegisterSymbol("my_func"), "my_func", params, &void_type, body, @@ -177,8 +177,9 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithInOutVars) { mod.AddGlobalVariable(bar_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("foo"), @@ -252,8 +253,9 @@ TEST_F(MslGeneratorImplTest, mod.AddGlobalVariable(depth_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("depth"), "depth"), create( @@ -328,8 +330,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) { "x")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( @@ -408,8 +410,8 @@ TEST_F(MslGeneratorImplTest, "b")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( @@ -493,8 +495,8 @@ TEST_F(MslGeneratorImplTest, "b")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( @@ -584,13 +586,15 @@ TEST_F( nullptr, // constructor ast::VariableDecorationList{})); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create(Source{}, mod.RegisterSymbol("foo"), "foo"))); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("val"), "val"), create(Source{}, mod.RegisterSymbol("param"), @@ -608,8 +612,9 @@ TEST_F( expr.push_back(create( Source{}, create(Source{}, &f32, 1.0f))); - body = create(); + body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create( @@ -687,7 +692,7 @@ TEST_F(MslGeneratorImplTest, nullptr, // constructor ast::VariableDecorationList{})); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{}, create( Source{}, mod.RegisterSymbol("param"), "param"))); @@ -701,8 +706,9 @@ TEST_F(MslGeneratorImplTest, expr.push_back(create( Source{}, create(Source{}, &f32, 1.0f))); - body = create(); + body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("depth"), "depth"), create( @@ -789,8 +795,9 @@ TEST_F( nullptr, // constructor ast::VariableDecorationList{})); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("depth"), "depth"), create( @@ -812,8 +819,9 @@ TEST_F( expr.push_back(create( Source{}, create(Source{}, &f32, 1.0f))); - body = create(); + body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("depth"), "depth"), create( @@ -885,7 +893,7 @@ TEST_F(MslGeneratorImplTest, nullptr, // constructor ast::VariableDecorationList{})); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{}, create( Source{}, @@ -916,8 +924,8 @@ TEST_F(MslGeneratorImplTest, expr), // constructor ast::VariableDecorationList{}); // decorations - body = create(); - body->append(create(var)); + body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( @@ -993,7 +1001,7 @@ TEST_F(MslGeneratorImplTest, nullptr, // constructor ast::VariableDecorationList{})); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{}, create( Source{}, @@ -1024,8 +1032,8 @@ TEST_F(MslGeneratorImplTest, expr), // constructor ast::VariableDecorationList{}); // decorations - body = create(); - body->append(create(var)); + body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( @@ -1107,7 +1115,7 @@ TEST_F(MslGeneratorImplTest, nullptr, // constructor ast::VariableDecorationList{})); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{}, create( Source{}, @@ -1138,8 +1146,8 @@ TEST_F(MslGeneratorImplTest, expr), // constructor ast::VariableDecorationList{}); // decorations - body = create(); - body->append(create(var)); + body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( @@ -1195,14 +1203,15 @@ TEST_F(MslGeneratorImplTest, mod.AddGlobalVariable(bar_var); ast::VariableList params; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod.RegisterSymbol("bar"), "bar"), create( Source{}, create(Source{}, &f32, 1.0f)))); - auto* list = create(); + auto* list = create(Source{}); list->append(create(Source{})); body->append(create( @@ -1251,7 +1260,7 @@ TEST_F(MslGeneratorImplTest, auto* func = create( Source{}, mod.RegisterSymbol("main"), "main", ast::VariableList{}, - &void_type, create(), + &void_type, create(Source{}), ast::FunctionDecorationList{ create(ast::PipelineStage::kCompute, Source{}), }); @@ -1283,7 +1292,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayParams) { ast::type::Void void_type; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); auto* func = create(Source{}, mod.RegisterSymbol("my_func"), "my_func", params, &void_type, body, @@ -1371,8 +1380,8 @@ TEST_F(MslGeneratorImplTest, "d")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( @@ -1401,8 +1410,8 @@ TEST_F(MslGeneratorImplTest, "d")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( diff --git a/src/writer/msl/generator_impl_if_test.cc b/src/writer/msl/generator_impl_if_test.cc index 603698d9a0..3ded7e3bb7 100644 --- a/src/writer/msl/generator_impl_if_test.cc +++ b/src/writer/msl/generator_impl_if_test.cc @@ -31,7 +31,7 @@ using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_If) { auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); ast::IfStatement i(Source{}, cond, body, ast::ElseStatementList{}); @@ -48,16 +48,17 @@ TEST_F(MslGeneratorImplTest, Emit_If) { TEST_F(MslGeneratorImplTest, Emit_IfWithElseIf) { auto* else_cond = create( Source{}, mod.RegisterSymbol("else_cond"), "else_cond"); - auto* else_body = create(); + auto* else_body = create(Source{}); else_body->append(create(Source{})); auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); - ast::IfStatement i(Source{}, cond, body, - {create(else_cond, else_body)}); + ast::IfStatement i( + Source{}, cond, body, + {create(Source{}, else_cond, else_body)}); gen.increment_indent(); @@ -71,16 +72,17 @@ TEST_F(MslGeneratorImplTest, Emit_IfWithElseIf) { } TEST_F(MslGeneratorImplTest, Emit_IfWithElse) { - auto* else_body = create(); + auto* else_body = create(Source{}); else_body->append(create(Source{})); auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); - ast::IfStatement i(Source{}, cond, body, - {create(else_body)}); + ast::IfStatement i( + Source{}, cond, body, + {create(Source{}, nullptr, else_body)}); gen.increment_indent(); @@ -97,22 +99,23 @@ TEST_F(MslGeneratorImplTest, Emit_IfWithMultiple) { auto* else_cond = create( Source{}, mod.RegisterSymbol("else_cond"), "else_cond"); - auto* else_body = create(); + auto* else_body = create(Source{}); else_body->append(create(Source{})); - auto* else_body_2 = create(); + auto* else_body_2 = create(Source{}); else_body_2->append(create(Source{})); auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); - ast::IfStatement i(Source{}, cond, body, - { - create(else_cond, else_body), - create(else_body_2), - }); + ast::IfStatement i( + Source{}, cond, body, + { + create(Source{}, else_cond, else_body), + create(Source{}, nullptr, else_body_2), + }); gen.increment_indent(); diff --git a/src/writer/msl/generator_impl_loop_test.cc b/src/writer/msl/generator_impl_loop_test.cc index cf0f3759b1..94ecdb5796 100644 --- a/src/writer/msl/generator_impl_loop_test.cc +++ b/src/writer/msl/generator_impl_loop_test.cc @@ -36,10 +36,10 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_Loop) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - ast::LoopStatement l(body, {}); + ast::LoopStatement l(Source{}, body, {}); gen.increment_indent(); @@ -51,13 +51,13 @@ TEST_F(MslGeneratorImplTest, Emit_Loop) { } TEST_F(MslGeneratorImplTest, Emit_LoopWithContinuing) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - auto* continuing = create(); + auto* continuing = create(Source{}); continuing->append(create(Source{})); - ast::LoopStatement l(body, continuing); + ast::LoopStatement l(Source{}, body, continuing); gen.increment_indent(); @@ -79,15 +79,15 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithContinuing) { TEST_F(MslGeneratorImplTest, Emit_LoopNestedWithContinuing) { ast::type::F32 f32; - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - auto* continuing = create(); + auto* continuing = create(Source{}); continuing->append(create(Source{})); - auto* inner = create(body, continuing); + auto* inner = create(Source{}, body, continuing); - body = create(); + body = create(Source{}); body->append(inner); auto* lhs = create( @@ -95,10 +95,10 @@ TEST_F(MslGeneratorImplTest, Emit_LoopNestedWithContinuing) { auto* rhs = create( Source{}, mod.RegisterSymbol("rhs"), "rhs"); - continuing = create(); - continuing->append(create(lhs, rhs)); + continuing = create(Source{}); + continuing->append(create(Source{}, lhs, rhs)); - ast::LoopStatement outer(body, continuing); + ast::LoopStatement outer(Source{}, body, continuing); gen.increment_indent(); @@ -162,9 +162,10 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) { create(Source{}, &f32, 2.4)), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create( + Source{}, create(Source{}, // source "other", // name ast::StorageClass::kFunction, // storage_class @@ -178,12 +179,12 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) { auto* rhs = create( Source{}, mod.RegisterSymbol("rhs"), "rhs"); - auto* continuing = create(); - continuing->append(create(lhs, rhs)); + auto* continuing = create(Source{}); + continuing->append(create(Source{}, lhs, rhs)); gen.increment_indent(); - ast::LoopStatement outer(body, continuing); + ast::LoopStatement outer(Source{}, body, continuing); ASSERT_TRUE(gen.EmitStatement(&outer)) << gen.error(); EXPECT_EQ(gen.result(), R"( { diff --git a/src/writer/msl/generator_impl_switch_test.cc b/src/writer/msl/generator_impl_switch_test.cc index 56f3b82061..0b825672a1 100644 --- a/src/writer/msl/generator_impl_switch_test.cc +++ b/src/writer/msl/generator_impl_switch_test.cc @@ -33,18 +33,19 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_Switch) { - auto* def_body = create(); - def_body->append(create()); - auto* def = create(def_body); + auto* def_body = create(Source{}); + def_body->append(create(Source{})); + auto* def = + create(Source{}, ast::CaseSelectorList{}, def_body); ast::type::I32 i32; ast::CaseSelectorList case_val; case_val.push_back(create(Source{}, &i32, 5)); - auto* case_body = create(); - case_body->append(create()); + auto* case_body = create(Source{}); + case_body->append(create(Source{})); - auto* case_stmt = create(case_val, case_body); + auto* case_stmt = create(Source{}, case_val, case_body); ast::CaseStatementList body; body.push_back(case_stmt); @@ -52,7 +53,7 @@ TEST_F(MslGeneratorImplTest, Emit_Switch) { auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - ast::SwitchStatement s(cond, body); + ast::SwitchStatement s(Source{}, cond, body); gen.increment_indent(); diff --git a/src/writer/msl/generator_impl_test.cc b/src/writer/msl/generator_impl_test.cc index 0910b78531..c22568cc90 100644 --- a/src/writer/msl/generator_impl_test.cc +++ b/src/writer/msl/generator_impl_test.cc @@ -52,7 +52,7 @@ TEST_F(MslGeneratorImplTest, Generate) { auto* func = create( Source{}, mod.RegisterSymbol("my_func"), "my_func", ast::VariableList{}, - &void_type, create(), + &void_type, create(Source{}), ast::FunctionDecorationList{ create(ast::PipelineStage::kCompute, Source{}), }); diff --git a/src/writer/msl/generator_impl_variable_decl_statement_test.cc b/src/writer/msl/generator_impl_variable_decl_statement_test.cc index 01194908d8..23b9147eb2 100644 --- a/src/writer/msl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/msl/generator_impl_variable_decl_statement_test.cc @@ -51,7 +51,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent(); @@ -70,7 +70,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent(); @@ -91,7 +91,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent(); @@ -123,7 +123,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Struct) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent(); @@ -145,7 +145,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Vector) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent(); @@ -165,7 +165,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Matrix) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent(); @@ -184,7 +184,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent(); @@ -206,7 +206,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) { ident, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); ASSERT_TRUE(gen.EmitStatement(&stmt)) << gen.error(); EXPECT_EQ(gen.result(), R"(float a = initializer; @@ -230,7 +230,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_ZeroVec) { zero_vec, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); ASSERT_TRUE(gen.EmitStatement(&stmt)) << gen.error(); EXPECT_EQ(gen.result(), R"(float3 a = float3(0.0f); diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc index a1ce0400a8..82f100eab7 100644 --- a/src/writer/spirv/builder_accessor_expression_test.cc +++ b/src/writer/spirv/builder_accessor_expression_test.cc @@ -514,7 +514,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) { auto* rhs = create( Source{}, create(Source{}, &f32, 2.f)); - ast::AssignmentStatement expr(lhs, rhs); + ast::AssignmentStatement expr(Source{}, lhs, rhs); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -588,7 +588,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) { create(Source{}, mod->RegisterSymbol("a"), "a")); - ast::AssignmentStatement expr(lhs, rhs); + ast::AssignmentStatement expr(Source{}, lhs, rhs); td.RegisterVariableForTesting(&var); td.RegisterVariableForTesting(&store); diff --git a/src/writer/spirv/builder_assign_test.cc b/src/writer/spirv/builder_assign_test.cc index 6f557e99ee..96fe75ef9d 100644 --- a/src/writer/spirv/builder_assign_test.cc +++ b/src/writer/spirv/builder_assign_test.cc @@ -52,7 +52,7 @@ TEST_F(BuilderTest, Assign_Var) { auto* val = create( Source{}, create(Source{}, &f32, 1.0f)); - ast::AssignmentStatement assign(ident, val); + ast::AssignmentStatement assign(Source{}, ident, val); td.RegisterVariableForTesting(&v); @@ -88,7 +88,7 @@ TEST_F(BuilderTest, Assign_Var_ZeroConstructor) { ast::ExpressionList vals; auto* val = create(Source{}, &vec, vals); - ast::AssignmentStatement assign(ident, val); + ast::AssignmentStatement assign(Source{}, ident, val); td.RegisterVariableForTesting(&v); @@ -138,6 +138,7 @@ TEST_F(BuilderTest, Assign_Var_Complex_ConstructorWithExtract) { nullptr, ast::VariableDecorationList{}); ast::AssignmentStatement assign( + Source{}, create(Source{}, mod->RegisterSymbol("var"), "var"), init); @@ -189,6 +190,7 @@ TEST_F(BuilderTest, Assign_Var_Complex_Constructor) { nullptr, ast::VariableDecorationList{}); ast::AssignmentStatement assign( + Source{}, create(Source{}, mod->RegisterSymbol("var"), "var"), init); @@ -248,7 +250,7 @@ TEST_F(BuilderTest, Assign_StructMember) { auto* val = create( Source{}, create(Source{}, &f32, 4.0f)); - ast::AssignmentStatement assign(ident, val); + ast::AssignmentStatement assign(Source{}, ident, val); td.RegisterVariableForTesting(&v); @@ -297,7 +299,7 @@ TEST_F(BuilderTest, Assign_Vector) { auto* val = create(Source{}, &vec3, vals); - ast::AssignmentStatement assign(ident, val); + ast::AssignmentStatement assign(Source{}, ident, val); td.RegisterVariableForTesting(&v); @@ -342,7 +344,7 @@ TEST_F(BuilderTest, Assign_Vector_MemberByName) { auto* val = create( Source{}, create(Source{}, &f32, 1.0f)); - ast::AssignmentStatement assign(ident, val); + ast::AssignmentStatement assign(Source{}, ident, val); td.RegisterVariableForTesting(&v); @@ -391,7 +393,7 @@ TEST_F(BuilderTest, Assign_Vector_MemberByIndex) { auto* val = create( Source{}, create(Source{}, &f32, 1.0f)); - ast::AssignmentStatement assign(ident, val); + ast::AssignmentStatement assign(Source{}, ident, val); td.RegisterVariableForTesting(&v); diff --git a/src/writer/spirv/builder_block_test.cc b/src/writer/spirv/builder_block_test.cc index 43977b9140..30dc6babda 100644 --- a/src/writer/spirv/builder_block_test.cc +++ b/src/writer/spirv/builder_block_test.cc @@ -39,9 +39,10 @@ TEST_F(BuilderTest, Block) { // Note, this test uses shadow variables which aren't allowed in WGSL but // serves to prove the block code is pushing new scopes as needed. - ast::BlockStatement outer; + ast::BlockStatement outer(Source{}); outer.append(create( + Source{}, create(Source{}, // source "var", // name ast::StorageClass::kFunction, // storage_class @@ -50,13 +51,15 @@ TEST_F(BuilderTest, Block) { nullptr, // constructor ast::VariableDecorationList{}))); // decorations outer.append(create( + Source{}, create(Source{}, mod->RegisterSymbol("var"), "var"), create( Source{}, create(Source{}, &f32, 1.0f)))); - auto* inner = create(); + auto* inner = create(Source{}); inner->append(create( + Source{}, create(Source{}, // source "var", // name ast::StorageClass::kFunction, // storage_class @@ -65,6 +68,7 @@ TEST_F(BuilderTest, Block) { nullptr, // constructor ast::VariableDecorationList{}))); // decorations inner->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("var"), "var"), create( @@ -72,6 +76,7 @@ TEST_F(BuilderTest, Block) { outer.append(inner); outer.append(create( + Source{}, create(Source{}, mod->RegisterSymbol("var"), "var"), create( diff --git a/src/writer/spirv/builder_call_test.cc b/src/writer/spirv/builder_call_test.cc index 86075893b8..de09ffb031 100644 --- a/src/writer/spirv/builder_call_test.cc +++ b/src/writer/spirv/builder_call_test.cc @@ -61,7 +61,7 @@ TEST_F(BuilderTest, Expression_Call) { nullptr, // constructor ast::VariableDecorationList{})); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{}, create( Source{}, ast::BinaryOp::kAdd, @@ -73,7 +73,7 @@ TEST_F(BuilderTest, Expression_Call) { func_params, &f32, body, ast::FunctionDecorationList{}); ast::Function func(Source{}, mod->RegisterSymbol("main"), "main", {}, - &void_type, create(), + &void_type, create(Source{}), ast::FunctionDecorationList{}); ast::ExpressionList call_params; @@ -144,7 +144,7 @@ TEST_F(BuilderTest, Statement_Call) { nullptr, // constructor ast::VariableDecorationList{})); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{}, create( Source{}, ast::BinaryOp::kAdd, @@ -158,7 +158,7 @@ TEST_F(BuilderTest, Statement_Call) { ast::FunctionDecorationList{}); ast::Function func(Source{}, mod->RegisterSymbol("main"), "main", {}, - &void_type, create(), + &void_type, create(Source{}), ast::FunctionDecorationList{}); ast::ExpressionList call_params; @@ -167,11 +167,12 @@ TEST_F(BuilderTest, Statement_Call) { call_params.push_back(create( Source{}, create(Source{}, &f32, 1.f))); - ast::CallStatement expr(create( - Source{}, - create(Source{}, mod->RegisterSymbol("a_func"), - "a_func"), - call_params)); + ast::CallStatement expr( + Source{}, create( + Source{}, + create( + Source{}, mod->RegisterSymbol("a_func"), "a_func"), + call_params)); ASSERT_TRUE(td.DetermineFunction(&func)) << td.error(); ASSERT_TRUE(td.DetermineFunction(&a_func)) << td.error(); diff --git a/src/writer/spirv/builder_discard_test.cc b/src/writer/spirv/builder_discard_test.cc index caf5b81ae3..6b3796a5aa 100644 --- a/src/writer/spirv/builder_discard_test.cc +++ b/src/writer/spirv/builder_discard_test.cc @@ -27,7 +27,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, Discard) { - ast::DiscardStatement expr; + ast::DiscardStatement expr(Source{}); b.push_function(Function{}); EXPECT_EQ(b.GenerateStatement(&expr), 1u) << b.error(); diff --git a/src/writer/spirv/builder_function_decoration_test.cc b/src/writer/spirv/builder_function_decoration_test.cc index 67a294c91a..c9f1725527 100644 --- a/src/writer/spirv/builder_function_decoration_test.cc +++ b/src/writer/spirv/builder_function_decoration_test.cc @@ -43,7 +43,7 @@ TEST_F(BuilderTest, FunctionDecoration_Stage) { ast::Function func( Source{}, mod->RegisterSymbol("main"), "main", {}, &void_type, - create(), + create(Source{}), ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex, Source{}), }); @@ -69,7 +69,7 @@ TEST_P(FunctionDecoration_StageTest, Emit) { ast::type::Void void_type; ast::Function func(Source{}, mod->RegisterSymbol("main"), "main", {}, - &void_type, create(), + &void_type, create(Source{}), ast::FunctionDecorationList{ create(params.stage, Source{}), }); @@ -99,7 +99,7 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUnusedInterfaceIds) { ast::Function func( Source{}, mod->RegisterSymbol("main"), "main", {}, &void_type, - create(), + create(Source{}), ast::FunctionDecorationList{ create(ast::PipelineStage::kVertex, Source{}), }); @@ -163,19 +163,22 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUsedInterfaceIds) { ast::type::F32 f32; ast::type::Void void_type; - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("my_out"), "my_out"), create(Source{}, mod->RegisterSymbol("my_in"), "my_in"))); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("my_wg"), "my_wg"), create(Source{}, mod->RegisterSymbol("my_wg"), "my_wg"))); // Add duplicate usages so we show they don't get output multiple times. body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("my_out"), "my_out"), create(Source{}, mod->RegisterSymbol("my_in"), @@ -253,7 +256,7 @@ TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_Fragment_OriginUpperLeft) { ast::Function func( Source{}, mod->RegisterSymbol("main"), "main", {}, &void_type, - create(), + create(Source{}), ast::FunctionDecorationList{ create(ast::PipelineStage::kFragment, Source{}), }); @@ -269,7 +272,7 @@ TEST_F(BuilderTest, FunctionDecoration_WorkgroupSize_Default) { ast::Function func( Source{}, mod->RegisterSymbol("main"), "main", {}, &void_type, - create(), + create(Source{}), ast::FunctionDecorationList{ create(ast::PipelineStage::kCompute, Source{}), }); @@ -285,7 +288,7 @@ TEST_F(BuilderTest, FunctionDecoration_WorkgroupSize) { ast::Function func( Source{}, mod->RegisterSymbol("main"), "main", {}, &void_type, - create(), + create(Source{}), ast::FunctionDecorationList{ create(2u, 4u, 6u, Source{}), create(ast::PipelineStage::kCompute, Source{}), @@ -302,14 +305,14 @@ TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_MultipleFragment) { ast::Function func1( Source{}, mod->RegisterSymbol("main1"), "main1", {}, &void_type, - create(), + create(Source{}), ast::FunctionDecorationList{ create(ast::PipelineStage::kFragment, Source{}), }); ast::Function func2( Source{}, mod->RegisterSymbol("main2"), "main2", {}, &void_type, - create(), + create(Source{}), ast::FunctionDecorationList{ create(ast::PipelineStage::kFragment, Source{}), }); diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc index 6c7aefd613..e0024d4058 100644 --- a/src/writer/spirv/builder_function_test.cc +++ b/src/writer/spirv/builder_function_test.cc @@ -48,7 +48,7 @@ using BuilderTest = TestHelper; TEST_F(BuilderTest, Function_Empty) { ast::type::Void void_type; ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - &void_type, create(), + &void_type, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)); @@ -65,7 +65,7 @@ OpFunctionEnd TEST_F(BuilderTest, Function_Terminator_Return) { ast::type::Void void_type; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, @@ -96,7 +96,7 @@ TEST_F(BuilderTest, Function_Terminator_ReturnValue) { ast::VariableDecorationList{}); // decorations td.RegisterVariableForTesting(var_a); - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{}, create( Source{}, mod->RegisterSymbol("a"), "a"))); @@ -126,8 +126,8 @@ OpFunctionEnd TEST_F(BuilderTest, Function_Terminator_Discard) { ast::type::Void void_type; - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, &void_type, body, ast::FunctionDecorationList{}); @@ -166,7 +166,7 @@ TEST_F(BuilderTest, Function_WithParams) { ast::VariableDecorationList{}), // decorations }; - auto* body = create(); + auto* body = create(Source{}); body->append(create( Source{}, create( Source{}, mod->RegisterSymbol("a"), "a"))); @@ -196,7 +196,7 @@ OpFunctionEnd TEST_F(BuilderTest, Function_WithBody) { ast::type::Void void_type; - auto* body = create(); + auto* body = create(Source{}); body->append(create(Source{})); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, @@ -216,7 +216,7 @@ OpFunctionEnd TEST_F(BuilderTest, FunctionType) { ast::type::Void void_type; ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - &void_type, create(), + &void_type, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)); @@ -228,10 +228,10 @@ TEST_F(BuilderTest, FunctionType) { TEST_F(BuilderTest, FunctionType_DeDuplicate) { ast::type::Void void_type; ast::Function func1(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - &void_type, create(), + &void_type, create(Source{}), ast::FunctionDecorationList{}); ast::Function func2(Source{}, mod->RegisterSymbol("b_func"), "b_func", {}, - &void_type, create(), + &void_type, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func1)); @@ -309,8 +309,8 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { "d")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( @@ -340,8 +340,8 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { "d")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( diff --git a/src/writer/spirv/builder_if_test.cc b/src/writer/spirv/builder_if_test.cc index f5050ea53e..b5c8b8b765 100644 --- a/src/writer/spirv/builder_if_test.cc +++ b/src/writer/spirv/builder_if_test.cc @@ -48,7 +48,7 @@ TEST_F(BuilderTest, If_Empty) { auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - ast::IfStatement expr(Source{}, cond, create(), + ast::IfStatement expr(Source{}, cond, create(Source{}), ast::ElseStatementList{}); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -84,8 +84,9 @@ TEST_F(BuilderTest, If_WithStatements) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( @@ -139,15 +140,17 @@ TEST_F(BuilderTest, If_WithElse) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 2)))); - auto* else_body = create(); + auto* else_body = create(Source{}); else_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( @@ -156,8 +159,9 @@ TEST_F(BuilderTest, If_WithElse) { auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - ast::IfStatement expr(Source{}, cond, body, - {create(else_body)}); + ast::IfStatement expr( + Source{}, cond, body, + {create(Source{}, nullptr, else_body)}); td.RegisterVariableForTesting(var); @@ -207,15 +211,17 @@ TEST_F(BuilderTest, If_WithElseIf) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 2)))); - auto* else_body = create(); + auto* else_body = create(Source{}); else_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( @@ -227,8 +233,9 @@ TEST_F(BuilderTest, If_WithElseIf) { auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - ast::IfStatement expr(Source{}, cond, body, - {create(else_cond, else_body)}); + ast::IfStatement expr( + Source{}, cond, body, + {create(Source{}, else_cond, else_body)}); td.RegisterVariableForTesting(var); @@ -287,26 +294,30 @@ TEST_F(BuilderTest, If_WithMultiple) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 2)))); - auto* elseif_1_body = create(); + auto* elseif_1_body = create(Source{}); elseif_1_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 3)))); - auto* elseif_2_body = create(); + auto* elseif_2_body = create(Source{}); elseif_2_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 4)))); - auto* else_body = create(); + auto* else_body = create(Source{}); else_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( @@ -323,9 +334,9 @@ TEST_F(BuilderTest, If_WithMultiple) { ast::IfStatement expr( Source{}, cond, body, { - create(elseif_1_cond, elseif_1_body), - create(elseif_2_cond, elseif_2_body), - create(else_body), + create(Source{}, elseif_1_cond, elseif_1_body), + create(Source{}, elseif_2_cond, elseif_2_body), + create(Source{}, nullptr, else_body), }); td.RegisterVariableForTesting(var); @@ -387,16 +398,17 @@ TEST_F(BuilderTest, If_WithBreak) { auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - auto* if_body = create(); - if_body->append(create()); + auto* if_body = create(Source{}); + if_body->append(create(Source{})); auto* if_stmt = create(Source{}, cond, if_body, ast::ElseStatementList{}); - auto* loop_body = create(); + auto* loop_body = create(Source{}); loop_body->append(if_stmt); - ast::LoopStatement expr(loop_body, create()); + ast::LoopStatement expr(Source{}, loop_body, + create(Source{})); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -435,17 +447,19 @@ TEST_F(BuilderTest, If_WithElseBreak) { auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - auto* else_body = create(); - else_body->append(create()); + auto* else_body = create(Source{}); + else_body->append(create(Source{})); auto* if_stmt = create( - Source{}, cond, create(), - ast::ElseStatementList{create(else_body)}); + Source{}, cond, create(Source{}), + ast::ElseStatementList{ + create(Source{}, nullptr, else_body)}); - auto* loop_body = create(); + auto* loop_body = create(Source{}); loop_body->append(if_stmt); - ast::LoopStatement expr(loop_body, create()); + ast::LoopStatement expr(Source{}, loop_body, + create(Source{})); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -485,16 +499,17 @@ TEST_F(BuilderTest, If_WithContinue) { auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - auto* if_body = create(); - if_body->append(create()); + auto* if_body = create(Source{}); + if_body->append(create(Source{})); auto* if_stmt = create(Source{}, cond, if_body, ast::ElseStatementList{}); - auto* loop_body = create(); + auto* loop_body = create(Source{}); loop_body->append(if_stmt); - ast::LoopStatement expr(loop_body, create()); + ast::LoopStatement expr(Source{}, loop_body, + create(Source{})); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -533,17 +548,19 @@ TEST_F(BuilderTest, If_WithElseContinue) { auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - auto* else_body = create(); - else_body->append(create()); + auto* else_body = create(Source{}); + else_body->append(create(Source{})); auto* if_stmt = create( - Source{}, cond, create(), - ast::ElseStatementList{create(else_body)}); + Source{}, cond, create(Source{}), + ast::ElseStatementList{ + create(Source{}, nullptr, else_body)}); - auto* loop_body = create(); + auto* loop_body = create(Source{}); loop_body->append(if_stmt); - ast::LoopStatement expr(loop_body, create()); + ast::LoopStatement expr(Source{}, loop_body, + create(Source{})); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -581,7 +598,7 @@ TEST_F(BuilderTest, If_WithReturn) { auto* cond = create( Source{}, create(Source{}, &bool_type, true)); - auto* if_body = create(); + auto* if_body = create(Source{}); if_body->append(create(Source{})); ast::IfStatement expr(Source{}, cond, if_body, ast::ElseStatementList{}); @@ -613,7 +630,7 @@ TEST_F(BuilderTest, If_WithReturnValue) { auto* cond2 = create( Source{}, create(Source{}, &bool_type, false)); - auto* if_body = create(); + auto* if_body = create(Source{}); if_body->append(create(Source{}, cond2)); ast::IfStatement expr(Source{}, cond, if_body, ast::ElseStatementList{}); @@ -655,7 +672,7 @@ TEST_F(BuilderTest, If_WithLoad_Bug327) { ast::IfStatement expr(Source{}, create( Source{}, mod->RegisterSymbol("a"), "a"), - create(), + create(Source{}), ast::ElseStatementList{}); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); diff --git a/src/writer/spirv/builder_intrinsic_test.cc b/src/writer/spirv/builder_intrinsic_test.cc index de5055b1d2..8de99f1a54 100644 --- a/src/writer/spirv/builder_intrinsic_test.cc +++ b/src/writer/spirv/builder_intrinsic_test.cc @@ -472,7 +472,7 @@ TEST_F(IntrinsicBuilderTest, Call_GLSLMethod_WithLoad) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error(); @@ -506,7 +506,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Float_Test, Call_Scalar) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -534,7 +534,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Float_Test, Call_Vector) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -588,7 +588,7 @@ TEST_F(IntrinsicBuilderTest, Call_Length_Scalar) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -613,7 +613,7 @@ TEST_F(IntrinsicBuilderTest, Call_Length_Vector) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -640,7 +640,7 @@ TEST_F(IntrinsicBuilderTest, Call_Normalize) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -672,7 +672,7 @@ TEST_P(Intrinsic_Builtin_DualParam_Float_Test, Call_Scalar) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -701,7 +701,7 @@ TEST_P(Intrinsic_Builtin_DualParam_Float_Test, Call_Vector) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -738,7 +738,7 @@ TEST_F(IntrinsicBuilderTest, Call_Distance_Scalar) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -764,7 +764,7 @@ TEST_F(IntrinsicBuilderTest, Call_Distance_Vector) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -793,7 +793,7 @@ TEST_F(IntrinsicBuilderTest, Call_Cross) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -824,7 +824,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Float_Test, Call_Scalar) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -854,7 +854,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Float_Test, Call_Vector) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -895,7 +895,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Sint_Test, Call_Scalar) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -923,7 +923,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Sint_Test, Call_Vector) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -958,7 +958,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Uint_Test, Call_Scalar) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -986,7 +986,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Uint_Test, Call_Vector) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -1021,7 +1021,7 @@ TEST_P(Intrinsic_Builtin_DualParam_SInt_Test, Call_Scalar) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -1049,7 +1049,7 @@ TEST_P(Intrinsic_Builtin_DualParam_SInt_Test, Call_Vector) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -1085,7 +1085,7 @@ TEST_P(Intrinsic_Builtin_DualParam_UInt_Test, Call_Scalar) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -1113,7 +1113,7 @@ TEST_P(Intrinsic_Builtin_DualParam_UInt_Test, Call_Vector) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -1149,7 +1149,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Sint_Test, Call_Scalar) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -1179,7 +1179,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Sint_Test, Call_Vector) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -1214,7 +1214,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Uint_Test, Call_Scalar) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -1244,7 +1244,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Uint_Test, Call_Vector) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -1277,7 +1277,7 @@ TEST_F(IntrinsicBuilderTest, Call_Determinant) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -1321,7 +1321,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -1361,7 +1361,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); @@ -1407,7 +1407,7 @@ TEST_F(IntrinsicBuilderTest, DISABLED_Call_ArrayLength_Ptr) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - ty.void_, create(), + ty.void_, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateFunction(&func)) << b.error(); diff --git a/src/writer/spirv/builder_loop_test.cc b/src/writer/spirv/builder_loop_test.cc index 3fa284d626..5943521c97 100644 --- a/src/writer/spirv/builder_loop_test.cc +++ b/src/writer/spirv/builder_loop_test.cc @@ -39,13 +39,13 @@ TEST_F(BuilderTest, Loop_Empty) { // loop { // } - ast::LoopStatement expr(create(), - create()); + ast::LoopStatement loop(Source{}, create(Source{}), + create(Source{})); - ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); + ASSERT_TRUE(td.DetermineResultType(&loop)) << td.error(); b.push_function(Function{}); - EXPECT_TRUE(b.GenerateLoopStatement(&expr)) << b.error(); + EXPECT_TRUE(b.GenerateLoopStatement(&loop)) << b.error(); EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"(OpBranch %1 %1 = OpLabel @@ -74,22 +74,24 @@ TEST_F(BuilderTest, Loop_WithoutContinuing) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 2)))); - ast::LoopStatement expr(body, create()); + ast::LoopStatement loop(Source{}, body, + create(Source{})); td.RegisterVariableForTesting(var); - ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); + ASSERT_TRUE(td.DetermineResultType(&loop)) << td.error(); b.push_function(Function{}); ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error(); - EXPECT_TRUE(b.GenerateLoopStatement(&expr)) << b.error(); + EXPECT_TRUE(b.GenerateLoopStatement(&loop)) << b.error(); EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeInt 32 1 %2 = OpTypePointer Private %3 %4 = OpConstantNull %3 @@ -128,28 +130,30 @@ TEST_F(BuilderTest, Loop_WithContinuing) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); + auto* body = create(Source{}); body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 2)))); - auto* continuing = create(); + auto* continuing = create(Source{}); continuing->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 3)))); - ast::LoopStatement expr(body, continuing); + ast::LoopStatement loop(Source{}, body, continuing); td.RegisterVariableForTesting(var); - ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); + ASSERT_TRUE(td.DetermineResultType(&loop)) << td.error(); b.push_function(Function{}); ASSERT_TRUE(b.GenerateGlobalVariable(var)) << b.error(); - EXPECT_TRUE(b.GenerateLoopStatement(&expr)) << b.error(); + EXPECT_TRUE(b.GenerateLoopStatement(&loop)) << b.error(); EXPECT_EQ(DumpInstructions(b.types()), R"(%3 = OpTypeInt 32 1 %2 = OpTypePointer Private %3 %4 = OpConstantNull %3 @@ -176,16 +180,17 @@ TEST_F(BuilderTest, Loop_WithContinue) { // loop { // continue; // } - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - ast::LoopStatement expr(body, create()); + ast::LoopStatement loop(Source{}, body, + create(Source{})); - ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); + ASSERT_TRUE(td.DetermineResultType(&loop)) << td.error(); b.push_function(Function{}); - EXPECT_TRUE(b.GenerateLoopStatement(&expr)) << b.error(); + EXPECT_TRUE(b.GenerateLoopStatement(&loop)) << b.error(); EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"(OpBranch %1 %1 = OpLabel @@ -203,16 +208,17 @@ TEST_F(BuilderTest, Loop_WithBreak) { // loop { // break; // } - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - ast::LoopStatement expr(body, create()); + ast::LoopStatement loop(Source{}, body, + create(Source{})); - ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); + ASSERT_TRUE(td.DetermineResultType(&loop)) << td.error(); b.push_function(Function{}); - EXPECT_TRUE(b.GenerateLoopStatement(&expr)) << b.error(); + EXPECT_TRUE(b.GenerateLoopStatement(&loop)) << b.error(); EXPECT_EQ(DumpInstructions(b.functions()[0].instructions()), R"(OpBranch %1 %1 = OpLabel diff --git a/src/writer/spirv/builder_switch_test.cc b/src/writer/spirv/builder_switch_test.cc index 10341be3bc..3e99d19f97 100644 --- a/src/writer/spirv/builder_switch_test.cc +++ b/src/writer/spirv/builder_switch_test.cc @@ -47,7 +47,7 @@ TEST_F(BuilderTest, Switch_Empty) { auto* cond = create( Source{}, create(Source{}, &i32, 1)); - ast::SwitchStatement expr(cond, ast::CaseStatementList{}); + ast::SwitchStatement expr(Source{}, cond, ast::CaseStatementList{}); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -93,15 +93,17 @@ TEST_F(BuilderTest, Switch_WithCase) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* case_1_body = create(); + auto* case_1_body = create(Source{}); case_1_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 1)))); - auto* case_2_body = create(); + auto* case_2_body = create(Source{}); case_2_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( @@ -114,10 +116,13 @@ TEST_F(BuilderTest, Switch_WithCase) { selector_2.push_back(create(Source{}, &i32, 2)); ast::CaseStatementList cases; - cases.push_back(create(selector_1, case_1_body)); - cases.push_back(create(selector_2, case_2_body)); + cases.push_back( + create(Source{}, selector_1, case_1_body)); + cases.push_back( + create(Source{}, selector_2, case_2_body)); - ast::SwitchStatement expr(create( + ast::SwitchStatement expr(Source{}, + create( Source{}, mod->RegisterSymbol("a"), "a"), cases); @@ -126,7 +131,7 @@ TEST_F(BuilderTest, Switch_WithCase) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - &i32, create(), + &i32, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateGlobalVariable(v)) << b.error(); @@ -190,17 +195,20 @@ TEST_F(BuilderTest, Switch_WithDefault) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* default_body = create(); + auto* default_body = create(Source{}); default_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 1)))); ast::CaseStatementList cases; - cases.push_back(create(default_body)); + cases.push_back(create(Source{}, ast::CaseSelectorList{}, + default_body)); - ast::SwitchStatement expr(create( + ast::SwitchStatement expr(Source{}, + create( Source{}, mod->RegisterSymbol("a"), "a"), cases); @@ -209,7 +217,7 @@ TEST_F(BuilderTest, Switch_WithDefault) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - &i32, create(), + &i32, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateGlobalVariable(v)) << b.error(); @@ -271,22 +279,25 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* case_1_body = create(); + auto* case_1_body = create(Source{}); case_1_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 1)))); - auto* case_2_body = create(); + auto* case_2_body = create(Source{}); case_2_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 2)))); - auto* default_body = create(); + auto* default_body = create(Source{}); default_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( @@ -300,11 +311,15 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) { selector_2.push_back(create(Source{}, &i32, 3)); ast::CaseStatementList cases; - cases.push_back(create(selector_1, case_1_body)); - cases.push_back(create(selector_2, case_2_body)); - cases.push_back(create(default_body)); + cases.push_back( + create(Source{}, selector_1, case_1_body)); + cases.push_back( + create(Source{}, selector_2, case_2_body)); + cases.push_back(create(Source{}, ast::CaseSelectorList{}, + default_body)); - ast::SwitchStatement expr(create( + ast::SwitchStatement expr(Source{}, + create( Source{}, mod->RegisterSymbol("a"), "a"), cases); @@ -313,7 +328,7 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - &i32, create(), + &i32, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateGlobalVariable(v)) << b.error(); @@ -384,23 +399,26 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* case_1_body = create(); + auto* case_1_body = create(Source{}); case_1_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 1)))); - case_1_body->append(create()); + case_1_body->append(create(Source{})); - auto* case_2_body = create(); + auto* case_2_body = create(Source{}); case_2_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 2)))); - auto* default_body = create(); + auto* default_body = create(Source{}); default_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( @@ -413,11 +431,15 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) { selector_2.push_back(create(Source{}, &i32, 2)); ast::CaseStatementList cases; - cases.push_back(create(selector_1, case_1_body)); - cases.push_back(create(selector_2, case_2_body)); - cases.push_back(create(default_body)); + cases.push_back( + create(Source{}, selector_1, case_1_body)); + cases.push_back( + create(Source{}, selector_2, case_2_body)); + cases.push_back(create(Source{}, ast::CaseSelectorList{}, + default_body)); - ast::SwitchStatement expr(create( + ast::SwitchStatement expr(Source{}, + create( Source{}, mod->RegisterSymbol("a"), "a"), cases); @@ -426,7 +448,7 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - &i32, create(), + &i32, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateGlobalVariable(v)) << b.error(); @@ -493,21 +515,24 @@ TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* case_1_body = create(); + auto* case_1_body = create(Source{}); case_1_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( Source{}, create(Source{}, &i32, 1)))); - case_1_body->append(create()); + case_1_body->append(create(Source{})); ast::CaseSelectorList selector_1; selector_1.push_back(create(Source{}, &i32, 1)); ast::CaseStatementList cases; - cases.push_back(create(selector_1, case_1_body)); + cases.push_back( + create(Source{}, selector_1, case_1_body)); - ast::SwitchStatement expr(create( + ast::SwitchStatement expr(Source{}, + create( Source{}, mod->RegisterSymbol("a"), "a"), cases); @@ -516,7 +541,7 @@ TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - &i32, create(), + &i32, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateGlobalVariable(v)) << b.error(); @@ -556,10 +581,10 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* if_body = create(); - if_body->append(create()); + auto* if_body = create(Source{}); + if_body->append(create(Source{})); - auto* case_1_body = create(); + auto* case_1_body = create(Source{}); case_1_body->append(create( Source{}, create( @@ -567,6 +592,7 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) { if_body, ast::ElseStatementList{})); case_1_body->append(create( + Source{}, create(Source{}, mod->RegisterSymbol("v"), "v"), create( @@ -576,9 +602,11 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) { selector_1.push_back(create(Source{}, &i32, 1)); ast::CaseStatementList cases; - cases.push_back(create(selector_1, case_1_body)); + cases.push_back( + create(Source{}, selector_1, case_1_body)); - ast::SwitchStatement expr(create( + ast::SwitchStatement expr(Source{}, + create( Source{}, mod->RegisterSymbol("a"), "a"), cases); @@ -587,7 +615,7 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) { ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, - &i32, create(), + &i32, create(Source{}), ast::FunctionDecorationList{}); ASSERT_TRUE(b.GenerateGlobalVariable(v)) << b.error(); diff --git a/src/writer/wgsl/generator_impl_assign_test.cc b/src/writer/wgsl/generator_impl_assign_test.cc index 436a0a206d..0d3cde4de3 100644 --- a/src/writer/wgsl/generator_impl_assign_test.cc +++ b/src/writer/wgsl/generator_impl_assign_test.cc @@ -33,7 +33,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Assign) { Source{}, mod.RegisterSymbol("lhs"), "lhs"); auto* rhs = create( Source{}, mod.RegisterSymbol("rhs"), "rhs"); - ast::AssignmentStatement assign(lhs, rhs); + ast::AssignmentStatement assign(Source{}, lhs, rhs); gen.increment_indent(); diff --git a/src/writer/wgsl/generator_impl_block_test.cc b/src/writer/wgsl/generator_impl_block_test.cc index 85e00aa5da..b7e88b1291 100644 --- a/src/writer/wgsl/generator_impl_block_test.cc +++ b/src/writer/wgsl/generator_impl_block_test.cc @@ -28,8 +28,8 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Block) { - ast::BlockStatement b; - b.append(create()); + ast::BlockStatement b(Source{}); + b.append(create(Source{})); gen.increment_indent(); @@ -41,8 +41,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Block) { } TEST_F(WgslGeneratorImplTest, Emit_Block_WithoutNewline) { - ast::BlockStatement b; - b.append(create()); + ast::BlockStatement b(Source{}); + b.append(create(Source{})); gen.increment_indent(); diff --git a/src/writer/wgsl/generator_impl_break_test.cc b/src/writer/wgsl/generator_impl_break_test.cc index cb909f3de6..361f6c04ea 100644 --- a/src/writer/wgsl/generator_impl_break_test.cc +++ b/src/writer/wgsl/generator_impl_break_test.cc @@ -28,7 +28,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Break) { - ast::BreakStatement b; + ast::BreakStatement b(Source{}); gen.increment_indent(); diff --git a/src/writer/wgsl/generator_impl_call_test.cc b/src/writer/wgsl/generator_impl_call_test.cc index 1855d0cda5..6ad5e38564 100644 --- a/src/writer/wgsl/generator_impl_call_test.cc +++ b/src/writer/wgsl/generator_impl_call_test.cc @@ -60,7 +60,8 @@ TEST_F(WgslGeneratorImplTest, EmitStatement_Call) { params.push_back(create( Source{}, mod.RegisterSymbol("param2"), "param2")); - ast::CallStatement call(create(Source{}, id, params)); + ast::CallStatement call(Source{}, + create(Source{}, id, params)); gen.increment_indent(); ASSERT_TRUE(gen.EmitStatement(&call)) << gen.error(); diff --git a/src/writer/wgsl/generator_impl_case_test.cc b/src/writer/wgsl/generator_impl_case_test.cc index 1a1a444d0b..271ab692d3 100644 --- a/src/writer/wgsl/generator_impl_case_test.cc +++ b/src/writer/wgsl/generator_impl_case_test.cc @@ -33,12 +33,12 @@ using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Case) { ast::type::I32 i32; - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); ast::CaseSelectorList lit; lit.push_back(create(Source{}, &i32, 5)); - ast::CaseStatement c(lit, body); + ast::CaseStatement c(Source{}, lit, body); gen.increment_indent(); @@ -52,13 +52,13 @@ TEST_F(WgslGeneratorImplTest, Emit_Case) { TEST_F(WgslGeneratorImplTest, Emit_Case_MultipleSelectors) { ast::type::I32 i32; - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); ast::CaseSelectorList lit; lit.push_back(create(Source{}, &i32, 5)); lit.push_back(create(Source{}, &i32, 6)); - ast::CaseStatement c(lit, body); + ast::CaseStatement c(Source{}, lit, body); gen.increment_indent(); @@ -70,9 +70,9 @@ TEST_F(WgslGeneratorImplTest, Emit_Case_MultipleSelectors) { } TEST_F(WgslGeneratorImplTest, Emit_Case_Default) { - auto* body = create(); - body->append(create()); - ast::CaseStatement c(body); + auto* body = create(Source{}); + body->append(create(Source{})); + ast::CaseStatement c(Source{}, ast::CaseSelectorList{}, body); gen.increment_indent(); diff --git a/src/writer/wgsl/generator_impl_continue_test.cc b/src/writer/wgsl/generator_impl_continue_test.cc index 48d033e38d..384acba035 100644 --- a/src/writer/wgsl/generator_impl_continue_test.cc +++ b/src/writer/wgsl/generator_impl_continue_test.cc @@ -28,7 +28,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Continue) { - ast::ContinueStatement c; + ast::ContinueStatement c(Source{}); gen.increment_indent(); diff --git a/src/writer/wgsl/generator_impl_discard_test.cc b/src/writer/wgsl/generator_impl_discard_test.cc index 092d197f34..52633ecab2 100644 --- a/src/writer/wgsl/generator_impl_discard_test.cc +++ b/src/writer/wgsl/generator_impl_discard_test.cc @@ -25,7 +25,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Discard) { - ast::DiscardStatement k; + ast::DiscardStatement k(Source{}); gen.increment_indent(); diff --git a/src/writer/wgsl/generator_impl_fallthrough_test.cc b/src/writer/wgsl/generator_impl_fallthrough_test.cc index e8fcbe4b43..454c7f8987 100644 --- a/src/writer/wgsl/generator_impl_fallthrough_test.cc +++ b/src/writer/wgsl/generator_impl_fallthrough_test.cc @@ -25,7 +25,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Fallthrough) { - ast::FallthroughStatement f; + ast::FallthroughStatement f(Source{}); gen.increment_indent(); diff --git a/src/writer/wgsl/generator_impl_function_test.cc b/src/writer/wgsl/generator_impl_function_test.cc index 21407f7194..41263baf88 100644 --- a/src/writer/wgsl/generator_impl_function_test.cc +++ b/src/writer/wgsl/generator_impl_function_test.cc @@ -41,8 +41,8 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Function) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); body->append(create(Source{})); ast::type::Void void_type; @@ -60,8 +60,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Function) { } TEST_F(WgslGeneratorImplTest, Emit_Function_WithParams) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); body->append(create(Source{})); ast::type::F32 f32; @@ -99,8 +99,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithParams) { } TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_WorkgroupSize) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); body->append(create(Source{})); ast::type::Void void_type; @@ -122,8 +122,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_WorkgroupSize) { } TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_Stage) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); body->append(create(Source{})); ast::type::Void void_type; @@ -145,8 +145,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_Stage) { } TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_Multiple) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); body->append(create(Source{})); ast::type::Void void_type; @@ -237,8 +237,8 @@ TEST_F(WgslGeneratorImplTest, "d")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( @@ -267,8 +267,8 @@ TEST_F(WgslGeneratorImplTest, "d")), // constructor ast::VariableDecorationList{}); // decorations - auto* body = create(); - body->append(create(var)); + auto* body = create(Source{}); + body->append(create(Source{}, var)); body->append(create(Source{})); auto* func = create( diff --git a/src/writer/wgsl/generator_impl_if_test.cc b/src/writer/wgsl/generator_impl_if_test.cc index 8b3e0e9e6a..75d0694f8c 100644 --- a/src/writer/wgsl/generator_impl_if_test.cc +++ b/src/writer/wgsl/generator_impl_if_test.cc @@ -30,8 +30,8 @@ using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_If) { auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); ast::IfStatement i(Source{}, cond, body, ast::ElseStatementList{}); @@ -47,16 +47,17 @@ TEST_F(WgslGeneratorImplTest, Emit_If) { TEST_F(WgslGeneratorImplTest, Emit_IfWithElseIf) { auto* else_cond = create( Source{}, mod.RegisterSymbol("else_cond"), "else_cond"); - auto* else_body = create(); - else_body->append(create()); + auto* else_body = create(Source{}); + else_body->append(create(Source{})); auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - ast::IfStatement i(Source{}, cond, body, - {create(else_cond, else_body)}); + ast::IfStatement i( + Source{}, cond, body, + {create(Source{}, else_cond, else_body)}); gen.increment_indent(); @@ -70,16 +71,17 @@ TEST_F(WgslGeneratorImplTest, Emit_IfWithElseIf) { } TEST_F(WgslGeneratorImplTest, Emit_IfWithElse) { - auto* else_body = create(); - else_body->append(create()); + auto* else_body = create(Source{}); + else_body->append(create(Source{})); auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - ast::IfStatement i(Source{}, cond, body, - {create(else_body)}); + ast::IfStatement i( + Source{}, cond, body, + {create(Source{}, nullptr, else_body)}); gen.increment_indent(); @@ -96,22 +98,23 @@ TEST_F(WgslGeneratorImplTest, Emit_IfWithMultiple) { auto* else_cond = create( Source{}, mod.RegisterSymbol("else_cond"), "else_cond"); - auto* else_body = create(); - else_body->append(create()); + auto* else_body = create(Source{}); + else_body->append(create(Source{})); - auto* else_body_2 = create(); - else_body_2->append(create()); + auto* else_body_2 = create(Source{}); + else_body_2->append(create(Source{})); auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - ast::IfStatement i(Source{}, cond, body, - { - create(else_cond, else_body), - create(else_body_2), - }); + ast::IfStatement i( + Source{}, cond, body, + { + create(Source{}, else_cond, else_body), + create(Source{}, nullptr, else_body_2), + }); gen.increment_indent(); diff --git a/src/writer/wgsl/generator_impl_loop_test.cc b/src/writer/wgsl/generator_impl_loop_test.cc index 41c399d9dc..4c0b11e43e 100644 --- a/src/writer/wgsl/generator_impl_loop_test.cc +++ b/src/writer/wgsl/generator_impl_loop_test.cc @@ -28,9 +28,9 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Loop) { - auto* body = create(); - body->append(create()); - ast::LoopStatement l(body, {}); + auto* body = create(Source{}); + body->append(create(Source{})); + ast::LoopStatement l(Source{}, body, {}); gen.increment_indent(); @@ -42,13 +42,13 @@ TEST_F(WgslGeneratorImplTest, Emit_Loop) { } TEST_F(WgslGeneratorImplTest, Emit_LoopWithContinuing) { - auto* body = create(); - body->append(create()); + auto* body = create(Source{}); + body->append(create(Source{})); - auto* continuing = create(); - continuing->append(create()); + auto* continuing = create(Source{}); + continuing->append(create(Source{})); - ast::LoopStatement l(body, continuing); + ast::LoopStatement l(Source{}, body, continuing); gen.increment_indent(); diff --git a/src/writer/wgsl/generator_impl_switch_test.cc b/src/writer/wgsl/generator_impl_switch_test.cc index 96ddc99e24..f8bd646bb1 100644 --- a/src/writer/wgsl/generator_impl_switch_test.cc +++ b/src/writer/wgsl/generator_impl_switch_test.cc @@ -32,18 +32,19 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Switch) { - auto* def_body = create(); - def_body->append(create()); - auto* def = create(def_body); + auto* def_body = create(Source{}); + def_body->append(create(Source{})); + auto* def = + create(Source{}, ast::CaseSelectorList{}, def_body); ast::type::I32 i32; ast::CaseSelectorList case_val; case_val.push_back(create(Source{}, &i32, 5)); - auto* case_body = create(); - case_body->append(create()); + auto* case_body = create(Source{}); + case_body->append(create(Source{})); - auto* case_stmt = create(case_val, case_body); + auto* case_stmt = create(Source{}, case_val, case_body); ast::CaseStatementList body; body.push_back(case_stmt); @@ -51,7 +52,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Switch) { auto* cond = create( Source{}, mod.RegisterSymbol("cond"), "cond"); - ast::SwitchStatement s(cond, body); + ast::SwitchStatement s(Source{}, cond, body); gen.increment_indent(); diff --git a/src/writer/wgsl/generator_impl_test.cc b/src/writer/wgsl/generator_impl_test.cc index 1b8da48a8a..e1780131ae 100644 --- a/src/writer/wgsl/generator_impl_test.cc +++ b/src/writer/wgsl/generator_impl_test.cc @@ -34,7 +34,7 @@ TEST_F(WgslGeneratorImplTest, Generate) { mod.AddFunction(create( Source{}, mod.RegisterSymbol("a_func"), "my_func", ast::VariableList{}, - &void_type, create(), + &void_type, create(Source{}), ast::FunctionDecorationList{})); ASSERT_TRUE(gen.Generate(mod)) << gen.error(); diff --git a/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc b/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc index c892a2b7c2..c7a11bcde5 100644 --- a/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc @@ -41,7 +41,7 @@ TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent(); @@ -63,7 +63,7 @@ TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Function) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent(); @@ -82,7 +82,7 @@ TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Private) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::VariableDeclStatement stmt(var); + ast::VariableDeclStatement stmt(Source{}, var); gen.increment_indent();