From 6b59bf45aab0bcbcc91122421791cd43453d8cf4 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Fri, 11 Dec 2020 19:16:13 +0000 Subject: [PATCH] Add a symbol to the Identifier AST node This CL adds a Symbol to the identifier to represent the name. The name still exists but will be removed in a future CL when the namers are in place. Change-Id: Ic3cc8ad0d99e3bea6eb1ff1ce212e7de67991aec Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35460 Commit-Queue: dan sinclair Auto-Submit: dan sinclair Reviewed-by: Ben Clayton --- src/ast/array_accessor_expression_test.cc | 34 +- src/ast/assignment_statement_test.cc | 34 +- src/ast/binary_expression_test.cc | 38 +- src/ast/bitcast_expression_test.cc | 16 +- src/ast/builder.h | 4 +- src/ast/call_expression_test.cc | 45 +- src/ast/call_statement_test.cc | 17 +- src/ast/identifier_expression.cc | 14 +- src/ast/identifier_expression.h | 12 +- src/ast/identifier_expression_test.cc | 20 +- src/ast/if_statement_test.cc | 54 +- src/ast/member_accessor_expression_test.cc | 48 +- src/ast/module.cc | 6 +- src/ast/return_statement_test.cc | 12 +- src/ast/switch_statement_test.cc | 30 +- src/ast/type_constructor_expression_test.cc | 31 +- src/ast/unary_op_expression_test.cc | 19 +- src/ast/variable_test.cc | 19 +- src/inspector/inspector_test.cc | 91 ++- src/reader/spirv/function.cc | 105 ++- src/reader/spirv/function_arithmetic_test.cc | 90 ++- src/reader/spirv/function_bit_test.cc | 67 +- src/reader/spirv/function_call_test.cc | 35 +- src/reader/spirv/function_cfg_test.cc | 194 ++--- src/reader/spirv/function_composite_test.cc | 74 +- src/reader/spirv/function_conversion_test.cc | 88 ++- .../spirv/function_glsl_std_450_test.cc | 164 ++-- src/reader/spirv/function_logical_test.cc | 114 +-- src/reader/spirv/function_memory_test.cc | 56 +- src/reader/spirv/function_misc_test.cc | 32 +- src/reader/spirv/function_var_test.cc | 118 +-- .../spirv/parser_impl_function_decl_test.cc | 12 +- src/reader/spirv/parser_impl_handle_test.cc | 13 +- .../spirv/parser_impl_module_var_test.cc | 14 +- src/reader/spirv/parser_impl_test_helper.h | 6 +- src/reader/wgsl/parser_impl.cc | 10 +- src/transform/bound_array_accessors.cc | 4 +- src/transform/emit_vertex_point_size.cc | 4 +- src/transform/emit_vertex_point_size_test.cc | 40 +- src/transform/first_index_offset.cc | 11 +- src/transform/first_index_offset_test.cc | 15 +- src/transform/vertex_pulling.cc | 20 +- src/transform/vertex_pulling_test.cc | 32 +- src/type_determiner_test.cc | 734 ++++++++++++------ src/validator/validator_control_block_test.cc | 31 +- src/validator/validator_function_test.cc | 7 +- src/validator/validator_test.cc | 43 +- .../generator_impl_array_accessor_test.cc | 9 +- src/writer/hlsl/generator_impl_assign_test.cc | 6 +- src/writer/hlsl/generator_impl_binary_test.cc | 123 +-- .../hlsl/generator_impl_bitcast_test.cc | 6 +- src/writer/hlsl/generator_impl_call_test.cc | 21 +- src/writer/hlsl/generator_impl_cast_test.cc | 6 +- ...tor_impl_function_entry_point_data_test.cc | 55 +- .../hlsl/generator_impl_function_test.cc | 161 ++-- .../hlsl/generator_impl_identifier_test.cc | 4 +- src/writer/hlsl/generator_impl_if_test.cc | 18 +- src/writer/hlsl/generator_impl_import_test.cc | 30 +- .../hlsl/generator_impl_intrinsic_test.cc | 22 +- src/writer/hlsl/generator_impl_loop_test.cc | 12 +- .../generator_impl_member_accessor_test.cc | 127 +-- src/writer/hlsl/generator_impl_return_test.cc | 3 +- src/writer/hlsl/generator_impl_switch_test.cc | 3 +- src/writer/hlsl/generator_impl_test.cc | 3 +- .../hlsl/generator_impl_unary_op_test.cc | 3 +- ...rator_impl_variable_decl_statement_test.cc | 3 +- .../msl/generator_impl_array_accessor_test.cc | 9 +- src/writer/msl/generator_impl_assign_test.cc | 6 +- src/writer/msl/generator_impl_binary_test.cc | 6 +- src/writer/msl/generator_impl_bitcast_test.cc | 2 +- src/writer/msl/generator_impl_call_test.cc | 21 +- src/writer/msl/generator_impl_cast_test.cc | 6 +- ...tor_impl_function_entry_point_data_test.cc | 55 +- .../msl/generator_impl_function_test.cc | 175 +++-- .../msl/generator_impl_identifier_test.cc | 4 +- src/writer/msl/generator_impl_if_test.cc | 18 +- src/writer/msl/generator_impl_import_test.cc | 31 +- .../msl/generator_impl_intrinsic_test.cc | 22 +- src/writer/msl/generator_impl_loop_test.cc | 12 +- .../generator_impl_member_accessor_test.cc | 6 +- src/writer/msl/generator_impl_return_test.cc | 3 +- src/writer/msl/generator_impl_switch_test.cc | 3 +- src/writer/msl/generator_impl_test.cc | 3 +- .../msl/generator_impl_unary_op_test.cc | 3 +- ...rator_impl_variable_decl_statement_test.cc | 3 +- .../spirv/builder_accessor_expression_test.cc | 114 +-- src/writer/spirv/builder_assign_test.cc | 29 +- .../spirv/builder_binary_expression_test.cc | 32 +- src/writer/spirv/builder_block_test.cc | 6 +- src/writer/spirv/builder_call_test.cc | 26 +- .../spirv/builder_function_decoration_test.cc | 17 +- src/writer/spirv/builder_function_test.cc | 18 +- .../spirv/builder_function_variable_test.cc | 14 +- .../spirv/builder_ident_expression_test.cc | 20 +- src/writer/spirv/builder_if_test.cc | 79 +- src/writer/spirv/builder_loop_test.cc | 24 +- src/writer/spirv/builder_return_test.cc | 5 +- src/writer/spirv/builder_switch_test.cc | 106 +-- .../spirv/builder_unary_op_expression_test.cc | 5 +- .../generator_impl_array_accessor_test.cc | 9 +- src/writer/wgsl/generator_impl_assign_test.cc | 6 +- src/writer/wgsl/generator_impl_binary_test.cc | 6 +- .../wgsl/generator_impl_bitcast_test.cc | 2 +- src/writer/wgsl/generator_impl_call_test.cc | 21 +- src/writer/wgsl/generator_impl_cast_test.cc | 3 +- .../wgsl/generator_impl_function_test.cc | 12 +- .../wgsl/generator_impl_identifier_test.cc | 2 +- src/writer/wgsl/generator_impl_if_test.cc | 18 +- .../generator_impl_member_accessor_test.cc | 6 +- src/writer/wgsl/generator_impl_return_test.cc | 3 +- src/writer/wgsl/generator_impl_switch_test.cc | 3 +- .../wgsl/generator_impl_unary_op_test.cc | 3 +- .../wgsl/generator_impl_variable_test.cc | 6 +- 113 files changed, 2525 insertions(+), 1750 deletions(-) diff --git a/src/ast/array_accessor_expression_test.cc b/src/ast/array_accessor_expression_test.cc index 9526284065..9bb30e0d6c 100644 --- a/src/ast/array_accessor_expression_test.cc +++ b/src/ast/array_accessor_expression_test.cc @@ -24,8 +24,8 @@ namespace { using ArrayAccessorExpressionTest = TestHelper; TEST_F(ArrayAccessorExpressionTest, Create) { - auto* ary = create("ary"); - auto* idx = create("idx"); + auto* ary = create(mod.RegisterSymbol("ary"), "ary"); + auto* idx = create(mod.RegisterSymbol("idx"), "idx"); ArrayAccessorExpression exp(ary, idx); ASSERT_EQ(exp.array(), ary); @@ -33,8 +33,8 @@ TEST_F(ArrayAccessorExpressionTest, Create) { } TEST_F(ArrayAccessorExpressionTest, CreateWithSource) { - auto* ary = create("ary"); - auto* idx = create("idx"); + auto* ary = create(mod.RegisterSymbol("ary"), "ary"); + auto* idx = create(mod.RegisterSymbol("idx"), "idx"); ArrayAccessorExpression exp(Source{Source::Location{20, 2}}, ary, idx); auto src = exp.source(); @@ -43,58 +43,58 @@ TEST_F(ArrayAccessorExpressionTest, CreateWithSource) { } TEST_F(ArrayAccessorExpressionTest, IsArrayAccessor) { - auto* ary = create("ary"); - auto* idx = create("idx"); + auto* ary = create(mod.RegisterSymbol("ary"), "ary"); + auto* idx = create(mod.RegisterSymbol("idx"), "idx"); ArrayAccessorExpression exp(ary, idx); EXPECT_TRUE(exp.Is()); } TEST_F(ArrayAccessorExpressionTest, IsValid) { - auto* ary = create("ary"); - auto* idx = create("idx"); + auto* ary = create(mod.RegisterSymbol("ary"), "ary"); + auto* idx = create(mod.RegisterSymbol("idx"), "idx"); ArrayAccessorExpression exp(ary, idx); EXPECT_TRUE(exp.IsValid()); } TEST_F(ArrayAccessorExpressionTest, IsValid_MissingArray) { - auto* idx = create("idx"); + auto* idx = create(mod.RegisterSymbol("idx"), "idx"); ArrayAccessorExpression exp(nullptr, idx); EXPECT_FALSE(exp.IsValid()); } TEST_F(ArrayAccessorExpressionTest, IsValid_MissingIndex) { - auto* ary = create("ary"); + auto* ary = create(mod.RegisterSymbol("ary"), "ary"); ArrayAccessorExpression exp(ary, nullptr); EXPECT_FALSE(exp.IsValid()); } TEST_F(ArrayAccessorExpressionTest, IsValid_InvalidArray) { - auto* ary = create(""); - auto* idx = create("idx"); + auto* ary = create(mod.RegisterSymbol(""), ""); + auto* idx = create(mod.RegisterSymbol("idx"), "idx"); ArrayAccessorExpression exp(ary, idx); EXPECT_FALSE(exp.IsValid()); } TEST_F(ArrayAccessorExpressionTest, IsValid_InvalidIndex) { - auto* ary = create("ary"); - auto* idx = create(""); + auto* ary = create(mod.RegisterSymbol("ary"), "ary"); + auto* idx = create(mod.RegisterSymbol(""), ""); ArrayAccessorExpression exp(ary, idx); EXPECT_FALSE(exp.IsValid()); } TEST_F(ArrayAccessorExpressionTest, ToStr) { - auto* ary = create("ary"); - auto* idx = create("idx"); + auto* ary = create(mod.RegisterSymbol("ary"), "ary"); + auto* idx = create(mod.RegisterSymbol("idx"), "idx"); ArrayAccessorExpression exp(ary, idx); std::ostringstream out; exp.to_str(out, 2); - EXPECT_EQ(out.str(), R"( ArrayAccessor[not set]{ + EXPECT_EQ(demangle(out.str()), R"( ArrayAccessor[not set]{ Identifier[not set]{ary} Identifier[not set]{idx} } diff --git a/src/ast/assignment_statement_test.cc b/src/ast/assignment_statement_test.cc index 8fa68a4096..4f69c58410 100644 --- a/src/ast/assignment_statement_test.cc +++ b/src/ast/assignment_statement_test.cc @@ -24,8 +24,8 @@ namespace { using AssignmentStatementTest = TestHelper; TEST_F(AssignmentStatementTest, Creation) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); AssignmentStatement stmt(lhs, rhs); EXPECT_EQ(stmt.lhs(), lhs); @@ -33,8 +33,8 @@ TEST_F(AssignmentStatementTest, Creation) { } TEST_F(AssignmentStatementTest, CreationWithSource) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); AssignmentStatement stmt(Source{Source::Location{20, 2}}, lhs, rhs); auto src = stmt.source(); @@ -43,58 +43,58 @@ TEST_F(AssignmentStatementTest, CreationWithSource) { } TEST_F(AssignmentStatementTest, IsAssign) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); AssignmentStatement stmt(lhs, rhs); EXPECT_TRUE(stmt.Is()); } TEST_F(AssignmentStatementTest, IsValid) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); AssignmentStatement stmt(lhs, rhs); EXPECT_TRUE(stmt.IsValid()); } TEST_F(AssignmentStatementTest, IsValid_MissingLHS) { - auto* rhs = create("rhs"); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); AssignmentStatement stmt(nullptr, rhs); EXPECT_FALSE(stmt.IsValid()); } TEST_F(AssignmentStatementTest, IsValid_MissingRHS) { - auto* lhs = create("lhs"); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); AssignmentStatement stmt(lhs, nullptr); EXPECT_FALSE(stmt.IsValid()); } TEST_F(AssignmentStatementTest, IsValid_InvalidLHS) { - auto* lhs = create(""); - auto* rhs = create("rhs"); + auto* lhs = create(mod.RegisterSymbol(""), ""); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); AssignmentStatement stmt(lhs, rhs); EXPECT_FALSE(stmt.IsValid()); } TEST_F(AssignmentStatementTest, IsValid_InvalidRHS) { - auto* lhs = create("lhs"); - auto* rhs = create(""); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = create(mod.RegisterSymbol(""), ""); AssignmentStatement stmt(lhs, rhs); EXPECT_FALSE(stmt.IsValid()); } TEST_F(AssignmentStatementTest, ToStr) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); AssignmentStatement stmt(lhs, rhs); std::ostringstream out; stmt.to_str(out, 2); - EXPECT_EQ(out.str(), R"( Assignment{ + EXPECT_EQ(demangle(out.str()), R"( Assignment{ Identifier[not set]{lhs} Identifier[not set]{rhs} } diff --git a/src/ast/binary_expression_test.cc b/src/ast/binary_expression_test.cc index 6494a78c05..ecba1ac2a6 100644 --- a/src/ast/binary_expression_test.cc +++ b/src/ast/binary_expression_test.cc @@ -26,8 +26,8 @@ namespace { using BinaryExpressionTest = TestHelper; TEST_F(BinaryExpressionTest, Creation) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); BinaryExpression r(BinaryOp::kEqual, lhs, rhs); EXPECT_EQ(r.lhs(), lhs); @@ -36,8 +36,8 @@ TEST_F(BinaryExpressionTest, Creation) { } TEST_F(BinaryExpressionTest, Creation_WithSource) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); BinaryExpression r(Source{Source::Location{20, 2}}, BinaryOp::kEqual, lhs, rhs); @@ -47,67 +47,67 @@ TEST_F(BinaryExpressionTest, Creation_WithSource) { } TEST_F(BinaryExpressionTest, IsBinary) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); BinaryExpression r(BinaryOp::kEqual, lhs, rhs); EXPECT_TRUE(r.Is()); } TEST_F(BinaryExpressionTest, IsValid) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); BinaryExpression r(BinaryOp::kEqual, lhs, rhs); EXPECT_TRUE(r.IsValid()); } TEST_F(BinaryExpressionTest, IsValid_Null_LHS) { - auto* rhs = create("rhs"); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); BinaryExpression r(BinaryOp::kEqual, nullptr, rhs); EXPECT_FALSE(r.IsValid()); } TEST_F(BinaryExpressionTest, IsValid_Invalid_LHS) { - auto* lhs = create(""); - auto* rhs = create("rhs"); + auto* lhs = create(mod.RegisterSymbol(""), ""); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); BinaryExpression r(BinaryOp::kEqual, lhs, rhs); EXPECT_FALSE(r.IsValid()); } TEST_F(BinaryExpressionTest, IsValid_Null_RHS) { - auto* lhs = create("lhs"); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); BinaryExpression r(BinaryOp::kEqual, lhs, nullptr); EXPECT_FALSE(r.IsValid()); } TEST_F(BinaryExpressionTest, IsValid_Invalid_RHS) { - auto* lhs = create("lhs"); - auto* rhs = create(""); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = create(mod.RegisterSymbol(""), ""); BinaryExpression r(BinaryOp::kEqual, lhs, rhs); EXPECT_FALSE(r.IsValid()); } TEST_F(BinaryExpressionTest, IsValid_Binary_None) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); BinaryExpression r(BinaryOp::kNone, lhs, rhs); EXPECT_FALSE(r.IsValid()); } TEST_F(BinaryExpressionTest, ToStr) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = create(mod.RegisterSymbol("rhs"), "rhs"); BinaryExpression r(BinaryOp::kEqual, lhs, rhs); std::ostringstream out; r.to_str(out, 2); - EXPECT_EQ(out.str(), R"( Binary[not set]{ + EXPECT_EQ(demangle(out.str()), R"( Binary[not set]{ Identifier[not set]{lhs} equal Identifier[not set]{rhs} diff --git a/src/ast/bitcast_expression_test.cc b/src/ast/bitcast_expression_test.cc index 1c8afc1634..ebf8ec0512 100644 --- a/src/ast/bitcast_expression_test.cc +++ b/src/ast/bitcast_expression_test.cc @@ -26,7 +26,7 @@ using BitcastExpressionTest = TestHelper; TEST_F(BitcastExpressionTest, Create) { type::F32 f32; - auto* expr = create("expr"); + auto* expr = create(mod.RegisterSymbol("expr"), "expr"); BitcastExpression exp(&f32, expr); ASSERT_EQ(exp.type(), &f32); @@ -35,7 +35,7 @@ TEST_F(BitcastExpressionTest, Create) { TEST_F(BitcastExpressionTest, CreateWithSource) { type::F32 f32; - auto* expr = create("expr"); + auto* expr = create(mod.RegisterSymbol("expr"), "expr"); BitcastExpression exp(Source{Source::Location{20, 2}}, &f32, expr); auto src = exp.source(); @@ -45,7 +45,7 @@ TEST_F(BitcastExpressionTest, CreateWithSource) { TEST_F(BitcastExpressionTest, IsBitcast) { type::F32 f32; - auto* expr = create("expr"); + auto* expr = create(mod.RegisterSymbol("expr"), "expr"); BitcastExpression exp(&f32, expr); EXPECT_TRUE(exp.Is()); @@ -53,14 +53,14 @@ TEST_F(BitcastExpressionTest, IsBitcast) { TEST_F(BitcastExpressionTest, IsValid) { type::F32 f32; - auto* expr = create("expr"); + auto* expr = create(mod.RegisterSymbol("expr"), "expr"); BitcastExpression exp(&f32, expr); EXPECT_TRUE(exp.IsValid()); } TEST_F(BitcastExpressionTest, IsValid_MissingType) { - auto* expr = create("expr"); + auto* expr = create(mod.RegisterSymbol("expr"), "expr"); BitcastExpression exp(nullptr, expr); EXPECT_FALSE(exp.IsValid()); @@ -75,20 +75,20 @@ TEST_F(BitcastExpressionTest, IsValid_MissingExpr) { TEST_F(BitcastExpressionTest, IsValid_InvalidExpr) { type::F32 f32; - auto* expr = create(""); + auto* expr = create(mod.RegisterSymbol(""), ""); BitcastExpression e(&f32, expr); EXPECT_FALSE(e.IsValid()); } TEST_F(BitcastExpressionTest, ToStr) { type::F32 f32; - auto* expr = create("expr"); + auto* expr = create(mod.RegisterSymbol("expr"), "expr"); BitcastExpression exp(&f32, expr); std::ostringstream out; exp.to_str(out, 2); - EXPECT_EQ(out.str(), R"( Bitcast[not set]<__f32>{ + EXPECT_EQ(demangle(out.str()), R"( Bitcast[not set]<__f32>{ Identifier[not set]{expr} } )"); diff --git a/src/ast/builder.h b/src/ast/builder.h index 4a01d50720..189ebdb91d 100644 --- a/src/ast/builder.h +++ b/src/ast/builder.h @@ -206,13 +206,13 @@ class Builder { /// @param name the identifier name /// @return an IdentifierExpression with the given name IdentifierExpression* Expr(const std::string& name) { - return create(name); + return create(mod->RegisterSymbol(name), name); } /// @param name the identifier name /// @return an IdentifierExpression with the given name IdentifierExpression* Expr(const char* name) { - return create(name); + return create(mod->RegisterSymbol(name), name); } /// @param value the boolean value diff --git a/src/ast/call_expression_test.cc b/src/ast/call_expression_test.cc index be8407258e..4b59395fb7 100644 --- a/src/ast/call_expression_test.cc +++ b/src/ast/call_expression_test.cc @@ -24,10 +24,12 @@ namespace { using CallExpressionTest = TestHelper; TEST_F(CallExpressionTest, Creation) { - auto* func = create("func"); + auto* func = create(mod.RegisterSymbol("func"), "func"); ExpressionList params; - params.push_back(create("param1")); - params.push_back(create("param2")); + params.push_back( + create(mod.RegisterSymbol("param1"), "param1")); + params.push_back( + create(mod.RegisterSymbol("param2"), "param2")); CallExpression stmt(func, params); EXPECT_EQ(stmt.func(), func); @@ -39,7 +41,7 @@ TEST_F(CallExpressionTest, Creation) { } TEST_F(CallExpressionTest, Creation_WithSource) { - auto* func = create("func"); + auto* func = create(mod.RegisterSymbol("func"), "func"); CallExpression stmt(Source{Source::Location{20, 2}}, func, {}); auto src = stmt.source(); EXPECT_EQ(src.range.begin.line, 20u); @@ -47,13 +49,13 @@ TEST_F(CallExpressionTest, Creation_WithSource) { } TEST_F(CallExpressionTest, IsCall) { - auto* func = create("func"); + auto* func = create(mod.RegisterSymbol("func"), "func"); CallExpression stmt(func, {}); EXPECT_TRUE(stmt.Is()); } TEST_F(CallExpressionTest, IsValid) { - auto* func = create("func"); + auto* func = create(mod.RegisterSymbol("func"), "func"); CallExpression stmt(func, {}); EXPECT_TRUE(stmt.IsValid()); } @@ -64,40 +66,43 @@ TEST_F(CallExpressionTest, IsValid_MissingFunction) { } TEST_F(CallExpressionTest, IsValid_NullParam) { - auto* func = create("func"); + auto* func = create(mod.RegisterSymbol("func"), "func"); ExpressionList params; - params.push_back(create("param1")); + params.push_back( + create(mod.RegisterSymbol("param1"), "param1")); params.push_back(nullptr); - params.push_back(create("param2")); + params.push_back( + create(mod.RegisterSymbol("param2"), "param2")); CallExpression stmt(func, params); EXPECT_FALSE(stmt.IsValid()); } TEST_F(CallExpressionTest, IsValid_InvalidFunction) { - auto* func = create(""); + auto* func = create(mod.RegisterSymbol(""), ""); ExpressionList params; - params.push_back(create("param1")); + params.push_back( + create(mod.RegisterSymbol("param1"), "param1")); CallExpression stmt(func, params); EXPECT_FALSE(stmt.IsValid()); } TEST_F(CallExpressionTest, IsValid_InvalidParam) { - auto* func = create("func"); + auto* func = create(mod.RegisterSymbol("func"), "func"); ExpressionList params; - params.push_back(create("")); + params.push_back(create(mod.RegisterSymbol(""), "")); CallExpression stmt(func, params); EXPECT_FALSE(stmt.IsValid()); } TEST_F(CallExpressionTest, ToStr_NoParams) { - auto* func = create("func"); + auto* func = create(mod.RegisterSymbol("func"), "func"); CallExpression stmt(func, {}); std::ostringstream out; stmt.to_str(out, 2); - EXPECT_EQ(out.str(), R"( Call[not set]{ + EXPECT_EQ(demangle(out.str()), R"( Call[not set]{ Identifier[not set]{func} ( ) @@ -106,15 +111,17 @@ TEST_F(CallExpressionTest, ToStr_NoParams) { } TEST_F(CallExpressionTest, ToStr_WithParams) { - auto* func = create("func"); + auto* func = create(mod.RegisterSymbol("func"), "func"); ExpressionList params; - params.push_back(create("param1")); - params.push_back(create("param2")); + params.push_back( + create(mod.RegisterSymbol("param1"), "param1")); + params.push_back( + create(mod.RegisterSymbol("param2"), "param2")); CallExpression stmt(func, params); std::ostringstream out; stmt.to_str(out, 2); - EXPECT_EQ(out.str(), R"( Call[not set]{ + EXPECT_EQ(demangle(out.str()), R"( Call[not set]{ Identifier[not set]{func} ( Identifier[not set]{param1} diff --git a/src/ast/call_statement_test.cc b/src/ast/call_statement_test.cc index 8a0e7b5726..44f3604481 100644 --- a/src/ast/call_statement_test.cc +++ b/src/ast/call_statement_test.cc @@ -25,8 +25,9 @@ namespace { using CallStatementTest = TestHelper; TEST_F(CallStatementTest, Creation) { - auto* expr = create(create("func"), - ExpressionList{}); + auto* expr = create( + create(mod.RegisterSymbol("func"), "func"), + ExpressionList{}); CallStatement c(expr); EXPECT_EQ(c.expr(), expr); @@ -38,8 +39,9 @@ TEST_F(CallStatementTest, IsCall) { } TEST_F(CallStatementTest, IsValid) { - CallStatement c(create(create("func"), - ExpressionList{})); + CallStatement c(create( + create(mod.RegisterSymbol("func"), "func"), + ExpressionList{})); EXPECT_TRUE(c.IsValid()); } @@ -55,12 +57,13 @@ TEST_F(CallStatementTest, IsValid_InvalidExpr) { } TEST_F(CallStatementTest, ToStr) { - CallStatement c(create(create("func"), - ExpressionList{})); + CallStatement c(create( + create(mod.RegisterSymbol("func"), "func"), + ExpressionList{})); std::ostringstream out; c.to_str(out, 2); - EXPECT_EQ(out.str(), R"( Call[not set]{ + EXPECT_EQ(demangle(out.str()), R"( Call[not set]{ Identifier[not set]{func} ( ) diff --git a/src/ast/identifier_expression.cc b/src/ast/identifier_expression.cc index d4770db557..04ae344072 100644 --- a/src/ast/identifier_expression.cc +++ b/src/ast/identifier_expression.cc @@ -22,28 +22,30 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::IdentifierExpression); namespace tint { namespace ast { -IdentifierExpression::IdentifierExpression(const std::string& name) - : Base(), name_(name) {} +IdentifierExpression::IdentifierExpression(Symbol sym, const std::string& name) + : Base(), sym_(sym), name_(name) {} IdentifierExpression::IdentifierExpression(const Source& source, + Symbol sym, const std::string& name) - : Base(source), name_(name) {} + : Base(source), sym_(sym), name_(name) {} IdentifierExpression::IdentifierExpression(IdentifierExpression&&) = default; IdentifierExpression::~IdentifierExpression() = default; IdentifierExpression* IdentifierExpression::Clone(CloneContext* ctx) const { - return ctx->mod->create(ctx->Clone(source()), name_); + return ctx->mod->create(ctx->Clone(source()), sym_, + name_); } bool IdentifierExpression::IsValid() const { - return !name_.empty(); + return sym_.IsValid(); } void IdentifierExpression::to_str(std::ostream& out, size_t indent) const { make_indent(out, indent); - out << "Identifier[" << result_type_str() << "]{" << name_ << "}" + out << "Identifier[" << result_type_str() << "]{" << sym_.to_str() << "}" << std::endl; } diff --git a/src/ast/identifier_expression.h b/src/ast/identifier_expression.h index 703c041b11..9fa2660884 100644 --- a/src/ast/identifier_expression.h +++ b/src/ast/identifier_expression.h @@ -21,6 +21,7 @@ #include "src/ast/expression.h" #include "src/ast/intrinsic.h" +#include "src/symbol.h" namespace tint { namespace ast { @@ -29,16 +30,22 @@ namespace ast { class IdentifierExpression : public Castable { public: /// Constructor + /// @param sym the symbol for the identifier /// @param name the name - explicit IdentifierExpression(const std::string& name); + explicit IdentifierExpression(Symbol sym, const std::string& name); /// Constructor /// @param source the source + /// @param sym the symbol for the identifier /// @param name the name - IdentifierExpression(const Source& source, const std::string& name); + IdentifierExpression(const Source& source, + Symbol sym, + const std::string& name); /// Move constructor IdentifierExpression(IdentifierExpression&&); ~IdentifierExpression() override; + /// @returns the symbol for the identifier + Symbol symbol() const { return sym_; } /// @returns the name part of the identifier std::string name() const { return name_; } @@ -82,6 +89,7 @@ class IdentifierExpression : public Castable { Intrinsic intrinsic_ = Intrinsic::kNone; std::unique_ptr intrinsic_sig_; + Symbol sym_; std::string name_; }; diff --git a/src/ast/identifier_expression_test.cc b/src/ast/identifier_expression_test.cc index 7ef416e550..a81f9cddba 100644 --- a/src/ast/identifier_expression_test.cc +++ b/src/ast/identifier_expression_test.cc @@ -23,12 +23,15 @@ namespace { using IdentifierExpressionTest = TestHelper; TEST_F(IdentifierExpressionTest, Creation) { - IdentifierExpression i("ident"); + IdentifierExpression i(mod.RegisterSymbol("ident"), "ident"); + EXPECT_EQ(i.symbol(), Symbol(1)); EXPECT_EQ(i.name(), "ident"); } TEST_F(IdentifierExpressionTest, Creation_WithSource) { - IdentifierExpression i(Source{Source::Location{20, 2}}, "ident"); + IdentifierExpression i(Source{Source::Location{20, 2}}, + mod.RegisterSymbol("ident"), "ident"); + EXPECT_EQ(i.symbol(), Symbol(1)); EXPECT_EQ(i.name(), "ident"); auto src = i.source(); @@ -37,25 +40,20 @@ TEST_F(IdentifierExpressionTest, Creation_WithSource) { } TEST_F(IdentifierExpressionTest, IsIdentifier) { - IdentifierExpression i("ident"); + IdentifierExpression i(mod.RegisterSymbol("ident"), "ident"); EXPECT_TRUE(i.Is()); } TEST_F(IdentifierExpressionTest, IsValid) { - IdentifierExpression i("ident"); + IdentifierExpression i(mod.RegisterSymbol("ident"), "ident"); EXPECT_TRUE(i.IsValid()); } -TEST_F(IdentifierExpressionTest, IsValid_BlankName) { - IdentifierExpression i(""); - EXPECT_FALSE(i.IsValid()); -} - TEST_F(IdentifierExpressionTest, ToStr) { - IdentifierExpression i("ident"); + IdentifierExpression i(mod.RegisterSymbol("ident"), "ident"); std::ostringstream out; i.to_str(out, 2); - EXPECT_EQ(out.str(), R"( Identifier[not set]{ident} + EXPECT_EQ(demangle(out.str()), R"( Identifier[not set]{ident} )"); } diff --git a/src/ast/if_statement_test.cc b/src/ast/if_statement_test.cc index e3117cded1..3314e9dbd2 100644 --- a/src/ast/if_statement_test.cc +++ b/src/ast/if_statement_test.cc @@ -25,7 +25,7 @@ namespace { using IfStatementTest = TestHelper; TEST_F(IfStatementTest, Creation) { - auto* cond = create("cond"); + auto* cond = create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); @@ -43,7 +43,7 @@ TEST_F(IfStatementTest, IsIf) { } TEST_F(IfStatementTest, IsValid) { - auto* cond = create("cond"); + auto* cond = create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); @@ -52,14 +52,15 @@ TEST_F(IfStatementTest, IsValid) { } TEST_F(IfStatementTest, IsValid_WithElseStatements) { - auto* cond = create("cond"); + auto* cond = create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); IfStatement stmt( Source{}, cond, body, { - create(create("Ident"), + create(create( + mod.RegisterSymbol("Ident"), "Ident"), create()), create(create()), }); @@ -75,7 +76,7 @@ TEST_F(IfStatementTest, IsValid_MissingCondition) { } TEST_F(IfStatementTest, IsValid_InvalidCondition) { - auto* cond = create(""); + auto* cond = create(mod.RegisterSymbol(""), ""); auto* body = create(); body->append(create()); @@ -84,7 +85,7 @@ TEST_F(IfStatementTest, IsValid_InvalidCondition) { } TEST_F(IfStatementTest, IsValid_NullBodyStatement) { - auto* cond = create("cond"); + auto* cond = create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); body->append(nullptr); @@ -94,7 +95,7 @@ TEST_F(IfStatementTest, IsValid_NullBodyStatement) { } TEST_F(IfStatementTest, IsValid_InvalidBodyStatement) { - auto* cond = create("cond"); + auto* cond = create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); body->append(create(Source{}, nullptr, create(), @@ -105,14 +106,15 @@ TEST_F(IfStatementTest, IsValid_InvalidBodyStatement) { } TEST_F(IfStatementTest, IsValid_NullElseStatement) { - auto* cond = create("cond"); + auto* cond = create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); IfStatement stmt( Source{}, cond, body, { - create(create("Ident"), + create(create( + mod.RegisterSymbol("Ident"), "Ident"), create()), create(create()), nullptr, @@ -121,20 +123,21 @@ TEST_F(IfStatementTest, IsValid_NullElseStatement) { } TEST_F(IfStatementTest, IsValid_InvalidElseStatement) { - auto* cond = create("cond"); + auto* cond = create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); IfStatement stmt(Source{}, cond, body, { - create(create(""), + create(create( + mod.RegisterSymbol(""), ""), create()), }); EXPECT_FALSE(stmt.IsValid()); } TEST_F(IfStatementTest, IsValid_MultipleElseWiththoutCondition) { - auto* cond = create("cond"); + auto* cond = create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); @@ -147,7 +150,7 @@ TEST_F(IfStatementTest, IsValid_MultipleElseWiththoutCondition) { } TEST_F(IfStatementTest, IsValid_ElseNotLast) { - auto* cond = create("cond"); + auto* cond = create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); @@ -155,14 +158,15 @@ TEST_F(IfStatementTest, IsValid_ElseNotLast) { Source{}, cond, body, { create(create()), - create(create("ident"), + create(create( + mod.RegisterSymbol("ident"), "ident"), create()), }); EXPECT_FALSE(stmt.IsValid()); } TEST_F(IfStatementTest, ToStr) { - auto* cond = create("cond"); + auto* cond = create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); @@ -170,7 +174,7 @@ TEST_F(IfStatementTest, ToStr) { std::ostringstream out; stmt.to_str(out, 2); - EXPECT_EQ(out.str(), R"( If{ + EXPECT_EQ(demangle(out.str()), R"( If{ ( Identifier[not set]{cond} ) @@ -182,7 +186,7 @@ TEST_F(IfStatementTest, ToStr) { } TEST_F(IfStatementTest, ToStr_WithElseStatements) { - auto* cond = create("cond"); + auto* cond = create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); @@ -193,16 +197,18 @@ TEST_F(IfStatementTest, ToStr_WithElseStatements) { else_body->append(create()); else_body->append(create()); - IfStatement stmt(Source{}, cond, body, - { - create( - create("ident"), else_if_body), - create(else_body), - }); + IfStatement stmt( + Source{}, cond, body, + { + create(create( + mod.RegisterSymbol("ident"), "ident"), + else_if_body), + create(else_body), + }); std::ostringstream out; stmt.to_str(out, 2); - EXPECT_EQ(out.str(), R"( If{ + EXPECT_EQ(demangle(out.str()), R"( If{ ( Identifier[not set]{cond} ) diff --git a/src/ast/member_accessor_expression_test.cc b/src/ast/member_accessor_expression_test.cc index d307b80c6e..3985ce13b0 100644 --- a/src/ast/member_accessor_expression_test.cc +++ b/src/ast/member_accessor_expression_test.cc @@ -26,8 +26,10 @@ namespace { using MemberAccessorExpressionTest = TestHelper; TEST_F(MemberAccessorExpressionTest, Creation) { - auto* str = create("structure"); - auto* mem = create("member"); + auto* str = create(mod.RegisterSymbol("structure"), + "structure"); + auto* mem = + create(mod.RegisterSymbol("member"), "member"); MemberAccessorExpression stmt(str, mem); EXPECT_EQ(stmt.structure(), str); @@ -35,8 +37,10 @@ TEST_F(MemberAccessorExpressionTest, Creation) { } TEST_F(MemberAccessorExpressionTest, Creation_WithSource) { - auto* str = create("structure"); - auto* mem = create("member"); + auto* str = create(mod.RegisterSymbol("structure"), + "structure"); + auto* mem = + create(mod.RegisterSymbol("member"), "member"); MemberAccessorExpression stmt(Source{Source::Location{20, 2}}, str, mem); auto src = stmt.source(); @@ -45,59 +49,69 @@ TEST_F(MemberAccessorExpressionTest, Creation_WithSource) { } TEST_F(MemberAccessorExpressionTest, IsMemberAccessor) { - auto* str = create("structure"); - auto* mem = create("member"); + auto* str = create(mod.RegisterSymbol("structure"), + "structure"); + auto* mem = + create(mod.RegisterSymbol("member"), "member"); MemberAccessorExpression stmt(str, mem); EXPECT_TRUE(stmt.Is()); } TEST_F(MemberAccessorExpressionTest, IsValid) { - auto* str = create("structure"); - auto* mem = create("member"); + auto* str = create(mod.RegisterSymbol("structure"), + "structure"); + auto* mem = + create(mod.RegisterSymbol("member"), "member"); MemberAccessorExpression stmt(str, mem); EXPECT_TRUE(stmt.IsValid()); } TEST_F(MemberAccessorExpressionTest, IsValid_NullStruct) { - auto* mem = create("member"); + auto* mem = + create(mod.RegisterSymbol("member"), "member"); MemberAccessorExpression stmt(nullptr, mem); EXPECT_FALSE(stmt.IsValid()); } TEST_F(MemberAccessorExpressionTest, IsValid_InvalidStruct) { - auto* str = create(""); - auto* mem = create("member"); + auto* str = create(mod.RegisterSymbol(""), ""); + auto* mem = + create(mod.RegisterSymbol("member"), "member"); MemberAccessorExpression stmt(str, mem); EXPECT_FALSE(stmt.IsValid()); } TEST_F(MemberAccessorExpressionTest, IsValid_NullMember) { - auto* str = create("structure"); + auto* str = create(mod.RegisterSymbol("structure"), + "structure"); MemberAccessorExpression stmt(str, nullptr); EXPECT_FALSE(stmt.IsValid()); } TEST_F(MemberAccessorExpressionTest, IsValid_InvalidMember) { - auto* str = create("structure"); - auto* mem = create(""); + auto* str = create(mod.RegisterSymbol("structure"), + "structure"); + auto* mem = create(mod.RegisterSymbol(""), ""); MemberAccessorExpression stmt(str, mem); EXPECT_FALSE(stmt.IsValid()); } TEST_F(MemberAccessorExpressionTest, ToStr) { - auto* str = create("structure"); - auto* mem = create("member"); + auto* str = create(mod.RegisterSymbol("structure"), + "structure"); + auto* mem = + create(mod.RegisterSymbol("member"), "member"); MemberAccessorExpression stmt(str, mem); std::ostringstream out; stmt.to_str(out, 2); - EXPECT_EQ(out.str(), R"( MemberAccessor[not set]{ + EXPECT_EQ(demangle(out.str()), R"( MemberAccessor[not set]{ Identifier[not set]{structure} Identifier[not set]{member} } diff --git a/src/ast/module.cc b/src/ast/module.cc index 2132e1f935..32dfbef5f5 100644 --- a/src/ast/module.cc +++ b/src/ast/module.cc @@ -38,6 +38,10 @@ Module Module::Clone() { } void Module::Clone(CloneContext* ctx) { + // Symbol table must be cloned first so that the resulting module has the + // symbols before we start the tree mutations. + ctx->mod->symbol_table_ = symbol_table_; + for (auto* ty : constructed_types_) { ctx->mod->constructed_types_.emplace_back(ctx->Clone(ty)); } @@ -47,8 +51,6 @@ void Module::Clone(CloneContext* ctx) { for (auto* func : functions_) { ctx->mod->functions_.emplace_back(ctx->Clone(func)); } - - ctx->mod->symbol_table_ = symbol_table_; } Function* Module::FindFunctionBySymbol(Symbol sym) const { diff --git a/src/ast/return_statement_test.cc b/src/ast/return_statement_test.cc index 8e9e5253ac..c7d46b0d17 100644 --- a/src/ast/return_statement_test.cc +++ b/src/ast/return_statement_test.cc @@ -26,7 +26,7 @@ namespace { using ReturnStatementTest = TestHelper; TEST_F(ReturnStatementTest, Creation) { - auto* expr = create("expr"); + auto* expr = create(mod.RegisterSymbol("expr"), "expr"); ReturnStatement r(Source{}, expr); EXPECT_EQ(r.value(), expr); @@ -50,7 +50,7 @@ TEST_F(ReturnStatementTest, HasValue_WithoutValue) { } TEST_F(ReturnStatementTest, HasValue_WithValue) { - auto* expr = create("expr"); + auto* expr = create(mod.RegisterSymbol("expr"), "expr"); ReturnStatement r(Source{}, expr); EXPECT_TRUE(r.has_value()); } @@ -61,23 +61,23 @@ TEST_F(ReturnStatementTest, IsValid_WithoutValue) { } TEST_F(ReturnStatementTest, IsValid_WithValue) { - auto* expr = create("expr"); + auto* expr = create(mod.RegisterSymbol("expr"), "expr"); ReturnStatement r(Source{}, expr); EXPECT_TRUE(r.IsValid()); } TEST_F(ReturnStatementTest, IsValid_InvalidValue) { - auto* expr = create(""); + auto* expr = create(mod.RegisterSymbol(""), ""); ReturnStatement r(Source{}, expr); EXPECT_FALSE(r.IsValid()); } TEST_F(ReturnStatementTest, ToStr_WithValue) { - auto* expr = create("expr"); + auto* expr = create(mod.RegisterSymbol("expr"), "expr"); ReturnStatement r(Source{}, expr); std::ostringstream out; r.to_str(out, 2); - EXPECT_EQ(out.str(), R"( Return{ + EXPECT_EQ(demangle(out.str()), R"( Return{ { Identifier[not set]{expr} } diff --git a/src/ast/switch_statement_test.cc b/src/ast/switch_statement_test.cc index df82f3d373..bd610faa6f 100644 --- a/src/ast/switch_statement_test.cc +++ b/src/ast/switch_statement_test.cc @@ -34,7 +34,8 @@ TEST_F(SwitchStatementTest, Creation) { CaseSelectorList lit; lit.push_back(create(&i32, 1)); - auto* ident = create("ident"); + auto* ident = + create(mod.RegisterSymbol("ident"), "ident"); CaseStatementList body; auto* case_stmt = create(lit, create()); body.push_back(case_stmt); @@ -46,7 +47,8 @@ TEST_F(SwitchStatementTest, Creation) { } TEST_F(SwitchStatementTest, Creation_WithSource) { - auto* ident = create("ident"); + auto* ident = + create(mod.RegisterSymbol("ident"), "ident"); SwitchStatement stmt(Source{Source::Location{20, 2}}, ident, CaseStatementList()); @@ -61,7 +63,8 @@ TEST_F(SwitchStatementTest, IsSwitch) { CaseSelectorList lit; lit.push_back(create(&i32, 2)); - auto* ident = create("ident"); + auto* ident = + create(mod.RegisterSymbol("ident"), "ident"); CaseStatementList body; body.push_back(create(lit, create())); @@ -75,7 +78,8 @@ TEST_F(SwitchStatementTest, IsValid) { CaseSelectorList lit; lit.push_back(create(&i32, 2)); - auto* ident = create("ident"); + auto* ident = + create(mod.RegisterSymbol("ident"), "ident"); CaseStatementList body; body.push_back(create(lit, create())); @@ -102,7 +106,7 @@ TEST_F(SwitchStatementTest, IsValid_Invalid_Condition) { CaseSelectorList lit; lit.push_back(create(&i32, 2)); - auto* ident = create(""); + auto* ident = create(mod.RegisterSymbol(""), ""); CaseStatementList body; body.push_back(create(lit, create())); @@ -116,7 +120,8 @@ TEST_F(SwitchStatementTest, IsValid_Null_BodyStatement) { CaseSelectorList lit; lit.push_back(create(&i32, 2)); - auto* ident = create("ident"); + auto* ident = + create(mod.RegisterSymbol("ident"), "ident"); CaseStatementList body; body.push_back(create(lit, create())); body.push_back(nullptr); @@ -126,7 +131,8 @@ TEST_F(SwitchStatementTest, IsValid_Null_BodyStatement) { } TEST_F(SwitchStatementTest, IsValid_Invalid_BodyStatement) { - auto* ident = create("ident"); + auto* ident = + create(mod.RegisterSymbol("ident"), "ident"); auto* case_body = create(); case_body->append(nullptr); @@ -139,12 +145,13 @@ TEST_F(SwitchStatementTest, IsValid_Invalid_BodyStatement) { } TEST_F(SwitchStatementTest, ToStr_Empty) { - auto* ident = create("ident"); + auto* ident = + create(mod.RegisterSymbol("ident"), "ident"); SwitchStatement stmt(ident, {}); std::ostringstream out; stmt.to_str(out, 2); - EXPECT_EQ(out.str(), R"( Switch{ + EXPECT_EQ(demangle(out.str()), R"( Switch{ Identifier[not set]{ident} { } @@ -158,14 +165,15 @@ TEST_F(SwitchStatementTest, ToStr) { CaseSelectorList lit; lit.push_back(create(&i32, 2)); - auto* ident = create("ident"); + auto* ident = + create(mod.RegisterSymbol("ident"), "ident"); CaseStatementList body; body.push_back(create(lit, create())); SwitchStatement stmt(ident, body); std::ostringstream out; stmt.to_str(out, 2); - EXPECT_EQ(out.str(), R"( Switch{ + EXPECT_EQ(demangle(out.str()), R"( Switch{ Identifier[not set]{ident} { Case 2{ diff --git a/src/ast/type_constructor_expression_test.cc b/src/ast/type_constructor_expression_test.cc index d7efed7e5c..3fbf937f20 100644 --- a/src/ast/type_constructor_expression_test.cc +++ b/src/ast/type_constructor_expression_test.cc @@ -32,7 +32,8 @@ using TypeConstructorExpressionTest = TestHelper; TEST_F(TypeConstructorExpressionTest, Creation) { type::F32 f32; ExpressionList expr; - expr.push_back(create("expr")); + expr.push_back( + create(mod.RegisterSymbol("expr"), "expr")); TypeConstructorExpression t(&f32, expr); EXPECT_EQ(t.type(), &f32); @@ -43,7 +44,8 @@ TEST_F(TypeConstructorExpressionTest, Creation) { TEST_F(TypeConstructorExpressionTest, Creation_WithSource) { type::F32 f32; ExpressionList expr; - expr.push_back(create("expr")); + expr.push_back( + create(mod.RegisterSymbol("expr"), "expr")); TypeConstructorExpression t(Source{Source::Location{20, 2}}, &f32, expr); auto src = t.source(); @@ -54,7 +56,8 @@ TEST_F(TypeConstructorExpressionTest, Creation_WithSource) { TEST_F(TypeConstructorExpressionTest, IsTypeConstructor) { type::F32 f32; ExpressionList expr; - expr.push_back(create("expr")); + expr.push_back( + create(mod.RegisterSymbol("expr"), "expr")); TypeConstructorExpression t(&f32, expr); EXPECT_TRUE(t.Is()); @@ -63,7 +66,8 @@ TEST_F(TypeConstructorExpressionTest, IsTypeConstructor) { TEST_F(TypeConstructorExpressionTest, IsValid) { type::F32 f32; ExpressionList expr; - expr.push_back(create("expr")); + expr.push_back( + create(mod.RegisterSymbol("expr"), "expr")); TypeConstructorExpression t(&f32, expr); EXPECT_TRUE(t.IsValid()); @@ -79,7 +83,8 @@ TEST_F(TypeConstructorExpressionTest, IsValid_EmptyValue) { TEST_F(TypeConstructorExpressionTest, IsValid_NullType) { ExpressionList expr; - expr.push_back(create("expr")); + expr.push_back( + create(mod.RegisterSymbol("expr"), "expr")); TypeConstructorExpression t(nullptr, expr); EXPECT_FALSE(t.IsValid()); @@ -88,7 +93,8 @@ TEST_F(TypeConstructorExpressionTest, IsValid_NullType) { TEST_F(TypeConstructorExpressionTest, IsValid_NullValue) { type::F32 f32; ExpressionList expr; - expr.push_back(create("expr")); + expr.push_back( + create(mod.RegisterSymbol("expr"), "expr")); expr.push_back(nullptr); TypeConstructorExpression t(&f32, expr); @@ -98,7 +104,7 @@ TEST_F(TypeConstructorExpressionTest, IsValid_NullValue) { TEST_F(TypeConstructorExpressionTest, IsValid_InvalidValue) { type::F32 f32; ExpressionList expr; - expr.push_back(create("")); + expr.push_back(create(mod.RegisterSymbol(""), "")); TypeConstructorExpression t(&f32, expr); EXPECT_FALSE(t.IsValid()); @@ -108,14 +114,17 @@ TEST_F(TypeConstructorExpressionTest, ToStr) { type::F32 f32; type::Vector vec(&f32, 3); ExpressionList expr; - expr.push_back(create("expr_1")); - expr.push_back(create("expr_2")); - expr.push_back(create("expr_3")); + expr.push_back( + create(mod.RegisterSymbol("expr_1"), "expr_1")); + expr.push_back( + create(mod.RegisterSymbol("expr_2"), "expr_2")); + expr.push_back( + create(mod.RegisterSymbol("expr_3"), "expr_3")); TypeConstructorExpression t(&vec, expr); std::ostringstream out; t.to_str(out, 2); - EXPECT_EQ(out.str(), R"( TypeConstructor[not set]{ + EXPECT_EQ(demangle(out.str()), R"( TypeConstructor[not set]{ __vec_3__f32 Identifier[not set]{expr_1} Identifier[not set]{expr_2} diff --git a/src/ast/unary_op_expression_test.cc b/src/ast/unary_op_expression_test.cc index 5e3ec1f349..532d8cbd63 100644 --- a/src/ast/unary_op_expression_test.cc +++ b/src/ast/unary_op_expression_test.cc @@ -26,7 +26,8 @@ namespace { using UnaryOpExpressionTest = TestHelper; TEST_F(UnaryOpExpressionTest, Creation) { - auto* ident = create("ident"); + auto* ident = + create(mod.RegisterSymbol("ident"), "ident"); UnaryOpExpression u(UnaryOp::kNot, ident); EXPECT_EQ(u.op(), UnaryOp::kNot); @@ -34,7 +35,8 @@ TEST_F(UnaryOpExpressionTest, Creation) { } TEST_F(UnaryOpExpressionTest, Creation_WithSource) { - auto* ident = create("ident"); + auto* ident = + create(mod.RegisterSymbol("ident"), "ident"); UnaryOpExpression u(Source{Source::Location{20, 2}}, UnaryOp::kNot, ident); auto src = u.source(); EXPECT_EQ(src.range.begin.line, 20u); @@ -42,13 +44,15 @@ TEST_F(UnaryOpExpressionTest, Creation_WithSource) { } TEST_F(UnaryOpExpressionTest, IsUnaryOp) { - auto* ident = create("ident"); + auto* ident = + create(mod.RegisterSymbol("ident"), "ident"); UnaryOpExpression u(UnaryOp::kNot, ident); EXPECT_TRUE(u.Is()); } TEST_F(UnaryOpExpressionTest, IsValid) { - auto* ident = create("ident"); + auto* ident = + create(mod.RegisterSymbol("ident"), "ident"); UnaryOpExpression u(UnaryOp::kNot, ident); EXPECT_TRUE(u.IsValid()); } @@ -59,17 +63,18 @@ TEST_F(UnaryOpExpressionTest, IsValid_NullExpression) { } TEST_F(UnaryOpExpressionTest, IsValid_InvalidExpression) { - auto* ident = create(""); + auto* ident = create(mod.RegisterSymbol(""), ""); UnaryOpExpression u(UnaryOp::kNot, ident); EXPECT_FALSE(u.IsValid()); } TEST_F(UnaryOpExpressionTest, ToStr) { - auto* ident = create("ident"); + auto* ident = + create(mod.RegisterSymbol("ident"), "ident"); UnaryOpExpression u(UnaryOp::kNot, ident); std::ostringstream out; u.to_str(out, 2); - EXPECT_EQ(out.str(), R"( UnaryOp[not set]{ + EXPECT_EQ(demangle(out.str()), R"( UnaryOp[not set]{ not Identifier[not set]{ident} } diff --git a/src/ast/variable_test.cc b/src/ast/variable_test.cc index 54658831a4..ac95d69cc9 100644 --- a/src/ast/variable_test.cc +++ b/src/ast/variable_test.cc @@ -84,7 +84,7 @@ TEST_F(VariableTest, IsValid_WithConstructor) { StorageClass::kNone, &t, false, - create("ident"), + create(mod.RegisterSymbol("ident"), "ident"), ast::VariableDecorationList{}}; EXPECT_TRUE(v.IsValid()); } @@ -115,7 +115,7 @@ TEST_F(VariableTest, IsValid_InvalidConstructor) { StorageClass::kNone, &t, false, - create(""), + create(mod.RegisterSymbol(""), ""), ast::VariableDecorationList{}}; EXPECT_FALSE(v.IsValid()); } @@ -162,16 +162,17 @@ TEST_F(VariableTest, ConstantId) { TEST_F(VariableTest, Decorated_to_str) { type::F32 t; - auto* var = create(Source{}, "my_var", StorageClass::kFunction, &t, - false, create("expr"), - VariableDecorationList{ - create(2, Source{}), - create(1, Source{}), - }); + auto* var = create( + Source{}, "my_var", StorageClass::kFunction, &t, false, + create(mod.RegisterSymbol("expr"), "expr"), + VariableDecorationList{ + create(2, Source{}), + create(1, Source{}), + }); std::ostringstream out; var->to_str(out, 2); - EXPECT_EQ(out.str(), R"( Variable{ + EXPECT_EQ(demangle(out.str()), R"( Variable{ Decorations{ BindingDecoration{2} SetDecoration{1} diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index fbf24e5dcc..5a406238b4 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -98,7 +98,8 @@ class InspectorHelper { std::string callee, ast::FunctionDecorationList decorations = {}) { auto* body = create(); - auto* ident_expr = create(callee); + auto* ident_expr = create( + mod()->RegisterSymbol(callee), callee); auto* call_expr = create(ident_expr, ast::ExpressionList()); body->append(create(call_expr)); @@ -152,8 +153,8 @@ class InspectorHelper { std::string in, out; std::tie(in, out) = inout; body->append(create( - create(out), - create(in))); + create(mod()->RegisterSymbol(out), out), + create(mod()->RegisterSymbol(in), in))); } body->append(create(Source{})); return create(Source{}, mod()->RegisterSymbol(name), name, @@ -179,10 +180,11 @@ class InspectorHelper { std::string in, out; std::tie(in, out) = inout; body->append(create( - create(out), - create(in))); + create(mod()->RegisterSymbol(out), out), + create(mod()->RegisterSymbol(in), in))); } - auto* ident_expr = create(callee); + auto* ident_expr = create( + mod()->RegisterSymbol(callee), callee); auto* call_expr = create(ident_expr, ast::ExpressionList()); body->append(create(call_expr)); @@ -442,10 +444,14 @@ class InspectorHelper { std::tie(member_idx, member_type) = member; std::string member_name = StructMemberName(member_idx, member_type); body->append(create( - create("local" + member_name), + create( + mod()->RegisterSymbol("local" + member_name), + "local" + member_name), create( - create(struct_name), - create(member_name)))); + create( + mod()->RegisterSymbol(struct_name), struct_name), + create( + mod()->RegisterSymbol(member_name), member_name)))); } body->append(create(Source{})); @@ -581,14 +587,21 @@ class InspectorHelper { body->append(create(call_result)); ast::ExpressionList call_params; - call_params.push_back(create(texture_name)); - call_params.push_back(create(sampler_name)); - call_params.push_back(create(coords_name)); + call_params.push_back(create( + mod()->RegisterSymbol(texture_name), texture_name)); + call_params.push_back(create( + mod()->RegisterSymbol(sampler_name), sampler_name)); + call_params.push_back(create( + mod()->RegisterSymbol(coords_name), coords_name)); auto* call_expr = create( - create("textureSample"), call_params); + create( + mod()->RegisterSymbol("textureSample"), "textureSample"), + call_params); body->append(create( - create("sampler_result"), call_expr)); + create( + mod()->RegisterSymbol("sampler_result"), "sampler_result"), + call_expr)); body->append(create(Source{})); return create(Source{}, mod()->RegisterSymbol(func_name), @@ -628,15 +641,23 @@ class InspectorHelper { body->append(create(call_result)); ast::ExpressionList call_params; - call_params.push_back(create(texture_name)); - call_params.push_back(create(sampler_name)); - call_params.push_back(create(coords_name)); - call_params.push_back(create(array_index)); + call_params.push_back(create( + mod()->RegisterSymbol(texture_name), texture_name)); + call_params.push_back(create( + mod()->RegisterSymbol(sampler_name), sampler_name)); + call_params.push_back(create( + mod()->RegisterSymbol(coords_name), coords_name)); + call_params.push_back(create( + mod()->RegisterSymbol(array_index), array_index)); auto* call_expr = create( - create("textureSample"), call_params); + create( + mod()->RegisterSymbol("textureSample"), "textureSample"), + call_params); body->append(create( - create("sampler_result"), call_expr)); + create( + mod()->RegisterSymbol("sampler_result"), "sampler_result"), + call_expr)); body->append(create(Source{})); return create(Source{}, mod()->RegisterSymbol(func_name), @@ -677,15 +698,24 @@ class InspectorHelper { body->append(create(call_result)); ast::ExpressionList call_params; - call_params.push_back(create(texture_name)); - call_params.push_back(create(sampler_name)); - call_params.push_back(create(coords_name)); - call_params.push_back(create(depth_name)); + call_params.push_back(create( + mod()->RegisterSymbol(texture_name), texture_name)); + call_params.push_back(create( + mod()->RegisterSymbol(sampler_name), sampler_name)); + call_params.push_back(create( + mod()->RegisterSymbol(coords_name), coords_name)); + call_params.push_back(create( + mod()->RegisterSymbol(depth_name), depth_name)); auto* call_expr = create( - create("textureSampleCompare"), call_params); + create( + mod()->RegisterSymbol("textureSampleCompare"), + "textureSampleCompare"), + call_params); body->append(create( - create("sampler_result"), call_expr)); + create( + mod()->RegisterSymbol("sampler_result"), "sampler_result"), + call_expr)); body->append(create(Source{})); return create(Source{}, mod()->RegisterSymbol(func_name), @@ -1507,7 +1537,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) { AddReferenceFunc("ub_baz_func", "ub_baz"); auto AddFuncCall = [&](ast::BlockStatement* body, const std::string& callee) { - auto* ident_expr = create(callee); + auto* ident_expr = create( + mod()->RegisterSymbol(callee), callee); auto* call_expr = create(ident_expr, ast::ExpressionList()); body->append(create(call_expr)); @@ -1654,7 +1685,8 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) { AddReferenceFunc("sb_baz_func", "sb_baz"); auto AddFuncCall = [&](ast::BlockStatement* body, const std::string& callee) { - auto* ident_expr = create(callee); + auto* ident_expr = create( + mod()->RegisterSymbol(callee), callee); auto* call_expr = create(ident_expr, ast::ExpressionList()); body->append(create(call_expr)); @@ -1828,7 +1860,8 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, AddReferenceFunc("sb_baz_func", "sb_baz"); auto AddFuncCall = [&](ast::BlockStatement* body, const std::string& callee) { - auto* ident_expr = create(callee); + auto* ident_expr = create( + mod()->RegisterSymbol(callee), callee); auto* call_expr = create(ident_expr, ast::ExpressionList()); body->append(create(call_expr)); diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index eddd2ad570..08a1c6d994 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -689,7 +689,8 @@ void FunctionEmitter::PushGuard(const std::string& guard_name, // as the statement block at the top of the stack. const auto& top = statements_stack_.back(); - auto* cond = create(guard_name); + auto* cond = create( + ast_module_.RegisterSymbol(guard_name), guard_name); auto* body = create(); AddStatement( create(Source{}, cond, body, ast::ElseStatementList{})); @@ -1891,9 +1892,11 @@ TypedExpression FunctionEmitter::MakeExpression(uint32_t id) { return {}; } if (identifier_values_.count(id) || parser_impl_.IsScalarSpecConstant(id)) { + auto name = namer_.Name(id); return TypedExpression{ parser_impl_.ConvertType(def_use_mgr_->GetDef(id)->type_id()), - create(namer_.Name(id))}; + create(ast_module_.RegisterSymbol(name), + name)}; } if (singly_used_values_.count(id)) { auto expr = std::move(singly_used_values_[id]); @@ -1910,11 +1913,13 @@ TypedExpression FunctionEmitter::MakeExpression(uint32_t id) { return {}; } switch (inst->opcode()) { - case SpvOpVariable: + case SpvOpVariable: { // This occurs for module-scope variables. - return TypedExpression{ - parser_impl_.ConvertType(inst->type_id()), - create(namer_.Name(inst->result_id()))}; + auto name = namer_.Name(inst->result_id()); + return TypedExpression{parser_impl_.ConvertType(inst->type_id()), + create( + ast_module_.RegisterSymbol(name), name)}; + } default: break; } @@ -2579,7 +2584,9 @@ ast::Statement* FunctionEmitter::MakeBranchDetailed( } // Signal an exit from the branch. return create( - create(flow_guard), MakeFalse()); + create( + ast_module_.RegisterSymbol(flow_guard), flow_guard), + MakeFalse()); } // For an unconditional branch, the break out to an if-selection @@ -2733,7 +2740,9 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info, const auto var_name = GetDefInfo(assignment.phi_id)->phi_var; auto expr = MakeExpression(assignment.value); AddStatement(create( - create(var_name), expr.expr)); + create( + ast_module_.RegisterSymbol(var_name), var_name), + expr.expr)); } } @@ -2766,12 +2775,13 @@ bool FunctionEmitter::EmitConstDefOrWriteToHoistedVar( const auto result_id = inst.result_id(); const auto* def_info = GetDefInfo(result_id); if (def_info && def_info->requires_hoisted_def) { + auto name = namer_.Name(result_id); // Emit an assignment of the expression to the hoisted variable. - AddStatementForInstruction( - create( - create(namer_.Name(result_id)), - ast_expr.expr), - inst); + AddStatementForInstruction(create( + create( + ast_module_.RegisterSymbol(name), name), + ast_expr.expr), + inst); return true; } return EmitConstDefinition(inst, ast_expr); @@ -2861,9 +2871,10 @@ bool FunctionEmitter::EmitStatement(const spvtools::opt::Instruction& inst) { } case SpvOpPhi: { // Emit a read from the associated state variable. - TypedExpression expr{ - parser_impl_.ConvertType(inst.type_id()), - create(def_info->phi_var)}; + TypedExpression expr{parser_impl_.ConvertType(inst.type_id()), + create( + ast_module_.RegisterSymbol(def_info->phi_var), + def_info->phi_var)}; return EmitConstDefOrWriteToHoistedVar(inst, expr); } case SpvOpFunctionCall: @@ -2916,7 +2927,9 @@ TypedExpression FunctionEmitter::MaybeEmitCombinatorialValue( ast::ExpressionList params; params.emplace_back(MakeOperand(inst, 0).expr); return {ast_type, create( - create(unary_builtin_name), + create( + ast_module_.RegisterSymbol(unary_builtin_name), + unary_builtin_name), std::move(params))}; } @@ -3017,7 +3030,8 @@ TypedExpression FunctionEmitter::EmitGlslStd450ExtInst( return {}; } - auto* func = create(name); + auto* func = + create(ast_module_.RegisterSymbol(name), name); ast::ExpressionList operands; ast::type::Type* first_operand_type = nullptr; // All parameters to GLSL.std.450 extended instructions are IDs. @@ -3042,17 +3056,21 @@ ast::IdentifierExpression* FunctionEmitter::Swizzle(uint32_t i) { return nullptr; } const char* names[] = {"x", "y", "z", "w"}; - return create(names[i & 3]); + return create( + ast_module_.RegisterSymbol(names[i & 3]), names[i & 3]); } ast::IdentifierExpression* FunctionEmitter::PrefixSwizzle(uint32_t n) { switch (n) { case 1: - return create("x"); + return create(ast_module_.RegisterSymbol("x"), + "x"); case 2: - return create("xy"); + return create(ast_module_.RegisterSymbol("xy"), + "xy"); case 3: - return create("xyz"); + return create( + ast_module_.RegisterSymbol("xyz"), "xyz"); default: break; } @@ -3121,8 +3139,10 @@ TypedExpression FunctionEmitter::MakeAccessChain( first_index = first_index + 1; // Replace the gl_PerVertex reference with the gl_Position reference ptr_ty_id = builtin_position_info.member_pointer_type_id; - current_expr.expr = - create(namer_.Name(base_id)); + + auto name = namer_.Name(base_id); + current_expr.expr = create( + ast_module_.RegisterSymbol(name), name); current_expr.type = parser_impl_.ConvertType(ptr_ty_id); } } @@ -3212,8 +3232,10 @@ TypedExpression FunctionEmitter::MakeAccessChain( << pointee_type_id << " having " << num_members << " members"; return {}; } + auto name = + namer_.GetMemberName(pointee_type_id, uint32_t(index_const_val)); auto* member_access = create( - namer_.GetMemberName(pointee_type_id, uint32_t(index_const_val))); + ast_module_.RegisterSymbol(name), name); next_expr = create(current_expr.expr, member_access); @@ -3331,8 +3353,9 @@ TypedExpression FunctionEmitter::MakeCompositeExtract( << current_type_id << " having " << num_members << " members"; return {}; } + auto name = namer_.GetMemberName(current_type_id, uint32_t(index_val)); auto* member_access = create( - namer_.GetMemberName(current_type_id, uint32_t(index_val))); + ast_module_.RegisterSymbol(name), name); next_expr = create(current_expr.expr, member_access); @@ -3712,8 +3735,9 @@ TypedExpression FunctionEmitter::MakeNumericConversion( bool FunctionEmitter::EmitFunctionCall(const spvtools::opt::Instruction& inst) { // We ignore function attributes such as Inline, DontInline, Pure, Const. - auto* function = create( - namer_.Name(inst.GetSingleWordInOperand(0))); + auto name = namer_.Name(inst.GetSingleWordInOperand(0)); + auto* function = + create(ast_module_.RegisterSymbol(name), name); ast::ExpressionList params; for (uint32_t iarg = 1; iarg < inst.NumInOperands(); ++iarg) { @@ -3739,7 +3763,9 @@ TypedExpression FunctionEmitter::MakeIntrinsicCall( const auto intrinsic = GetIntrinsic(inst.opcode()); std::ostringstream ss; ss << intrinsic; - auto* ident = create(ss.str()); + auto name = ss.str(); + auto* ident = + create(ast_module_.RegisterSymbol(name), name); ident->set_intrinsic(intrinsic); ast::ExpressionList params; @@ -3781,9 +3807,11 @@ TypedExpression FunctionEmitter::MakeSimpleSelect( params.push_back(operand2.expr); // The condition goes last. params.push_back(condition.expr); - return {operand1.type, create( - create("select"), - std::move(params))}; + return {operand1.type, + create( + create( + ast_module_.RegisterSymbol("select"), "select"), + std::move(params))}; } return {}; } @@ -3813,8 +3841,9 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) { return Fail() << "internal error: couldn't find image for " << inst.PrettyPrint(); } - params.push_back( - create(namer_.Name(image->result_id()))); + auto name = namer_.Name(image->result_id()); + params.push_back(create( + ast_module_.RegisterSymbol(name), name)); if (IsSampledImageAccess(inst.opcode())) { // Form the sampler operand. @@ -3824,8 +3853,9 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) { return Fail() << "internal error: couldn't find sampler for " << inst.PrettyPrint(); } - params.push_back( - create(namer_.Name(sampler->result_id()))); + auto param_name = namer_.Name(sampler->result_id()); + params.push_back(create( + ast_module_.RegisterSymbol(param_name), param_name)); } ast::type::Pointer* texture_ptr_type = @@ -3964,7 +3994,8 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) { << "): " << inst.PrettyPrint(); } - auto* ident = create(builtin_name); + auto* ident = create( + ast_module_.RegisterSymbol(builtin_name), builtin_name); auto* call_expr = create(ident, std::move(params)); if (inst.type_id() != 0) { diff --git a/src/reader/spirv/function_arithmetic_test.cc b/src/reader/spirv/function_arithmetic_test.cc index 415e0b17a8..b474a27409 100644 --- a/src/reader/spirv/function_arithmetic_test.cc +++ b/src/reader/spirv/function_arithmetic_test.cc @@ -135,7 +135,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -147,7 +147,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Int) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) { @@ -162,7 +162,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -176,7 +176,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Int_Uint) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) { @@ -191,7 +191,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -205,7 +205,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Int) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) { @@ -220,7 +220,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -236,7 +236,7 @@ TEST_F(SpvUnaryArithTest, SNegate_Uint_Uint) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) { @@ -251,7 +251,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -267,7 +267,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_SignedVec) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) { @@ -282,7 +282,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -300,7 +300,7 @@ TEST_F(SpvUnaryArithTest, SNegate_SignedVec_UnsignedVec) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) { @@ -315,7 +315,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -333,7 +333,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_SignedVec) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) { @@ -348,7 +348,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -368,7 +368,7 @@ TEST_F(SpvUnaryArithTest, SNegate_UnsignedVec_UnsignedVec) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, FNegate_Scalar) { @@ -383,7 +383,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -395,7 +395,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryArithTest, FNegate_Vector) { @@ -410,7 +410,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -426,7 +426,7 @@ TEST_F(SpvUnaryArithTest, FNegate_Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } struct BinaryData { @@ -474,7 +474,8 @@ TEST_P(SpvBinaryArithTest, EmitExpression) { << GetParam().ast_type << "\n {\n Binary[not set]{" << "\n " << GetParam().ast_lhs << "\n " << GetParam().ast_op << "\n " << GetParam().ast_rhs; - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(ss.str())) << assembly; + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(ss.str())) + << assembly; } INSTANTIATE_TEST_SUITE_P( @@ -696,7 +697,7 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Scalar_UnsignedResult) { << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -731,7 +732,7 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Vector_UnsignedResult) { << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -754,7 +755,7 @@ TEST_F(SpvBinaryArithTestBasic, SDiv_Vector_UnsignedResult) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } INSTANTIATE_TEST_SUITE_P( @@ -842,7 +843,7 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Scalar_UnsignedResult) { << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -877,7 +878,7 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Vector_UnsignedResult) { << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -900,7 +901,7 @@ TEST_F(SpvBinaryArithTestBasic, SMod_Vector_UnsignedResult) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } INSTANTIATE_TEST_SUITE_P( @@ -930,7 +931,8 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesScalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_10 none __vec_2__f32 @@ -942,7 +944,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesScalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) { @@ -959,7 +961,8 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_10 none __mat_2_2__f32 @@ -971,7 +974,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesScalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) { @@ -988,7 +991,8 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_10 none __mat_2_2__f32 @@ -1000,7 +1004,7 @@ TEST_F(SpvBinaryArithTestBasic, VectorTimesMatrix) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) { @@ -1017,7 +1021,8 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_10 none __mat_2_2__f32 @@ -1029,7 +1034,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesVector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) { @@ -1046,7 +1051,8 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_10 none __mat_2_2__f32 @@ -1058,7 +1064,7 @@ TEST_F(SpvBinaryArithTestBasic, MatrixTimesMatrix) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvBinaryArithTestBasic, Dot) { @@ -1075,7 +1081,8 @@ TEST_F(SpvBinaryArithTestBasic, Dot) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_3 none __f32 @@ -1089,7 +1096,7 @@ TEST_F(SpvBinaryArithTestBasic, Dot) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvBinaryArithTestBasic, OuterProduct) { @@ -1106,7 +1113,8 @@ TEST_F(SpvBinaryArithTestBasic, OuterProduct) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_3 none __mat_2_2__f32 @@ -1120,7 +1128,7 @@ TEST_F(SpvBinaryArithTestBasic, OuterProduct) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } // TODO(dneto): OpSRem. Missing from WGSL diff --git a/src/reader/spirv/function_bit_test.cc b/src/reader/spirv/function_bit_test.cc index 3ed4f4e067..3565456607 100644 --- a/src/reader/spirv/function_bit_test.cc +++ b/src/reader/spirv/function_bit_test.cc @@ -163,7 +163,8 @@ TEST_P(SpvBinaryBitTest, EmitExpression) { << GetParam().ast_type << "\n {\n Binary[not set]{" << "\n " << GetParam().ast_lhs << "\n " << GetParam().ast_op << "\n " << GetParam().ast_rhs; - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(ss.str())) << assembly; + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(ss.str())) + << assembly; } INSTANTIATE_TEST_SUITE_P( @@ -400,7 +401,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -412,7 +413,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Int) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryBitTest, Not_Int_Uint) { @@ -427,7 +428,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -441,7 +442,7 @@ TEST_F(SpvUnaryBitTest, Not_Int_Uint) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryBitTest, Not_Uint_Int) { @@ -456,7 +457,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -470,7 +471,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Int) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryBitTest, Not_Uint_Uint) { @@ -485,7 +486,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -497,7 +498,7 @@ TEST_F(SpvUnaryBitTest, Not_Uint_Uint) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) { @@ -512,7 +513,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -528,7 +529,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_SignedVec) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) { @@ -543,7 +544,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -561,7 +562,7 @@ TEST_F(SpvUnaryBitTest, Not_SignedVec_UnsignedVec) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) { @@ -576,7 +577,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -594,7 +595,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_SignedVec) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) { const auto assembly = CommonTypes() + R"( @@ -608,7 +609,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -624,7 +625,7 @@ TEST_F(SpvUnaryBitTest, Not_UnsignedVec_UnsignedVec) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } std::string BitTestPreamble() { @@ -663,7 +664,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Uint_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -691,7 +692,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Uint_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -721,7 +722,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Int_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -751,7 +752,7 @@ TEST_F(SpvUnaryBitTest, BitCount_Int_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -779,7 +780,7 @@ TEST_F(SpvUnaryBitTest, BitCount_UintVector_UintVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -807,7 +808,7 @@ TEST_F(SpvUnaryBitTest, BitCount_UintVector_IntVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -837,7 +838,7 @@ TEST_F(SpvUnaryBitTest, BitCount_IntVector_UintVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -867,7 +868,7 @@ TEST_F(SpvUnaryBitTest, BitCount_IntVector_IntVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -895,7 +896,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Uint_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -923,7 +924,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Uint_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -953,7 +954,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Int_Uint) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -983,7 +984,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_Int_Int) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1011,7 +1012,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_UintVector_UintVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1039,7 +1040,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_UintVector_IntVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1069,7 +1070,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_IntVector_UintVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1099,7 +1100,7 @@ TEST_F(SpvUnaryBitTest, BitReverse_IntVector_IntVector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - const auto body = ToString(fe.ast_body()); + const auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 diff --git a/src/reader/spirv/function_call_test.cc b/src/reader/spirv/function_call_test.cc index fabf8191f7..ce9525a3a1 100644 --- a/src/reader/spirv/function_call_test.cc +++ b/src/reader/spirv/function_call_test.cc @@ -48,18 +48,16 @@ TEST_F(SpvParserTest, EmitStatement_VoidCallNoParams) { ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error(); const auto module_ast_str = p->get_module().to_str(); EXPECT_THAT(module_ast_str, Eq(R"(Module{ - Function )" + p->get_module().GetSymbol("x_50").to_str() + - R"( -> __void + Function tint_symbol_1 -> __void () { Return{} } - Function )" + p->get_module().GetSymbol("x_100").to_str() + - R"( -> __void + Function tint_symbol_2 -> __void () { Call[not set]{ - Identifier[not set]{x_50} + Identifier[not set]{tint_symbol_1} ( ) } @@ -92,7 +90,8 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParams) { { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -107,17 +106,17 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParams) { } } Return{})")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 50)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Return{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Return{ { ScalarConstructor[not set]{42} } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } } @@ -148,7 +147,8 @@ TEST_F(SpvParserTest, EmitStatement_ScalarCallNoParamsUsedTwice) { { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ Variable{ x_10 function @@ -178,16 +178,16 @@ Assignment{ Identifier[not set]{x_1} } Return{})")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 50)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Return{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Return{ { ScalarConstructor[not set]{42} } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } } @@ -218,8 +218,7 @@ TEST_F(SpvParserTest, EmitStatement_CallWithParams) { EXPECT_TRUE(p->error().empty()); const auto module_ast_str = p->get_module().to_str(); EXPECT_THAT(module_ast_str, HasSubstr(R"(Module{ - Function )" + p->get_module().GetSymbol("x_50").to_str() + - R"( -> __u32 + Function tint_symbol_3 -> __u32 ( VariableConst{ x_51 @@ -236,9 +235,9 @@ TEST_F(SpvParserTest, EmitStatement_CallWithParams) { Return{ { Binary[not set]{ - Identifier[not set]{x_51} + Identifier[not set]{tint_symbol_1} add - Identifier[not set]{x_52} + Identifier[not set]{tint_symbol_2} } } } @@ -254,7 +253,7 @@ TEST_F(SpvParserTest, EmitStatement_CallWithParams) { __u32 { Call[not set]{ - Identifier[not set]{x_50} + Identifier[not set]{tint_symbol_3} ( ScalarConstructor[not set]{42} ScalarConstructor[not set]{84} diff --git a/src/reader/spirv/function_cfg_test.cc b/src/reader/spirv/function_cfg_test.cc index c94abd78c0..cc5bdf977a 100644 --- a/src/reader/spirv/function_cfg_test.cc +++ b/src/reader/spirv/function_cfg_test.cc @@ -7361,7 +7361,7 @@ TEST_F(SpvParserTest, EmitBody_IfBreak_FromThen_ForwardWithinThen) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -7473,7 +7473,7 @@ TEST_F(SpvParserTest, EmitBody_IfBreak_FromElse_ForwardWithinElse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -7600,7 +7600,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error() << assembly; - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -7791,7 +7791,7 @@ TEST_F(SpvParserTest, EmitBody_If_Empty) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{false} @@ -7827,7 +7827,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_NoElse) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -7875,7 +7875,7 @@ TEST_F(SpvParserTest, EmitBody_If_NoThen_Else) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -7931,7 +7931,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_Else) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -7998,7 +7998,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_Else_Premerge) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8070,7 +8070,7 @@ TEST_F(SpvParserTest, EmitBody_If_Then_Premerge) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8134,7 +8134,7 @@ TEST_F(SpvParserTest, EmitBody_If_Else_Premerge) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8219,7 +8219,7 @@ TEST_F(SpvParserTest, EmitBody_If_Nest_If) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8309,7 +8309,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_TrueBackedge) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8364,7 +8364,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_FalseBackedge) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8415,7 +8415,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_BothBackedge) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8458,7 +8458,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_SingleBlock_UnconditionalBackege) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8509,7 +8509,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Unconditional_Body_SingleBlockContinue) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8574,7 +8574,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Unconditional_Body_MultiBlockContinue) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8648,7 +8648,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Unconditional_Body_ContinueNestIf) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8720,7 +8720,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_MultiBlockContinueIsEntireLoop) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -8778,7 +8778,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_Never) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -8838,7 +8838,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_TrueToBody_FalseBreaks) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -8905,7 +8905,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_FalseToBody_TrueBreaks) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -8979,7 +8979,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_NestedIfContinue) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ If{ ( @@ -9037,7 +9037,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyAlwaysBreaks) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -9086,7 +9086,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromTrue) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -9142,7 +9142,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromFalse) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -9204,7 +9204,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromTrue_Early) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -9266,7 +9266,7 @@ TEST_F(SpvParserTest, EmitBody_Loop_BodyConditionallyBreaks_FromFalse_Early) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -9319,7 +9319,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_NoCases) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9364,7 +9364,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_OneCase) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9418,7 +9418,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_TwoCases) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9478,7 +9478,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsMerge_CasesWithDup) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9544,7 +9544,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsCase_NoDupCases) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9615,7 +9615,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_DefaultIsCase_WithDupCase) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9687,7 +9687,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_Case_SintValue) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9757,7 +9757,7 @@ TEST_F(SpvParserTest, EmitBody_Switch_Case_UintValue) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -9809,7 +9809,7 @@ TEST_F(SpvParserTest, EmitBody_Return_TopLevel) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Return{} )"; ASSERT_EQ(expect, got); @@ -9835,7 +9835,7 @@ TEST_F(SpvParserTest, EmitBody_Return_InsideIf) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{false} @@ -9875,7 +9875,7 @@ TEST_F(SpvParserTest, EmitBody_Return_InsideLoop) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Return{} } @@ -9905,7 +9905,7 @@ TEST_F(SpvParserTest, EmitBody_ReturnValue_TopLevel) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Return{ { ScalarConstructor[not set]{2} @@ -9944,7 +9944,7 @@ TEST_F(SpvParserTest, EmitBody_ReturnValue_InsideIf) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{false} @@ -10001,7 +10001,7 @@ TEST_F(SpvParserTest, EmitBody_ReturnValue_Loop) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Return{ { @@ -10031,7 +10031,7 @@ TEST_F(SpvParserTest, EmitBody_Kill_TopLevel) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Discard{} )"; ASSERT_EQ(expect, got); @@ -10057,7 +10057,7 @@ TEST_F(SpvParserTest, EmitBody_Kill_InsideIf) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{false} @@ -10097,7 +10097,7 @@ TEST_F(SpvParserTest, EmitBody_Kill_InsideLoop) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Discard{} } @@ -10119,7 +10119,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_TopLevel) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Return{} )"; ASSERT_EQ(expect, got); @@ -10145,7 +10145,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_InsideIf) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{false} @@ -10185,7 +10185,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_InsideLoop) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Return{} } @@ -10215,7 +10215,7 @@ TEST_F(SpvParserTest, EmitBody_Unreachable_InNonVoidFunction) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 200)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Return{ { ScalarConstructor[not set]{0} @@ -10249,7 +10249,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_BackEdge_MultiBlockLoop) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ continuing { Assignment{ @@ -10284,7 +10284,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_BackEdge_SingleBlockLoop) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -10321,7 +10321,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_SwitchBreak_LastInCase) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -10381,7 +10381,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_SwitchBreak_NotLastInCase) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -10452,7 +10452,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopBreak_MultiBlockLoop_FromBody) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -10534,7 +10534,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ continuing { Assignment{ @@ -10576,7 +10576,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopContinue_LastInLoopConstruct) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ Assignment{ Identifier[not set]{var_1} @@ -10630,7 +10630,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopContinue_BeforeLast) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Loop{ If{ ( @@ -10699,7 +10699,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_LoopContinue_FromSwitch) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -10769,7 +10769,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_IfBreak_FromThen) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{false} @@ -10812,7 +10812,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_IfBreak_FromElse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(If{ ( ScalarConstructor[not set]{false} @@ -10864,7 +10864,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_Fallthrough) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -10915,7 +10915,7 @@ TEST_F(SpvParserTest, EmitBody_Branch_Forward) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11019,7 +11019,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Back_SingleBlock_Back) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -11062,7 +11062,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -11113,7 +11113,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -11171,7 +11171,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -11227,7 +11227,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -11287,7 +11287,7 @@ TEST_F(SpvParserTest, FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11348,7 +11348,7 @@ TEST_F(SpvParserTest, FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11431,7 +11431,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Continue_OnTrue) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11526,7 +11526,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Continue_OnFalse) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11611,7 +11611,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Forward_OnTrue) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11680,7 +11680,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_SwitchBreak_Forward_OnFalse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11747,7 +11747,7 @@ TEST_F(SpvParserTest, FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11821,7 +11821,7 @@ TEST_F(SpvParserTest, FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -11890,7 +11890,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -11948,7 +11948,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12021,7 +12021,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Continue_OnTrue) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12117,7 +12117,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Continue_OnFalse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12256,7 +12256,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Forward_OnTrue) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12337,7 +12337,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopBreak_Forward_OnFalse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12405,7 +12405,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Continue_FromHeader) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12462,7 +12462,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12534,7 +12534,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12622,7 +12622,7 @@ TEST_F( ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12701,7 +12701,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_LoopContinue_FromSwitch) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -12789,7 +12789,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_IfBreak_OnTrue) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12886,7 +12886,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_IfBreak_OnFalse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -12982,7 +12982,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Fallthrough_OnTrue) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -13091,7 +13091,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Fallthrough_OnFalse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -13188,7 +13188,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Forward_OnTrue) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -13269,7 +13269,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Continue_Forward_OnFalse) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -13333,7 +13333,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_IfBreak_IfBreak_Same) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{0} @@ -13418,7 +13418,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Fallthrough_Fallthrough_Same) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -13509,7 +13509,7 @@ TEST_F(SpvParserTest, EmitBody_BranchConditional_Forward_Forward_Same) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = R"(Assignment{ Identifier[not set]{var_1} ScalarConstructor[not set]{1} @@ -13578,7 +13578,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = "unhandled case"; ASSERT_EQ(expect, got); } @@ -13613,7 +13613,7 @@ TEST_F(SpvParserTest, ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto got = ToString(fe.ast_body()); + auto got = ToString(p->get_module(), fe.ast_body()); auto* expect = "unhandled case"; ASSERT_EQ(expect, got); } diff --git a/src/reader/spirv/function_composite_test.cc b/src/reader/spirv/function_composite_test.cc index 0cc2cc87a1..2c4d356a4d 100644 --- a/src/reader/spirv/function_composite_test.cc +++ b/src/reader/spirv/function_composite_test.cc @@ -86,7 +86,8 @@ TEST_F(SpvParserTest_Composite_Construct, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -127,7 +128,7 @@ VariableDeclStatement{ } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest_Composite_Construct, Matrix) { @@ -142,7 +143,7 @@ TEST_F(SpvParserTest_Composite_Construct, Matrix) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -168,7 +169,7 @@ TEST_F(SpvParserTest_Composite_Construct, Matrix) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest_Composite_Construct, Array) { @@ -183,7 +184,7 @@ TEST_F(SpvParserTest_Composite_Construct, Array) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -199,7 +200,7 @@ TEST_F(SpvParserTest_Composite_Construct, Array) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest_Composite_Construct, Struct) { @@ -214,7 +215,7 @@ TEST_F(SpvParserTest_Composite_Construct, Struct) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -232,7 +233,7 @@ TEST_F(SpvParserTest_Composite_Construct, Struct) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } using SpvParserTest_CompositeExtract = SpvParserTest; @@ -249,7 +250,7 @@ TEST_F(SpvParserTest_CompositeExtract, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -265,7 +266,7 @@ TEST_F(SpvParserTest_CompositeExtract, Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest_CompositeExtract, Vector_IndexTooBigError) { @@ -300,7 +301,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_2 none @@ -312,7 +313,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest_CompositeExtract, Matrix_IndexTooBigError) { @@ -351,7 +352,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_2 none @@ -366,7 +367,7 @@ TEST_F(SpvParserTest_CompositeExtract, Matrix_Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest_CompositeExtract, Array) { @@ -385,7 +386,7 @@ TEST_F(SpvParserTest_CompositeExtract, Array) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_2 none @@ -397,7 +398,7 @@ TEST_F(SpvParserTest_CompositeExtract, Array) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest_CompositeExtract, RuntimeArray_IsError) { @@ -436,7 +437,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_2 none @@ -448,7 +449,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) { @@ -478,7 +479,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_2 none @@ -490,8 +491,8 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) { } } })")) - << ToString(fe.ast_body()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + << ToString(p->get_module(), fe.ast_body()); + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_4 none @@ -503,7 +504,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_DifferOnlyInMemberName) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest_CompositeExtract, Struct_IndexTooBigError) { @@ -544,7 +545,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_Array_Matrix_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_2 none @@ -565,7 +566,7 @@ TEST_F(SpvParserTest_CompositeExtract, Struct_Array_Matrix_Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } using SpvParserTest_CopyObject = SpvParserTest; @@ -583,7 +584,8 @@ TEST_F(SpvParserTest_CopyObject, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -602,7 +604,7 @@ VariableDeclStatement{ Identifier[not set]{x_1} } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest_CopyObject, Pointer) { @@ -621,7 +623,8 @@ TEST_F(SpvParserTest_CopyObject, Pointer) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -640,7 +643,7 @@ VariableDeclStatement{ Identifier[not set]{x_1} } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } using SpvParserTest_VectorShuffle = SpvParserTest; @@ -661,7 +664,8 @@ TEST_F(SpvParserTest_VectorShuffle, FunctionScopeOperands_UseBoth) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_10 none __vec_4__u32 @@ -687,7 +691,7 @@ TEST_F(SpvParserTest_VectorShuffle, FunctionScopeOperands_UseBoth) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) { @@ -703,7 +707,8 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_10 none __vec_4__u32 @@ -745,7 +750,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_UseBoth) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) { @@ -762,7 +767,8 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_10 none __vec_2__u32 @@ -777,7 +783,7 @@ TEST_F(SpvParserTest_VectorShuffle, ConstantOperands_AllOnesMapToNull) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest_VectorShuffle, IndexTooBig_IsError) { diff --git a/src/reader/spirv/function_conversion_test.cc b/src/reader/spirv/function_conversion_test.cc index e95afa7f6e..5499451096 100644 --- a/src/reader/spirv/function_conversion_test.cc +++ b/src/reader/spirv/function_conversion_test.cc @@ -82,7 +82,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -93,7 +93,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, Bitcast_Vector) { @@ -108,7 +108,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -123,7 +123,7 @@ TEST_F(SpvUnaryConversionTest, Bitcast_Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertSToF_BadArg) { @@ -238,7 +238,8 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __f32 @@ -249,7 +250,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromSigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) { @@ -265,7 +266,8 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __f32 @@ -278,7 +280,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Scalar_FromUnsigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) { @@ -294,7 +296,8 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __vec_2__f32 @@ -305,7 +308,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromSigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) { @@ -321,7 +324,8 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __vec_2__f32 @@ -334,7 +338,7 @@ TEST_F(SpvUnaryConversionTest, ConvertSToF_Vector_FromUnsigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_BadArgType) { @@ -383,7 +387,8 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __f32 @@ -396,7 +401,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromSigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) { @@ -412,7 +417,8 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __f32 @@ -423,7 +429,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Scalar_FromUnsigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) { @@ -439,7 +445,8 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __vec_2__f32 @@ -452,7 +459,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromSigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) { @@ -468,7 +475,8 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __vec_2__f32 @@ -479,7 +487,7 @@ TEST_F(SpvUnaryConversionTest, ConvertUToF_Vector_FromUnsigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_BadArgType) { @@ -529,7 +537,8 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __i32 @@ -540,7 +549,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToSigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) { @@ -556,7 +565,8 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __u32 @@ -569,7 +579,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Scalar_ToUnsigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) { @@ -585,7 +595,8 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __vec_2__i32 @@ -596,7 +607,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToSigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) { @@ -612,7 +623,8 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __vec_2__u32 @@ -625,7 +637,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToS_Vector_ToUnsigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_BadArgType) { @@ -675,7 +687,8 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __i32 @@ -688,7 +701,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToSigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToUnsigned) { @@ -704,7 +717,8 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __u32 @@ -715,7 +729,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Scalar_ToUnsigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToSigned) { @@ -731,7 +745,8 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToSigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __vec_2__i32 @@ -744,7 +759,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToSigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToUnsigned) { @@ -760,7 +775,8 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToUnsigned) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableConst{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableConst{ x_1 none __vec_2__u32 @@ -771,7 +787,7 @@ TEST_F(SpvUnaryConversionTest, ConvertFToU_Vector_ToUnsigned) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } // TODO(dneto): OpSConvert // only if multiple widths diff --git a/src/reader/spirv/function_glsl_std_450_test.cc b/src/reader/spirv/function_glsl_std_450_test.cc index 4333ceeb4c..78f7932cc6 100644 --- a/src/reader/spirv/function_glsl_std_450_test.cc +++ b/src/reader/spirv/function_glsl_std_450_test.cc @@ -183,7 +183,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -191,14 +191,14 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{f1} ) } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) { @@ -212,7 +212,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -220,14 +220,14 @@ TEST_P(SpvParserTest_GlslStd450_Float_Floating, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2f1} ) } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) { @@ -241,7 +241,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -249,7 +249,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{f1} Identifier[not set]{f2} @@ -257,7 +257,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) { @@ -271,7 +271,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -279,7 +279,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2f1} Identifier[not set]{v2f2} @@ -287,7 +287,7 @@ TEST_P(SpvParserTest_GlslStd450_Float_FloatingFloating, Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) { @@ -301,7 +301,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -309,14 +309,14 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{f1} ) } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) { @@ -330,7 +330,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -338,14 +338,14 @@ TEST_P(SpvParserTest_GlslStd450_Floating_Floating, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2f1} ) } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) { @@ -359,7 +359,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -367,7 +367,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{f1} Identifier[not set]{f2} @@ -375,7 +375,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) { @@ -389,7 +389,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -397,7 +397,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2f1} Identifier[not set]{v2f2} @@ -405,7 +405,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloating, Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) { @@ -419,7 +419,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -427,7 +427,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{f1} Identifier[not set]{f2} @@ -436,7 +436,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) { @@ -451,7 +451,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -459,7 +459,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2f1} Identifier[not set]{v2f2} @@ -468,7 +468,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingFloatingFloating, Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) { @@ -482,7 +482,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -490,7 +490,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{f1} Identifier[not set]{u1} @@ -498,7 +498,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) { @@ -513,7 +513,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -521,7 +521,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2f1} Identifier[not set]{v2u1} @@ -529,7 +529,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingUinting, Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) { @@ -543,7 +543,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -551,7 +551,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{f1} Identifier[not set]{i1} @@ -559,7 +559,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) { @@ -574,7 +574,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -582,7 +582,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2f1} Identifier[not set]{v2i1} @@ -590,7 +590,7 @@ TEST_P(SpvParserTest_GlslStd450_Floating_FloatingInting, Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) { @@ -605,7 +605,7 @@ TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -613,7 +613,7 @@ TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v3f1} Identifier[not set]{v3f2} @@ -621,7 +621,7 @@ TEST_P(SpvParserTest_GlslStd450_Float3_Float3Float3, Samples) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } INSTANTIATE_TEST_SUITE_P(Samples, @@ -709,7 +709,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -717,14 +717,14 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{i1} ) } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Vector) { @@ -739,7 +739,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -747,14 +747,14 @@ TEST_P(SpvParserTest_GlslStd450_Inting_Inting, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2i1} ) } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) { @@ -769,7 +769,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -777,7 +777,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{i1} Identifier[not set]{i2} @@ -785,7 +785,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) { @@ -800,7 +800,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -808,7 +808,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2i1} Identifier[not set]{v2i2} @@ -816,7 +816,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingInting, Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) { @@ -831,7 +831,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -839,7 +839,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{i1} Identifier[not set]{i2} @@ -848,7 +848,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) { @@ -863,7 +863,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -871,7 +871,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2i1} Identifier[not set]{v2i2} @@ -880,7 +880,7 @@ TEST_P(SpvParserTest_GlslStd450_Inting_IntingIntingInting, Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } INSTANTIATE_TEST_SUITE_P(Samples, @@ -907,7 +907,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -915,7 +915,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{u1} Identifier[not set]{u2} @@ -923,7 +923,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) { @@ -938,7 +938,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -946,7 +946,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2u1} Identifier[not set]{v2u2} @@ -954,7 +954,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUinting, Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) { @@ -968,7 +968,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -976,7 +976,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{u1} Identifier[not set]{u2} @@ -985,7 +985,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) { @@ -1000,7 +1000,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -1008,7 +1008,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) { { Call[not set]{ Identifier[not set]{)" + GetParam().wgsl_func + - R"(} + R"(} ( Identifier[not set]{v2u1} Identifier[not set]{v2u2} @@ -1017,7 +1017,7 @@ TEST_P(SpvParserTest_GlslStd450_Uinting_UintingUintingUinting, Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } INSTANTIATE_TEST_SUITE_P(Samples, @@ -1043,7 +1043,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SAbs) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto body = ToString(fe.ast_body()); + auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1095,7 +1095,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SMax) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto body = ToString(fe.ast_body()); + auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1153,7 +1153,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SMin) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto body = ToString(fe.ast_body()); + auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1211,7 +1211,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_SClamp) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto body = ToString(fe.ast_body()); + auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1271,7 +1271,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UMax) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto body = ToString(fe.ast_body()); + auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1329,7 +1329,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UMin) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto body = ToString(fe.ast_body()); + auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 @@ -1387,7 +1387,7 @@ TEST_F(SpvParserTest, RectifyOperandsAndResult_UClamp) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - auto body = ToString(fe.ast_body()); + auto body = ToString(p->get_module(), fe.ast_body()); EXPECT_THAT(body, HasSubstr(R"( VariableConst{ x_1 diff --git a/src/reader/spirv/function_logical_test.cc b/src/reader/spirv/function_logical_test.cc index 1630a1f87f..355c223761 100644 --- a/src/reader/spirv/function_logical_test.cc +++ b/src/reader/spirv/function_logical_test.cc @@ -206,7 +206,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -218,7 +218,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) { @@ -233,7 +233,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -249,7 +249,7 @@ TEST_F(SpvUnaryLogicalTest, LogicalNot_Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } struct BinaryData { @@ -296,7 +296,8 @@ TEST_P(SpvBinaryLogicalTest, EmitExpression) { << GetParam().ast_type << "\n {\n Binary[not set]{" << "\n " << GetParam().ast_lhs << "\n " << GetParam().ast_op << "\n " << GetParam().ast_rhs; - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(ss.str())) << assembly; + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(ss.str())) + << assembly; } INSTANTIATE_TEST_SUITE_P( @@ -701,7 +702,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -717,7 +718,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordEqual_Vector) { @@ -732,7 +733,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -756,7 +757,7 @@ TEST_F(SpvFUnordTest, FUnordEqual_Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) { @@ -771,7 +772,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -787,7 +788,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) { @@ -802,7 +803,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -826,7 +827,7 @@ TEST_F(SpvFUnordTest, FUnordNotEqual_Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) { @@ -841,7 +842,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -857,7 +858,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordLessThan_Vector) { @@ -872,7 +873,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -896,7 +897,7 @@ TEST_F(SpvFUnordTest, FUnordLessThan_Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) { @@ -911,7 +912,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -927,7 +928,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) { @@ -942,7 +943,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -966,7 +967,7 @@ TEST_F(SpvFUnordTest, FUnordLessThanEqual_Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) { @@ -981,7 +982,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -997,7 +998,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) { @@ -1012,7 +1013,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -1036,7 +1037,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThan_Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) { @@ -1051,7 +1052,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -1067,7 +1068,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Scalar) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) { @@ -1082,7 +1083,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -1106,7 +1107,7 @@ TEST_F(SpvFUnordTest, FUnordGreaterThanEqual_Vector) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, Select_BoolCond_BoolParams) { @@ -1121,7 +1122,8 @@ TEST_F(SpvFUnordTest, Select_BoolCond_BoolParams) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -1137,7 +1139,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_BoolParams) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, Select_BoolCond_IntScalarParams) { @@ -1152,7 +1154,8 @@ TEST_F(SpvFUnordTest, Select_BoolCond_IntScalarParams) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -1168,7 +1171,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_IntScalarParams) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, Select_BoolCond_FloatScalarParams) { @@ -1183,7 +1186,8 @@ TEST_F(SpvFUnordTest, Select_BoolCond_FloatScalarParams) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -1199,7 +1203,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_FloatScalarParams) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, Select_BoolCond_VectorParams) { @@ -1214,7 +1218,8 @@ TEST_F(SpvFUnordTest, Select_BoolCond_VectorParams) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -1238,7 +1243,7 @@ TEST_F(SpvFUnordTest, Select_BoolCond_VectorParams) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvFUnordTest, Select_VecBoolCond_VectorParams) { @@ -1253,7 +1258,8 @@ TEST_F(SpvFUnordTest, Select_VecBoolCond_VectorParams) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -1281,7 +1287,7 @@ TEST_F(SpvFUnordTest, Select_VecBoolCond_VectorParams) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } using SpvLogicalTest = SpvParserTestBase<::testing::Test>; @@ -1298,7 +1304,8 @@ TEST_F(SpvLogicalTest, Any) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -1316,7 +1323,7 @@ TEST_F(SpvLogicalTest, Any) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvLogicalTest, All) { @@ -1331,7 +1338,8 @@ TEST_F(SpvLogicalTest, All) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -1349,7 +1357,7 @@ TEST_F(SpvLogicalTest, All) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvLogicalTest, IsNan_Scalar) { @@ -1364,7 +1372,8 @@ TEST_F(SpvLogicalTest, IsNan_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -1378,7 +1387,7 @@ TEST_F(SpvLogicalTest, IsNan_Scalar) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvLogicalTest, IsNan_Vector) { @@ -1393,7 +1402,8 @@ TEST_F(SpvLogicalTest, IsNan_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -1411,7 +1421,7 @@ TEST_F(SpvLogicalTest, IsNan_Vector) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvLogicalTest, IsInf_Scalar) { @@ -1426,7 +1436,8 @@ TEST_F(SpvLogicalTest, IsInf_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -1440,7 +1451,7 @@ TEST_F(SpvLogicalTest, IsInf_Scalar) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvLogicalTest, IsInf_Vector) { @@ -1455,7 +1466,8 @@ TEST_F(SpvLogicalTest, IsInf_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -1473,7 +1485,7 @@ TEST_F(SpvLogicalTest, IsInf_Vector) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } // TODO(dneto): Kernel-guarded instructions. diff --git a/src/reader/spirv/function_memory_test.cc b/src/reader/spirv/function_memory_test.cc index 86e51893f6..bda6e9ab22 100644 --- a/src/reader/spirv/function_memory_test.cc +++ b/src/reader/spirv/function_memory_test.cc @@ -50,7 +50,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreBoolConst) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} ScalarConstructor[not set]{true} } @@ -82,7 +82,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreUintConst) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} ScalarConstructor[not set]{42} } @@ -110,7 +110,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreIntConst) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} ScalarConstructor[not set]{42} } @@ -138,7 +138,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreFloatConst) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} ScalarConstructor[not set]{42.000000} } @@ -167,7 +167,7 @@ TEST_F(SpvParserTest, EmitStatement_LoadBool) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_2 none @@ -196,7 +196,8 @@ TEST_F(SpvParserTest, EmitStatement_LoadScalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_2 none @@ -237,7 +238,8 @@ TEST_F(SpvParserTest, EmitStatement_UseLoadedScalarTwice) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_2 none @@ -274,7 +276,7 @@ TEST_F(SpvParserTest, EmitStatement_StoreToModuleScopeVar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ Identifier[not set]{x_1} ScalarConstructor[not set]{42} })")); @@ -341,13 +343,13 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorSwizzle) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ MemberAccessor[not set]{ Identifier[not set]{myvar} Identifier[not set]{z} } ScalarConstructor[not set]{42} -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorConstOutOfBounds) { @@ -404,7 +406,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_VectorNonConstIndex) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ Identifier[not set]{myvar} Identifier[not set]{x_11} @@ -441,7 +443,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Matrix) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ Identifier[not set]{myvar} ScalarConstructor[not set]{2} @@ -484,7 +486,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Array) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ Identifier[not set]{myvar} ScalarConstructor[not set]{2} @@ -526,7 +528,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ MemberAccessor[not set]{ Identifier[not set]{myvar} Identifier[not set]{age} @@ -574,7 +576,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct_DifferOnlyMemberName) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ MemberAccessor[not set]{ Identifier[not set]{myvar} Identifier[not set]{age} @@ -587,7 +589,7 @@ Assignment{ Identifier[not set]{ancientness} } ScalarConstructor[not set]{420.000000} -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, EmitStatement_AccessChain_StructNonConstIndex) { @@ -684,7 +686,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Struct_RuntimeArray) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ MemberAccessor[not set]{ Identifier[not set]{myvar} @@ -724,7 +726,7 @@ TEST_F(SpvParserTest, EmitStatement_AccessChain_Compound_Matrix_Vector) { << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ MemberAccessor[not set]{ ArrayAccessor[not set]{ Identifier[not set]{myvar} @@ -832,7 +834,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_NonCascaded) { ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ MemberAccessor[not set]{ Identifier[not set]{myvar} Identifier[not set]{field0} @@ -848,7 +850,7 @@ Assignment{ ScalarConstructor[not set]{1} } ScalarConstructor[not set]{0} -})")) << ToString(fe.ast_body()) +})")) << ToString(p->get_module(), fe.ast_body()) << p->error(); } @@ -871,7 +873,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_Cascaded) { ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"(Assignment{ ArrayAccessor[not set]{ MemberAccessor[not set]{ Identifier[not set]{myvar} @@ -880,7 +882,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughAccessChain_Cascaded) { ScalarConstructor[not set]{1} } ScalarConstructor[not set]{0} -})")) << ToString(fe.ast_body()) +})")) << ToString(p->get_module(), fe.ast_body()) << p->error(); } @@ -904,7 +906,8 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithoutHoisting) { ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_2 none @@ -923,7 +926,7 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithoutHoisting) { Assignment{ Identifier[not set]{x_2} ScalarConstructor[not set]{0} -})")) << ToString(fe.ast_body()) +})")) << ToString(p->get_module(), fe.ast_body()) << p->error(); } @@ -959,7 +962,8 @@ TEST_F(SpvParserTest, RemapStorageBuffer_ThroughCopyObject_WithHoisting) { ASSERT_TRUE(p->BuildAndParseInternalModule()) << assembly << p->error(); FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + Eq(R"(VariableDeclStatement{ Variable{ x_2 function @@ -993,7 +997,7 @@ Assignment{ ScalarConstructor[not set]{0} } Return{} -)")) << ToString(fe.ast_body()) +)")) << ToString(p->get_module(), fe.ast_body()) << p->error(); } diff --git a/src/reader/spirv/function_misc_test.cc b/src/reader/spirv/function_misc_test.cc index e215fdd7dd..2558e49b57 100644 --- a/src/reader/spirv/function_misc_test.cc +++ b/src/reader/spirv/function_misc_test.cc @@ -68,7 +68,8 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Scalar) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_11 none @@ -107,7 +108,7 @@ VariableDeclStatement{ ScalarConstructor[not set]{0.000000} } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Vector) { @@ -128,7 +129,8 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Vector) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_11 none @@ -169,7 +171,7 @@ VariableDeclStatement{ } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) { @@ -188,7 +190,8 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_11 none @@ -209,7 +212,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Matrix) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) { @@ -229,7 +232,8 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_11 none @@ -242,7 +246,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Array) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) { @@ -261,7 +265,8 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) { ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ VariableConst{ x_11 none @@ -276,7 +281,7 @@ TEST_F(SpvParserTestMiscInstruction, OpUndef_InFunction_Struct) { } } } -})")) << ToString(fe.ast_body()); +})")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTestMiscInstruction, OpNop) { @@ -292,8 +297,8 @@ TEST_F(SpvParserTestMiscInstruction, OpNop) { << p->error() << assembly; FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(Return{} -)")) << ToString(fe.ast_body()); + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), Eq(R"(Return{} +)")) << ToString(p->get_module(), fe.ast_body()); } // Test swizzle generation. @@ -324,7 +329,8 @@ TEST_P(SpvParserSwizzleTest, Sample) { ASSERT_NE(result, nullptr); std::ostringstream ss; result->to_str(ss, 0); - EXPECT_THAT(ss.str(), Eq(GetParam().expected_expr)); + auto str = Demangler().Demangle(p->get_module(), ss.str()); + EXPECT_THAT(str, Eq(GetParam().expected_expr)); } else { EXPECT_EQ(result, nullptr); EXPECT_FALSE(fe.success()); diff --git a/src/reader/spirv/function_var_test.cc b/src/reader/spirv/function_var_test.cc index b4c94615de..74803fa9e6 100644 --- a/src/reader/spirv/function_var_test.cc +++ b/src/reader/spirv/function_var_test.cc @@ -91,7 +91,8 @@ TEST_F(SpvParserTest, EmitFunctionVariables_AnonymousVars) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ Variable{ x_1 function @@ -129,7 +130,8 @@ TEST_F(SpvParserTest, EmitFunctionVariables_NamedVars) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ Variable{ a function @@ -167,7 +169,8 @@ TEST_F(SpvParserTest, EmitFunctionVariables_MixedTypes) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ Variable{ a function @@ -208,7 +211,8 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ScalarInitializers) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ Variable{ a function @@ -281,7 +285,8 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ScalarNullInitializers) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ Variable{ a function @@ -340,7 +345,8 @@ TEST_F(SpvParserTest, EmitFunctionVariables_VectorInitializer) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 function @@ -354,7 +360,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_VectorInitializer) { } } } -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, EmitFunctionVariables_MatrixInitializer) { @@ -378,7 +384,8 @@ TEST_F(SpvParserTest, EmitFunctionVariables_MatrixInitializer) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 function @@ -424,7 +431,8 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 function @@ -438,7 +446,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer) { } } } -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias) { @@ -458,7 +466,8 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 function @@ -472,7 +481,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias) { } } } -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) { @@ -491,7 +500,8 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 function @@ -505,7 +515,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Null) { } } } -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) { @@ -525,7 +535,8 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 function @@ -539,7 +550,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_ArrayInitializer_Alias_Null) { } } } -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) { @@ -559,7 +570,8 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 function @@ -578,7 +590,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer) { } } } -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer_Null) { @@ -598,7 +610,8 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer_Null) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitFunctionVariables()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + HasSubstr(R"(VariableDeclStatement{ Variable{ x_200 function @@ -617,7 +630,7 @@ TEST_F(SpvParserTest, EmitFunctionVariables_StructInitializer_Null) { } } } -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, @@ -642,7 +655,8 @@ TEST_F(SpvParserTest, FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + Eq(R"(VariableDeclStatement{ Variable{ x_25 function @@ -662,7 +676,7 @@ Assignment{ } } Return{} -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, EmitStatement_CombinatorialValue_Immediate_UsedTwice) { @@ -687,7 +701,8 @@ TEST_F(SpvParserTest, EmitStatement_CombinatorialValue_Immediate_UsedTwice) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + Eq(R"(VariableDeclStatement{ Variable{ x_25 function @@ -721,7 +736,7 @@ Assignment{ Identifier[not set]{x_2} } Return{} -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, @@ -757,7 +772,8 @@ TEST_F(SpvParserTest, FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + Eq(R"(VariableDeclStatement{ Variable{ x_25 function @@ -795,7 +811,7 @@ Assignment{ ScalarConstructor[not set]{2} } Return{} -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F( @@ -854,7 +870,7 @@ TEST_F( FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(Assignment{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), Eq(R"(Assignment{ Identifier[not set]{x_1} ScalarConstructor[not set]{0} } @@ -926,7 +942,7 @@ Assignment{ ScalarConstructor[not set]{5} } Return{} -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F( @@ -970,7 +986,8 @@ TEST_F( // We don't hoist x_1 into its own mutable variable. It is emitted as // a const definition. - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + Eq(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -1002,7 +1019,7 @@ Assignment{ Identifier[not set]{x_3} } Return{} -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, @@ -1053,7 +1070,7 @@ TEST_F(SpvParserTest, FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(If{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), Eq(R"(If{ ( ScalarConstructor[not set]{true} ) @@ -1092,7 +1109,7 @@ TEST_F(SpvParserTest, } } Return{} -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F( @@ -1138,7 +1155,7 @@ TEST_F( FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(If{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), Eq(R"(If{ ( ScalarConstructor[not set]{true} ) @@ -1179,7 +1196,7 @@ TEST_F( } } Return{} -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, @@ -1219,7 +1236,8 @@ TEST_F(SpvParserTest, // We don't hoist x_1 into its own mutable variable. It is emitted as // a const definition. - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + Eq(R"(VariableDeclStatement{ VariableConst{ x_1 none @@ -1247,7 +1265,7 @@ If{ } } Return{} -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, EmitStatement_Phi_SingleBlockLoopIndex) { @@ -1291,7 +1309,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_SingleBlockLoopIndex) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(Loop{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), Eq(R"(Loop{ VariableDeclStatement{ Variable{ x_2_phi @@ -1386,7 +1404,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_SingleBlockLoopIndex) { } } Return{} -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, EmitStatement_Phi_MultiBlockLoopIndex) { @@ -1433,7 +1451,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_MultiBlockLoopIndex) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(Loop{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), Eq(R"(Loop{ VariableDeclStatement{ Variable{ x_2_phi @@ -1541,7 +1559,7 @@ TEST_F(SpvParserTest, EmitStatement_Phi_MultiBlockLoopIndex) { } } Return{} -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, EmitStatement_Phi_ValueFromLoopBodyAndContinuing) { @@ -1589,7 +1607,8 @@ TEST_F(SpvParserTest, EmitStatement_Phi_ValueFromLoopBodyAndContinuing) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + Eq(R"(VariableDeclStatement{ VariableConst{ x_101 none @@ -1707,7 +1726,7 @@ Loop{ } } Return{} -)")) << ToString(fe.ast_body()) +)")) << ToString(p->get_module(), fe.ast_body()) << assembly; } @@ -1757,7 +1776,8 @@ TEST_F(SpvParserTest, EmitStatement_Phi_FromElseAndThen) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + Eq(R"(VariableDeclStatement{ VariableConst{ x_101 none @@ -1831,7 +1851,7 @@ Loop{ } } Return{} -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, EmitStatement_Phi_FromHeaderAndThen) { @@ -1877,7 +1897,8 @@ TEST_F(SpvParserTest, EmitStatement_Phi_FromHeaderAndThen) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + Eq(R"(VariableDeclStatement{ VariableConst{ x_101 none @@ -1946,7 +1967,7 @@ Loop{ } } Return{} -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } TEST_F(SpvParserTest, EmitStatement_UseInPhiCountsAsUse) { @@ -1983,7 +2004,8 @@ TEST_F(SpvParserTest, EmitStatement_UseInPhiCountsAsUse) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); - EXPECT_THAT(ToString(fe.ast_body()), Eq(R"(VariableDeclStatement{ + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), + Eq(R"(VariableDeclStatement{ Variable{ x_101_phi function @@ -2043,7 +2065,7 @@ VariableDeclStatement{ } } Return{} -)")) << ToString(fe.ast_body()); +)")) << ToString(p->get_module(), fe.ast_body()); } } // namespace diff --git a/src/reader/spirv/parser_impl_function_decl_test.cc b/src/reader/spirv/parser_impl_function_decl_test.cc index dab5f3a0e3..ff605239ec 100644 --- a/src/reader/spirv/parser_impl_function_decl_test.cc +++ b/src/reader/spirv/parser_impl_function_decl_test.cc @@ -199,10 +199,10 @@ TEST_F(SpvParserTest, EmitFunctions_CalleePrecedesCaller) { )")); EXPECT_TRUE(p->BuildAndParseInternalModule()); EXPECT_TRUE(p->error().empty()); - const auto module_ast = p->get_module().to_str(); + const auto module_ast = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_ast, HasSubstr(R"( - Function )" + p->get_module().GetSymbol("leaf").to_str() + - R"( -> __u32 + Function leaf -> __u32 () { Return{ @@ -211,8 +211,7 @@ TEST_F(SpvParserTest, EmitFunctions_CalleePrecedesCaller) { } } } - Function )" + p->get_module().GetSymbol("branch").to_str() + - R"( -> __u32 + Function branch -> __u32 () { VariableDeclStatement{ @@ -235,8 +234,7 @@ TEST_F(SpvParserTest, EmitFunctions_CalleePrecedesCaller) { } } } - Function )" + p->get_module().GetSymbol("root").to_str() + - R"( -> __void + Function root -> __void () { VariableDeclStatement{ diff --git a/src/reader/spirv/parser_impl_handle_test.cc b/src/reader/spirv/parser_impl_handle_test.cc index 7c3fc65828..bed8be6b88 100644 --- a/src/reader/spirv/parser_impl_handle_test.cc +++ b/src/reader/spirv/parser_impl_handle_test.cc @@ -16,6 +16,7 @@ #include #include "gmock/gmock.h" +#include "src/demangler.h" #include "src/reader/spirv/function.h" #include "src/reader/spirv/parser_impl.h" #include "src/reader/spirv/parser_impl_test_helper.h" @@ -1128,7 +1129,8 @@ TEST_P(SpvParserTest_DeclUnderspecifiedHandle, Variable) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error() << assembly; EXPECT_TRUE(p->error().empty()) << p->error(); - const auto module = p->module().to_str(); + const auto module = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module, HasSubstr(GetParam().var_decl)) << module; } @@ -1300,7 +1302,8 @@ TEST_P(SpvParserTest_SampledImageAccessTest, Variable) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error() << assembly; EXPECT_TRUE(p->error().empty()) << p->error(); - const auto module = p->module().to_str(); + const auto module = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module, HasSubstr(GetParam().var_decl)) << "DECLARATIONS ARE BAD " << module; EXPECT_THAT(module, HasSubstr(GetParam().texture_builtin)) @@ -2373,7 +2376,8 @@ TEST_P(SpvParserTest_ImageAccessTest, Variable) { auto p = parser(test::Assemble(assembly)); ASSERT_TRUE(p->BuildAndParseInternalModule()) << p->error() << assembly; EXPECT_TRUE(p->error().empty()) << p->error(); - const auto module = p->module().to_str(); + const auto module = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module, HasSubstr(GetParam().var_decl)) << "DECLARATIONS ARE BAD " << module; EXPECT_THAT(module, HasSubstr(GetParam().texture_builtin)) @@ -3670,7 +3674,8 @@ TEST_P(SpvParserTest_ImageCoordsTest, MakeCoordinateOperandsForImageAccess) { std::vector result_strings; for (auto* expr : result) { ASSERT_NE(expr, nullptr); - result_strings.push_back(expr->str()); + result_strings.push_back( + Demangler().Demangle(p->get_module(), expr->str())); } EXPECT_THAT(result_strings, ::testing::ContainerEq(GetParam().expected_expressions)); diff --git a/src/reader/spirv/parser_impl_module_var_test.cc b/src/reader/spirv/parser_impl_module_var_test.cc index be335f1215..15549611d9 100644 --- a/src/reader/spirv/parser_impl_module_var_test.cc +++ b/src/reader/spirv/parser_impl_module_var_test.cc @@ -15,6 +15,7 @@ #include #include "gmock/gmock.h" +#include "src/demangler.h" #include "src/reader/spirv/function.h" #include "src/reader/spirv/parser_impl.h" #include "src/reader/spirv/parser_impl_test_helper.h" @@ -326,7 +327,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_BuiltinPosition_StorePosition) { auto p = parser(test::Assemble(assembly)); EXPECT_TRUE(p->BuildAndParseInternalModule()); EXPECT_TRUE(p->error().empty()); - const auto module_str = p->module().to_str(); + const auto module_str = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_str, HasSubstr(R"( Assignment{ Identifier[not set]{gl_Position} @@ -357,7 +359,8 @@ TEST_F(SpvParserTest, auto p = parser(test::Assemble(assembly)); EXPECT_TRUE(p->BuildAndParseInternalModule()); EXPECT_TRUE(p->error().empty()); - const auto module_str = p->module().to_str(); + const auto module_str = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_str, HasSubstr(R"( Assignment{ MemberAccessor[not set]{ @@ -388,7 +391,8 @@ TEST_F(SpvParserTest, auto p = parser(test::Assemble(assembly)); EXPECT_TRUE(p->BuildAndParseInternalModule()); EXPECT_TRUE(p->error().empty()); - const auto module_str = p->module().to_str(); + const auto module_str = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_str, HasSubstr(R"( { Assignment{ @@ -1654,7 +1658,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ScalarSpecConstant_UsedInFunction) { FunctionEmitter fe(p.get(), *spirv_function(p.get(), 100)); EXPECT_TRUE(fe.EmitBody()) << p->error(); EXPECT_TRUE(p->error().empty()); - EXPECT_THAT(ToString(fe.ast_body()), HasSubstr(R"( + EXPECT_THAT(ToString(p->get_module(), fe.ast_body()), HasSubstr(R"( VariableConst{ x_1 none @@ -1667,7 +1671,7 @@ TEST_F(SpvParserTest, ModuleScopeVar_ScalarSpecConstant_UsedInFunction) { } } })")) - << ToString(fe.ast_body()); + << ToString(p->get_module(), fe.ast_body()); } } // namespace diff --git a/src/reader/spirv/parser_impl_test_helper.h b/src/reader/spirv/parser_impl_test_helper.h index 0a915a8b8c..0342e4725c 100644 --- a/src/reader/spirv/parser_impl_test_helper.h +++ b/src/reader/spirv/parser_impl_test_helper.h @@ -22,6 +22,7 @@ #include "gtest/gtest.h" #include "source/opt/ir_context.h" +#include "src/demangler.h" #include "src/reader/spirv/parser_impl.h" namespace tint { @@ -59,12 +60,13 @@ using SpvParserTest = SpvParserTestBase<::testing::Test>; /// Returns the string dump of a function body. /// @param body the statement in the body /// @returnss the string dump of a function body. -inline std::string ToString(const ast::BlockStatement* body) { +inline std::string ToString(const ast::Module& mod, + const ast::BlockStatement* body) { std::ostringstream outs; for (const auto* stmt : *body) { stmt->to_str(outs, 0); } - return outs.str(); + return Demangler().Demangle(mod, outs.str()); } } // namespace spirv diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 04ff79bb1c..a06ddfd958 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -2026,7 +2026,9 @@ Maybe ParserImpl::func_call_stmt() { return Failure::kErrored; return create(create( - source, create(name), std::move(params))); + source, + create(module_.RegisterSymbol(name), name), + std::move(params))); } // break_stmt @@ -2097,7 +2099,8 @@ Maybe ParserImpl::primary_expression() { } if (match(Token::Type::kIdentifier)) - return create(t.source(), t.to_str()); + return create( + t.source(), module_.RegisterSymbol(t.to_str()), t.to_str()); auto type = type_decl(); if (type.errored) @@ -2172,7 +2175,8 @@ Maybe ParserImpl::postfix_expr(ast::Expression* prefix) { return postfix_expr(create( ident.source, prefix, - create(ident.source, ident.value))); + create( + ident.source, module_.RegisterSymbol(ident.value), ident.value))); } return prefix; diff --git a/src/transform/bound_array_accessors.cc b/src/transform/bound_array_accessors.cc index 24d3ab6bd5..ba5e9541fe 100644 --- a/src/transform/bound_array_accessors.cc +++ b/src/transform/bound_array_accessors.cc @@ -135,7 +135,9 @@ ast::ArrayAccessorExpression* BoundArrayAccessors::Transform( ctx->mod->create(u32, size - 1))); auto* call_expr = ctx->mod->create( - ctx->mod->create("min"), std::move(params)); + ctx->mod->create( + ctx->mod->RegisterSymbol("min"), "min"), + std::move(params)); call_expr->set_result_type(u32); idx_expr = call_expr; diff --git a/src/transform/emit_vertex_point_size.cc b/src/transform/emit_vertex_point_size.cc index bc25edeb65..1c53e05040 100644 --- a/src/transform/emit_vertex_point_size.cc +++ b/src/transform/emit_vertex_point_size.cc @@ -67,8 +67,8 @@ Transform::Output EmitVertexPointSize::Run(ast::Module* in) { // Build the AST expression & statement for assigning pointsize one. auto* one = mod->create( mod->create(f32, 1.0f)); - auto* pointsize_ident = - mod->create(Source{}, kPointSizeVar); + auto* pointsize_ident = mod->create( + Source{}, mod->RegisterSymbol(kPointSizeVar), kPointSizeVar); auto* pointsize_assign = mod->create(pointsize_ident, one); diff --git a/src/transform/emit_vertex_point_size_test.cc b/src/transform/emit_vertex_point_size_test.cc index 57a904713b..f0d6ba8ba7 100644 --- a/src/transform/emit_vertex_point_size_test.cc +++ b/src/transform/emit_vertex_point_size_test.cc @@ -21,6 +21,7 @@ #include "src/ast/builder.h" #include "src/ast/stage_decoration.h" #include "src/ast/variable_decl_statement.h" +#include "src/demangler.h" #include "src/diagnostic/formatter.h" #include "src/transform/manager.h" @@ -85,7 +86,7 @@ TEST_F(EmitVertexPointSizeTest, VertexStageBasic) { ASSERT_FALSE(result.diagnostics.contains_errors()) << diag::Formatter().format(result.diagnostics); - auto expected = R"(Module{ + auto* expected = R"(Module{ Variable{ Decorations{ BuiltinDecoration{pointsize} @@ -94,13 +95,11 @@ TEST_F(EmitVertexPointSizeTest, VertexStageBasic) { out __f32 } - Function )" + result.module.RegisterSymbol("non_entry_a").to_str() + - R"( -> __void + Function non_entry_a -> __void () { } - Function )" + result.module.RegisterSymbol("entry").to_str() + - R"( -> __void + Function entry -> __void StageDecoration{vertex} () { @@ -116,14 +115,14 @@ TEST_F(EmitVertexPointSizeTest, VertexStageBasic) { } } } - Function )" + result.module.RegisterSymbol("non_entry_b").to_str() + - R"( -> __void + Function non_entry_b -> __void () { } } )"; - EXPECT_EQ(expected, result.module.to_str()); + EXPECT_EQ(expected, + Demangler().Demangle(result.module, result.module.to_str())); } TEST_F(EmitVertexPointSizeTest, VertexStageEmpty) { @@ -156,7 +155,7 @@ TEST_F(EmitVertexPointSizeTest, VertexStageEmpty) { ASSERT_FALSE(result.diagnostics.contains_errors()) << diag::Formatter().format(result.diagnostics); - auto expected = R"(Module{ + auto* expected = R"(Module{ Variable{ Decorations{ BuiltinDecoration{pointsize} @@ -165,13 +164,11 @@ TEST_F(EmitVertexPointSizeTest, VertexStageEmpty) { out __f32 } - Function )" + result.module.RegisterSymbol("non_entry_a").to_str() + - R"( -> __void + Function non_entry_a -> __void () { } - Function )" + result.module.RegisterSymbol("entry").to_str() + - R"( -> __void + Function entry -> __void StageDecoration{vertex} () { @@ -180,14 +177,14 @@ TEST_F(EmitVertexPointSizeTest, VertexStageEmpty) { ScalarConstructor[__f32]{1.000000} } } - Function )" + result.module.RegisterSymbol("non_entry_b").to_str() + - R"( -> __void + Function non_entry_b -> __void () { } } )"; - EXPECT_EQ(expected, result.module.to_str()); + EXPECT_EQ(expected, + Demangler().Demangle(result.module, result.module.to_str())); } TEST_F(EmitVertexPointSizeTest, NonVertexStage) { @@ -219,22 +216,21 @@ TEST_F(EmitVertexPointSizeTest, NonVertexStage) { ASSERT_FALSE(result.diagnostics.contains_errors()) << diag::Formatter().format(result.diagnostics); - auto expected = R"(Module{ - Function )" + result.module.RegisterSymbol("fragment_entry").to_str() + - R"( -> __void + auto* expected = R"(Module{ + Function fragment_entry -> __void StageDecoration{fragment} () { } - Function )" + result.module.RegisterSymbol("compute_entry").to_str() + - R"( -> __void + Function compute_entry -> __void StageDecoration{compute} () { } } )"; - EXPECT_EQ(expected, result.module.to_str()); + EXPECT_EQ(expected, + Demangler().Demangle(result.module, result.module.to_str())); } } // namespace diff --git a/src/transform/first_index_offset.cc b/src/transform/first_index_offset.cc index b398935922..ee75a77e2d 100644 --- a/src/transform/first_index_offset.cc +++ b/src/transform/first_index_offset.cc @@ -251,13 +251,16 @@ ast::VariableDeclStatement* FirstIndexOffset::CreateFirstIndexOffset( const std::string& field_name, ast::Variable* buffer_var, ast::Module* mod) { - auto* buffer = mod->create(buffer_var->name()); + auto* buffer = mod->create( + mod->RegisterSymbol(buffer_var->name()), buffer_var->name()); auto* constructor = mod->create( ast::BinaryOp::kAdd, - mod->create(kIndexOffsetPrefix + - original_name), + mod->create( + mod->RegisterSymbol(kIndexOffsetPrefix + original_name), + kIndexOffsetPrefix + original_name), mod->create( - buffer, mod->create(field_name))); + buffer, mod->create( + mod->RegisterSymbol(field_name), field_name))); auto* var = mod->create(Source{}, // source original_name, // name diff --git a/src/transform/first_index_offset_test.cc b/src/transform/first_index_offset_test.cc index 20fbb75c15..3813819cca 100644 --- a/src/transform/first_index_offset_test.cc +++ b/src/transform/first_index_offset_test.cc @@ -74,7 +74,8 @@ TEST_F(FirstIndexOffsetTest, Error_AlreadyTransformed) { void Build() override { AddBuiltinInput("vert_idx", ast::Builtin::kVertexIdx); AddFunction("test")->body()->append(create( - Source{}, create("vert_idx"))); + Source{}, create( + mod->RegisterSymbol("vert_idx"), "vert_idx"))); } }; @@ -115,7 +116,8 @@ TEST_F(FirstIndexOffsetTest, BasicModuleVertexIndex) { void Build() override { AddBuiltinInput("vert_idx", ast::Builtin::kVertexIdx); AddFunction("test")->body()->append(create( - Source{}, create("vert_idx"))); + Source{}, create( + mod->RegisterSymbol("vert_idx"), "vert_idx"))); } }; @@ -191,7 +193,8 @@ TEST_F(FirstIndexOffsetTest, BasicModuleInstanceIndex) { void Build() override { AddBuiltinInput("inst_idx", ast::Builtin::kInstanceIdx); AddFunction("test")->body()->append(create( - Source{}, create("inst_idx"))); + Source{}, create( + mod->RegisterSymbol("inst_idx"), "inst_idx"))); } }; @@ -344,11 +347,13 @@ TEST_F(FirstIndexOffsetTest, NestedCalls) { AddBuiltinInput("vert_idx", ast::Builtin::kVertexIdx); ast::Function* func1 = AddFunction("func1"); func1->body()->append(create( - Source{}, create("vert_idx"))); + Source{}, create( + mod->RegisterSymbol("vert_idx"), "vert_idx"))); ast::Function* func2 = AddFunction("func2"); func2->body()->append(create( Source{}, create( - create("func1"), + create( + mod->RegisterSymbol("func1"), "func1"), ast::ExpressionList{}))); } }; diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc index 6143d15601..05fbae5e8b 100644 --- a/src/transform/vertex_pulling.cc +++ b/src/transform/vertex_pulling.cc @@ -321,11 +321,12 @@ void VertexPulling::State::AddVertexPullingPreamble( } auto* v = it->second; + auto name = buffer_layout.step_mode == InputStepMode::kVertex + ? vertex_index_name + : instance_index_name; // Identifier to index by auto* index_identifier = mod->create( - buffer_layout.step_mode == InputStepMode::kVertex - ? vertex_index_name - : instance_index_name); + mod->RegisterSymbol(name), name); // An expression for the start of the read in the buffer in bytes auto* pos_value = mod->create( @@ -341,7 +342,8 @@ void VertexPulling::State::AddVertexPullingPreamble( block->append(set_pos_expr); block->append(mod->create( - mod->create(v->name()), + mod->create(mod->RegisterSymbol(v->name()), + v->name()), AccessByFormat(i, attribute_desc.format))); } } @@ -355,7 +357,8 @@ ast::Expression* VertexPulling::State::GenUint(uint32_t value) { } ast::Expression* VertexPulling::State::CreatePullingPositionIdent() { - return mod->create(kPullingPosVarName); + return mod->create( + mod->RegisterSymbol(kPullingPosVarName), kPullingPosVarName); } ast::Expression* VertexPulling::State::AccessByFormat(uint32_t buffer, @@ -392,10 +395,13 @@ ast::Expression* VertexPulling::State::AccessU32(uint32_t buffer, // by dividing. Then, that element is going to be read, and if needed, // unpacked into an appropriate variable. All reads should end up here as a // base case. + auto vbuf_name = GetVertexBufferName(buffer); return mod->create( mod->create( - mod->create(GetVertexBufferName(buffer)), - mod->create(kStructBufferName)), + mod->create(mod->RegisterSymbol(vbuf_name), + vbuf_name), + mod->create( + mod->RegisterSymbol(kStructBufferName), kStructBufferName)), mod->create(ast::BinaryOp::kDivide, pos, GenUint(4))); } diff --git a/src/transform/vertex_pulling_test.cc b/src/transform/vertex_pulling_test.cc index c0279201dd..8d950d5446 100644 --- a/src/transform/vertex_pulling_test.cc +++ b/src/transform/vertex_pulling_test.cc @@ -24,7 +24,7 @@ #include "src/ast/type/f32_type.h" #include "src/ast/type/i32_type.h" #include "src/ast/type/void_type.h" -#include "src/ast/variable.h" +#include "src/demangler.h" #include "src/diagnostic/formatter.h" #include "src/transform/manager.h" #include "src/type_determiner.h" @@ -195,8 +195,7 @@ TEST_F(VertexPullingTest, OneAttribute) { storage_buffer __struct_TintVertexData } - Function )" + result.module.GetSymbol("main").to_str() + - R"( -> __void + Function main -> __void StageDecoration{vertex} () { @@ -240,7 +239,7 @@ TEST_F(VertexPullingTest, OneAttribute) { } } )", - result.module.to_str()); + Demangler().Demangle(result.module, result.module.to_str())); } TEST_F(VertexPullingTest, OneInstancedAttribute) { @@ -283,8 +282,7 @@ TEST_F(VertexPullingTest, OneInstancedAttribute) { storage_buffer __struct_TintVertexData } - Function )" + result.module.GetSymbol("main").to_str() + - R"( -> __void + Function main -> __void StageDecoration{vertex} () { @@ -328,7 +326,7 @@ TEST_F(VertexPullingTest, OneInstancedAttribute) { } } )", - result.module.to_str()); + Demangler().Demangle(result.module, result.module.to_str())); } TEST_F(VertexPullingTest, OneAttributeDifferentOutputSet) { @@ -371,8 +369,7 @@ TEST_F(VertexPullingTest, OneAttributeDifferentOutputSet) { storage_buffer __struct_TintVertexData } - Function )" + result.module.GetSymbol("main").to_str() + - R"( -> __void + Function main -> __void StageDecoration{vertex} () { @@ -416,7 +413,7 @@ TEST_F(VertexPullingTest, OneAttributeDifferentOutputSet) { } } )", - result.module.to_str()); + Demangler().Demangle(result.module, result.module.to_str())); } // We expect the transform to use an existing builtin variables if it finds them @@ -510,8 +507,7 @@ TEST_F(VertexPullingTest, ExistingVertexIndexAndInstanceIndex) { storage_buffer __struct_TintVertexData } - Function )" + result.module.GetSymbol("main").to_str() + - R"( -> __void + Function main -> __void StageDecoration{vertex} () { @@ -583,7 +579,7 @@ TEST_F(VertexPullingTest, ExistingVertexIndexAndInstanceIndex) { } } )", - result.module.to_str()); + Demangler().Demangle(result.module, result.module.to_str())); } TEST_F(VertexPullingTest, TwoAttributesSameBuffer) { @@ -636,8 +632,7 @@ TEST_F(VertexPullingTest, TwoAttributesSameBuffer) { storage_buffer __struct_TintVertexData } - Function )" + result.module.GetSymbol("main").to_str() + - R"( -> __void + Function main -> __void StageDecoration{vertex} () { @@ -767,7 +762,7 @@ TEST_F(VertexPullingTest, TwoAttributesSameBuffer) { } } )", - result.module.to_str()); + Demangler().Demangle(result.module, result.module.to_str())); } TEST_F(VertexPullingTest, FloatVectorAttributes) { @@ -847,8 +842,7 @@ TEST_F(VertexPullingTest, FloatVectorAttributes) { storage_buffer __struct_TintVertexData } - Function )" + result.module.GetSymbol("main").to_str() + - R"( -> __void + Function main -> __void StageDecoration{vertex} () { @@ -1071,7 +1065,7 @@ TEST_F(VertexPullingTest, FloatVectorAttributes) { } } )", - result.module.to_str()); + Demangler().Demangle(result.module, result.module.to_str())); } } // namespace diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index a45e8961ec..1422aabb4a 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -351,7 +351,9 @@ TEST_F(TypeDeterminerTest, Stmt_Call) { ast::ExpressionList call_params; auto* expr = create( - create("my_func"), call_params); + create(mod->RegisterSymbol("my_func"), + "my_func"), + call_params); ast::CallStatement call(expr); EXPECT_TRUE(td()->DetermineResultType(&call)); @@ -364,10 +366,10 @@ TEST_F(TypeDeterminerTest, Stmt_Call_undeclared) { // fn func() -> void { return; } ast::type::F32 f32; ast::ExpressionList call_params; - auto* call_expr = - create(create( - Source{Source::Location{12, 34}}, "func"), - call_params); + auto* call_expr = create( + create(Source{Source::Location{12, 34}}, + mod->RegisterSymbol("func"), "func"), + call_params); ast::VariableList params0; auto* main_body = create(); main_body->append(create(call_expr)); @@ -457,7 +459,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) { // Register the global EXPECT_TRUE(td()->Determine()); - ast::ArrayAccessorExpression acc(create("my_var"), + ast::ArrayAccessorExpression acc(create( + mod->RegisterSymbol("my_var"), "my_var"), idx); EXPECT_TRUE(td()->DetermineResultType(&acc)); ASSERT_NE(acc.result_type(), nullptr); @@ -488,7 +491,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) { // Register the global EXPECT_TRUE(td()->Determine()); - ast::ArrayAccessorExpression acc(create("my_var"), + ast::ArrayAccessorExpression acc(create( + mod->RegisterSymbol("my_var"), "my_var"), idx); EXPECT_TRUE(td()->DetermineResultType(&acc)); ASSERT_NE(acc.result_type(), nullptr); @@ -518,7 +522,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) { // Register the global EXPECT_TRUE(td()->Determine()); - ast::ArrayAccessorExpression acc(create("my_var"), + ast::ArrayAccessorExpression acc(create( + mod->RegisterSymbol("my_var"), "my_var"), idx); EXPECT_TRUE(td()->DetermineResultType(&acc)); ASSERT_NE(acc.result_type(), nullptr); @@ -546,7 +551,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix) { // Register the global EXPECT_TRUE(td()->Determine()); - ast::ArrayAccessorExpression acc(create("my_var"), + ast::ArrayAccessorExpression acc(create( + mod->RegisterSymbol("my_var"), "my_var"), idx); EXPECT_TRUE(td()->DetermineResultType(&acc)); ASSERT_NE(acc.result_type(), nullptr); @@ -581,7 +587,9 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix_BothDimensions) { ast::ArrayAccessorExpression acc( create( - create("my_var"), idx1), + create(mod->RegisterSymbol("my_var"), + "my_var"), + idx1), idx2); EXPECT_TRUE(td()->DetermineResultType(&acc)); @@ -612,7 +620,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Vector) { // Register the global EXPECT_TRUE(td()->Determine()); - ast::ArrayAccessorExpression acc(create("my_var"), + ast::ArrayAccessorExpression acc(create( + mod->RegisterSymbol("my_var"), "my_var"), idx); EXPECT_TRUE(td()->DetermineResultType(&acc)); ASSERT_NE(acc.result_type(), nullptr); @@ -624,8 +633,9 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Vector) { TEST_F(TypeDeterminerTest, Expr_Bitcast) { ast::type::F32 f32; - ast::BitcastExpression bitcast(&f32, - create("name")); + ast::BitcastExpression bitcast( + &f32, + create(mod->RegisterSymbol("name"), "name")); ast::Variable v(Source{}, "name", ast::StorageClass::kPrivate, &f32, false, nullptr, ast::VariableDecorationList{}); @@ -649,7 +659,8 @@ TEST_F(TypeDeterminerTest, Expr_Call) { EXPECT_TRUE(td()->Determine()); ast::ExpressionList call_params; - ast::CallExpression call(create("my_func"), + ast::CallExpression call(create( + mod->RegisterSymbol("my_func"), "my_func"), call_params); EXPECT_TRUE(td()->DetermineResultType(&call)); ASSERT_NE(call.result_type(), nullptr); @@ -674,7 +685,8 @@ TEST_F(TypeDeterminerTest, Expr_Call_WithParams) { auto* param = call_params.back(); - ast::CallExpression call(create("my_func"), + ast::CallExpression call(create( + mod->RegisterSymbol("my_func"), "my_func"), call_params); EXPECT_TRUE(td()->DetermineResultType(&call)); ASSERT_NE(param->result_type(), nullptr); @@ -691,8 +703,9 @@ TEST_F(TypeDeterminerTest, Expr_Call_Intrinsic) { call_params.push_back(create( create(&f32, 2.4))); - ast::CallExpression call(create("round"), - call_params); + ast::CallExpression call( + create(mod->RegisterSymbol("round"), "round"), + call_params); EXPECT_TRUE(td()->DetermineResultType(&call)); ASSERT_NE(call.result_type(), nullptr); @@ -703,7 +716,8 @@ TEST_F(TypeDeterminerTest, Expr_Cast) { ast::type::F32 f32; ast::ExpressionList params; - params.push_back(create("name")); + params.push_back( + create(mod->RegisterSymbol("name"), "name")); ast::TypeConstructorExpression cast(&f32, params); ast::Variable v(Source{}, "name", ast::StorageClass::kPrivate, &f32, false, @@ -761,7 +775,7 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalVariable) { // Register the global EXPECT_TRUE(td()->Determine()); - ast::IdentifierExpression ident("my_var"); + ast::IdentifierExpression ident(mod->RegisterSymbol("my_var"), "my_var"); EXPECT_TRUE(td()->DetermineResultType(&ident)); ASSERT_NE(ident.result_type(), nullptr); EXPECT_TRUE(ident.result_type()->Is()); @@ -785,7 +799,7 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalConstant) { // Register the global EXPECT_TRUE(td()->Determine()); - ast::IdentifierExpression ident("my_var"); + ast::IdentifierExpression ident(mod->RegisterSymbol("my_var"), "my_var"); EXPECT_TRUE(td()->DetermineResultType(&ident)); ASSERT_NE(ident.result_type(), nullptr); EXPECT_TRUE(ident.result_type()->Is()); @@ -794,7 +808,8 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalConstant) { TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable_Const) { ast::type::F32 f32; - auto* my_var = create("my_var"); + auto* my_var = create( + mod->RegisterSymbol("my_var"), "my_var"); auto* var = create(Source{}, // source @@ -808,7 +823,8 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable_Const) { auto* body = create(); body->append(create(var)); body->append(create( - my_var, create("my_var"))); + my_var, create(mod->RegisterSymbol("my_var"), + "my_var"))); ast::Function f(Source{}, mod->RegisterSymbol("my_func"), "my_func", {}, &f32, body, ast::FunctionDecorationList{}); @@ -822,7 +838,8 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable_Const) { TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable) { ast::type::F32 f32; - auto* my_var = create("my_var"); + auto* my_var = create( + mod->RegisterSymbol("my_var"), "my_var"); auto* body = create(); body->append(create( @@ -835,7 +852,8 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable) { ast::VariableDecorationList{}))); // decorations body->append(create( - my_var, create("my_var"))); + my_var, create(mod->RegisterSymbol("my_var"), + "my_var"))); ast::Function f(Source{}, mod->RegisterSymbol("myfunc"), "my_func", {}, &f32, body, ast::FunctionDecorationList{}); @@ -854,7 +872,8 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) { ast::type::F32 f32; ast::type::Pointer ptr(&f32, ast::StorageClass::kFunction); - auto* my_var = create("my_var"); + auto* my_var = create( + mod->RegisterSymbol("my_var"), "my_var"); auto* body = create(); body->append(create( @@ -867,7 +886,8 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) { ast::VariableDecorationList{}))); // decorations body->append(create( - my_var, create("my_var"))); + my_var, create(mod->RegisterSymbol("my_var"), + "my_var"))); ast::Function f(Source{}, mod->RegisterSymbol("my_func"), "my_func", {}, &f32, body, ast::FunctionDecorationList{}); @@ -894,14 +914,14 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Function) { // Register the function EXPECT_TRUE(td()->Determine()); - ast::IdentifierExpression ident("my_func"); + ast::IdentifierExpression ident(mod->RegisterSymbol("my_func"), "my_func"); EXPECT_TRUE(td()->DetermineResultType(&ident)); ASSERT_NE(ident.result_type(), nullptr); EXPECT_TRUE(ident.result_type()->Is()); } TEST_F(TypeDeterminerTest, Expr_Identifier_Unknown) { - ast::IdentifierExpression a("a"); + ast::IdentifierExpression a(mod->RegisterSymbol("a"), "a"); EXPECT_FALSE(td()->DetermineResultType(&a)); } @@ -958,17 +978,25 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) { ast::VariableList params; auto* body = create(); body->append(create( - create("out_var"), - create("in_var"))); + create(mod->RegisterSymbol("out_var"), + "out_var"), + create(mod->RegisterSymbol("in_var"), + "in_var"))); body->append(create( - create("wg_var"), - create("wg_var"))); + create(mod->RegisterSymbol("wg_var"), + "wg_var"), + create(mod->RegisterSymbol("wg_var"), + "wg_var"))); body->append(create( - create("sb_var"), - create("sb_var"))); + create(mod->RegisterSymbol("sb_var"), + "sb_var"), + create(mod->RegisterSymbol("sb_var"), + "sb_var"))); body->append(create( - create("priv_var"), - create("priv_var"))); + create(mod->RegisterSymbol("priv_var"), + "priv_var"), + create(mod->RegisterSymbol("priv_var"), + "priv_var"))); auto* func = create(Source{}, mod->RegisterSymbol("my_func"), "my_func", params, &f32, body, ast::FunctionDecorationList{}); @@ -1039,17 +1067,25 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) { auto* body = create(); body->append(create( - create("out_var"), - create("in_var"))); + create(mod->RegisterSymbol("out_var"), + "out_var"), + create(mod->RegisterSymbol("in_var"), + "in_var"))); body->append(create( - create("wg_var"), - create("wg_var"))); + create(mod->RegisterSymbol("wg_var"), + "wg_var"), + create(mod->RegisterSymbol("wg_var"), + "wg_var"))); body->append(create( - create("sb_var"), - create("sb_var"))); + create(mod->RegisterSymbol("sb_var"), + "sb_var"), + create(mod->RegisterSymbol("sb_var"), + "sb_var"))); body->append(create( - create("priv_var"), - create("priv_var"))); + create(mod->RegisterSymbol("priv_var"), + "priv_var"), + create(mod->RegisterSymbol("priv_var"), + "priv_var"))); ast::VariableList params; auto* func = create(Source{}, mod->RegisterSymbol("my_func"), "my_func", @@ -1059,9 +1095,12 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) { body = create(); body->append(create( - create("out_var"), - create(create("my_func"), - ast::ExpressionList{}))); + create(mod->RegisterSymbol("out_var"), + "out_var"), + create( + create(mod->RegisterSymbol("my_func"), + "my_func"), + ast::ExpressionList{}))); auto* func2 = create(Source{}, mod->RegisterSymbol("func"), "func", params, &f32, body, ast::FunctionDecorationList{}); @@ -1095,7 +1134,7 @@ TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) { auto* body = create(); body->append(create(var)); body->append(create( - create("var"), + create(mod->RegisterSymbol("var"), "var"), create( create(&f32, 1.f)))); @@ -1143,8 +1182,10 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct) { // Register the global EXPECT_TRUE(td()->Determine()); - auto* ident = create("my_struct"); - auto* mem_ident = create("second_member"); + auto* ident = create( + mod->RegisterSymbol("my_struct"), "my_struct"); + auto* mem_ident = create( + mod->RegisterSymbol("second_member"), "second_member"); ast::MemberAccessorExpression mem(ident, mem_ident); EXPECT_TRUE(td()->DetermineResultType(&mem)); @@ -1183,8 +1224,10 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) { // Register the global EXPECT_TRUE(td()->Determine()); - auto* ident = create("my_struct"); - auto* mem_ident = create("second_member"); + auto* ident = create( + mod->RegisterSymbol("my_struct"), "my_struct"); + auto* mem_ident = create( + mod->RegisterSymbol("second_member"), "second_member"); ast::MemberAccessorExpression mem(ident, mem_ident); EXPECT_TRUE(td()->DetermineResultType(&mem)); @@ -1212,8 +1255,10 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle) { // Register the global EXPECT_TRUE(td()->Determine()); - auto* ident = create("my_vec"); - auto* swizzle = create("xy"); + auto* ident = create(mod->RegisterSymbol("my_vec"), + "my_vec"); + auto* swizzle = + create(mod->RegisterSymbol("xy"), "xy"); ast::MemberAccessorExpression mem(ident, swizzle); EXPECT_TRUE(td()->DetermineResultType(&mem)) << td()->error(); @@ -1241,8 +1286,10 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle_SingleElement) { // Register the global EXPECT_TRUE(td()->Determine()); - auto* ident = create("my_vec"); - auto* swizzle = create("x"); + auto* ident = create(mod->RegisterSymbol("my_vec"), + "my_vec"); + auto* swizzle = + create(mod->RegisterSymbol("x"), "x"); ast::MemberAccessorExpression mem(ident, swizzle); EXPECT_TRUE(td()->DetermineResultType(&mem)) << td()->error(); @@ -1312,12 +1359,16 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) { // Register the global EXPECT_TRUE(td()->Determine()); - auto* ident = create("c"); - auto* mem_ident = create("mem"); - auto* foo_ident = create("foo"); + auto* ident = + create(mod->RegisterSymbol("c"), "c"); + auto* mem_ident = + create(mod->RegisterSymbol("mem"), "mem"); + auto* foo_ident = + create(mod->RegisterSymbol("foo"), "foo"); auto* idx = create( create(&i32, 0)); - auto* swizzle = create("yx"); + auto* swizzle = + create(mod->RegisterSymbol("yx"), "yx"); ast::MemberAccessorExpression mem( create( @@ -1353,8 +1404,9 @@ TEST_P(Expr_Binary_BitwiseTest, Scalar) { // Register the global ASSERT_TRUE(td()->Determine()) << td()->error(); - ast::BinaryExpression expr(op, create("val"), - create("val")); + ast::BinaryExpression expr( + op, create(mod->RegisterSymbol("val"), "val"), + create(mod->RegisterSymbol("val"), "val")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1380,8 +1432,9 @@ TEST_P(Expr_Binary_BitwiseTest, Vector) { // Register the global ASSERT_TRUE(td()->Determine()) << td()->error(); - ast::BinaryExpression expr(op, create("val"), - create("val")); + ast::BinaryExpression expr( + op, create(mod->RegisterSymbol("val"), "val"), + create(mod->RegisterSymbol("val"), "val")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1423,8 +1476,9 @@ TEST_P(Expr_Binary_LogicalTest, Scalar) { // Register the global ASSERT_TRUE(td()->Determine()) << td()->error(); - ast::BinaryExpression expr(op, create("val"), - create("val")); + ast::BinaryExpression expr( + op, create(mod->RegisterSymbol("val"), "val"), + create(mod->RegisterSymbol("val"), "val")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1450,8 +1504,9 @@ TEST_P(Expr_Binary_LogicalTest, Vector) { // Register the global ASSERT_TRUE(td()->Determine()) << td()->error(); - ast::BinaryExpression expr(op, create("val"), - create("val")); + ast::BinaryExpression expr( + op, create(mod->RegisterSymbol("val"), "val"), + create(mod->RegisterSymbol("val"), "val")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1486,8 +1541,9 @@ TEST_P(Expr_Binary_CompareTest, Scalar) { // Register the global ASSERT_TRUE(td()->Determine()) << td()->error(); - ast::BinaryExpression expr(op, create("val"), - create("val")); + ast::BinaryExpression expr( + op, create(mod->RegisterSymbol("val"), "val"), + create(mod->RegisterSymbol("val"), "val")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1513,8 +1569,9 @@ TEST_P(Expr_Binary_CompareTest, Vector) { // Register the global ASSERT_TRUE(td()->Determine()) << td()->error(); - ast::BinaryExpression expr(op, create("val"), - create("val")); + ast::BinaryExpression expr( + op, create(mod->RegisterSymbol("val"), "val"), + create(mod->RegisterSymbol("val"), "val")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1550,9 +1607,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Scalar) { // Register the global ASSERT_TRUE(td()->Determine()) << td()->error(); - ast::BinaryExpression expr(ast::BinaryOp::kMultiply, - create("val"), - create("val")); + ast::BinaryExpression expr( + ast::BinaryOp::kMultiply, + create(mod->RegisterSymbol("val"), "val"), + create(mod->RegisterSymbol("val"), "val")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1586,8 +1644,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Scalar) { ASSERT_TRUE(td()->Determine()) << td()->error(); ast::BinaryExpression expr(ast::BinaryOp::kMultiply, - create("vector"), - create("scalar")); + create( + mod->RegisterSymbol("vector"), "vector"), + create( + mod->RegisterSymbol("scalar"), "scalar")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1626,8 +1686,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Vector) { ASSERT_TRUE(td()->Determine()) << td()->error(); ast::BinaryExpression expr(ast::BinaryOp::kMultiply, - create("scalar"), - create("vector")); + create( + mod->RegisterSymbol("scalar"), "scalar"), + create( + mod->RegisterSymbol("vector"), "vector")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1657,8 +1719,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Vector) { ASSERT_TRUE(td()->Determine()) << td()->error(); ast::BinaryExpression expr(ast::BinaryOp::kMultiply, - create("vector"), - create("vector")); + create( + mod->RegisterSymbol("vector"), "vector"), + create( + mod->RegisterSymbol("vector"), "vector")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1697,8 +1761,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Scalar) { ASSERT_TRUE(td()->Determine()) << td()->error(); ast::BinaryExpression expr(ast::BinaryOp::kMultiply, - create("matrix"), - create("scalar")); + create( + mod->RegisterSymbol("matrix"), "matrix"), + create( + mod->RegisterSymbol("scalar"), "scalar")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1737,8 +1803,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Matrix) { ASSERT_TRUE(td()->Determine()) << td()->error(); ast::BinaryExpression expr(ast::BinaryOp::kMultiply, - create("scalar"), - create("matrix")); + create( + mod->RegisterSymbol("scalar"), "scalar"), + create( + mod->RegisterSymbol("matrix"), "matrix")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1778,8 +1846,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Vector) { ASSERT_TRUE(td()->Determine()) << td()->error(); ast::BinaryExpression expr(ast::BinaryOp::kMultiply, - create("matrix"), - create("vector")); + create( + mod->RegisterSymbol("matrix"), "matrix"), + create( + mod->RegisterSymbol("vector"), "vector")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1819,8 +1889,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Matrix) { ASSERT_TRUE(td()->Determine()) << td()->error(); ast::BinaryExpression expr(ast::BinaryOp::kMultiply, - create("vector"), - create("matrix")); + create( + mod->RegisterSymbol("vector"), "vector"), + create( + mod->RegisterSymbol("matrix"), "matrix")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1860,8 +1932,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Matrix) { ASSERT_TRUE(td()->Determine()) << td()->error(); ast::BinaryExpression expr(ast::BinaryOp::kMultiply, - create("mat4x3"), - create("mat3x4")); + create( + mod->RegisterSymbol("mat4x3"), "mat4x3"), + create( + mod->RegisterSymbol("mat3x4"), "mat3x4")); ASSERT_TRUE(td()->DetermineResultType(&expr)) << td()->error(); ASSERT_NE(expr.result_type(), nullptr); @@ -1893,10 +1967,12 @@ TEST_P(IntrinsicDerivativeTest, Scalar) { EXPECT_TRUE(td()->Determine()); ast::ExpressionList call_params; - call_params.push_back(create("ident")); + call_params.push_back( + create(mod->RegisterSymbol("ident"), "ident")); - ast::CallExpression expr(create(name), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol(name), name), + call_params); EXPECT_TRUE(td()->DetermineResultType(&expr)); ASSERT_NE(expr.result_type(), nullptr); @@ -1923,10 +1999,12 @@ TEST_P(IntrinsicDerivativeTest, Vector) { EXPECT_TRUE(td()->Determine()); ast::ExpressionList call_params; - call_params.push_back(create("ident")); + call_params.push_back( + create(mod->RegisterSymbol("ident"), "ident")); - ast::CallExpression expr(create(name), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol(name), name), + call_params); EXPECT_TRUE(td()->DetermineResultType(&expr)); ASSERT_NE(expr.result_type(), nullptr); @@ -1948,8 +2026,9 @@ TEST_P(IntrinsicDerivativeTest, MissingParam) { EXPECT_TRUE(td()->Determine()); ast::ExpressionList call_params; - ast::CallExpression expr(create(name), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol(name), name), + call_params); EXPECT_FALSE(td()->DetermineResultType(&expr)); EXPECT_EQ(td()->error(), "incorrect number of parameters for " + name); } @@ -1983,11 +2062,14 @@ TEST_P(IntrinsicDerivativeTest, ToomManyParams) { EXPECT_TRUE(td()->Determine()); ast::ExpressionList call_params; - call_params.push_back(create("ident1")); - call_params.push_back(create("ident2")); + call_params.push_back(create( + mod->RegisterSymbol("ident1"), "ident1")); + call_params.push_back(create( + mod->RegisterSymbol("ident2"), "ident2")); - ast::CallExpression expr(create(name), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol(name), name), + call_params); EXPECT_FALSE(td()->DetermineResultType(&expr)); EXPECT_EQ(td()->error(), "incorrect number of parameters for " + name); } @@ -2021,10 +2103,12 @@ TEST_P(Intrinsic, Test) { mod->AddGlobalVariable(var); ast::ExpressionList call_params; - call_params.push_back(create("my_var")); + call_params.push_back(create( + mod->RegisterSymbol("my_var"), "my_var")); - ast::CallExpression expr(create(name), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol(name), name), + call_params); // Register the variable EXPECT_TRUE(td()->Determine()); @@ -2055,10 +2139,12 @@ TEST_P(Intrinsic_FloatMethod, Vector) { mod->AddGlobalVariable(var); ast::ExpressionList call_params; - call_params.push_back(create("my_var")); + call_params.push_back(create( + mod->RegisterSymbol("my_var"), "my_var")); - ast::CallExpression expr(create(name), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol(name), name), + call_params); // Register the variable EXPECT_TRUE(td()->Determine()); @@ -2089,10 +2175,12 @@ TEST_P(Intrinsic_FloatMethod, Scalar) { mod->AddGlobalVariable(var); ast::ExpressionList call_params; - call_params.push_back(create("my_var")); + call_params.push_back(create( + mod->RegisterSymbol("my_var"), "my_var")); - ast::CallExpression expr(create(name), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol(name), name), + call_params); // Register the variable EXPECT_TRUE(td()->Determine()); @@ -2117,8 +2205,9 @@ TEST_P(Intrinsic_FloatMethod, MissingParam) { mod->AddGlobalVariable(var); ast::ExpressionList call_params; - ast::CallExpression expr(create(name), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol(name), name), + call_params); // Register the variable EXPECT_TRUE(td()->Determine()); @@ -2142,11 +2231,14 @@ TEST_P(Intrinsic_FloatMethod, TooManyParams) { mod->AddGlobalVariable(var); ast::ExpressionList call_params; - call_params.push_back(create("my_var")); - call_params.push_back(create("my_var")); + call_params.push_back(create( + mod->RegisterSymbol("my_var"), "my_var")); + call_params.push_back(create( + mod->RegisterSymbol("my_var"), "my_var")); - ast::CallExpression expr(create(name), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol(name), name), + call_params); // Register the variable EXPECT_TRUE(td()->Determine()); @@ -2216,7 +2308,8 @@ class Intrinsic_TextureOperation nullptr, // constructor ast::VariableDecorationList{}); // decorations mod->AddGlobalVariable(var); - call_params->push_back(create(name)); + call_params->push_back( + create(mod->RegisterSymbol(name), name)); } std::unique_ptr subtype(Texture type) { @@ -2248,8 +2341,10 @@ TEST_P(Intrinsic_StorageTextureOperation, TextureLoadRo) { add_call_param("coords", coords_type.get(), &call_params); add_call_param("lod", &i32, &call_params); - ast::CallExpression expr(create("textureLoad"), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol("textureLoad"), + "textureLoad"), + call_params); EXPECT_TRUE(td()->Determine()); EXPECT_TRUE(td()->DetermineResultType(&expr)); @@ -2326,8 +2421,10 @@ TEST_P(Intrinsic_SampledTextureOperation, TextureLoadSampled) { add_call_param("coords", coords_type.get(), &call_params); add_call_param("lod", &i32, &call_params); - ast::CallExpression expr(create("textureLoad"), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol("textureLoad"), + "textureLoad"), + call_params); EXPECT_TRUE(td()->Determine()); EXPECT_TRUE(td()->DetermineResultType(&expr)); @@ -2377,11 +2474,14 @@ TEST_F(TypeDeterminerTest, Intrinsic_Dot) { mod->AddGlobalVariable(var); ast::ExpressionList call_params; - call_params.push_back(create("my_var")); - call_params.push_back(create("my_var")); + call_params.push_back(create( + mod->RegisterSymbol("my_var"), "my_var")); + call_params.push_back(create( + mod->RegisterSymbol("my_var"), "my_var")); - ast::CallExpression expr(create("dot"), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol("dot"), "dot"), + call_params); // Register the variable EXPECT_TRUE(td()->Determine()); @@ -2416,11 +2516,15 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select) { mod->AddGlobalVariable(bool_var); ast::ExpressionList call_params; - call_params.push_back(create("my_var")); - call_params.push_back(create("my_var")); - call_params.push_back(create("bool_var")); + call_params.push_back(create( + mod->RegisterSymbol("my_var"), "my_var")); + call_params.push_back(create( + mod->RegisterSymbol("my_var"), "my_var")); + call_params.push_back(create( + mod->RegisterSymbol("bool_var"), "bool_var")); - ast::CallExpression expr(create("select"), + ast::CallExpression expr(create( + mod->RegisterSymbol("select"), "select"), call_params); // Register the variable @@ -2450,9 +2554,11 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select_TooFewParams) { mod->AddGlobalVariable(var); ast::ExpressionList call_params; - call_params.push_back(create("v")); + call_params.push_back( + create(mod->RegisterSymbol("v"), "v")); - ast::CallExpression expr(create("select"), + ast::CallExpression expr(create( + mod->RegisterSymbol("select"), "select"), call_params); // Register the variable @@ -2477,12 +2583,17 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select_TooManyParams) { mod->AddGlobalVariable(var); ast::ExpressionList call_params; - call_params.push_back(create("v")); - call_params.push_back(create("v")); - call_params.push_back(create("v")); - call_params.push_back(create("v")); + call_params.push_back( + create(mod->RegisterSymbol("v"), "v")); + call_params.push_back( + create(mod->RegisterSymbol("v"), "v")); + call_params.push_back( + create(mod->RegisterSymbol("v"), "v")); + call_params.push_back( + create(mod->RegisterSymbol("v"), "v")); - ast::CallExpression expr(create("select"), + ast::CallExpression expr(create( + mod->RegisterSymbol("select"), "select"), call_params); // Register the variable @@ -2517,11 +2628,15 @@ TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct) { mod->AddGlobalVariable(var2); ast::ExpressionList call_params; - call_params.push_back(create("v3")); - call_params.push_back(create("v2")); + call_params.push_back( + create(mod->RegisterSymbol("v3"), "v3")); + call_params.push_back( + create(mod->RegisterSymbol("v2"), "v2")); - ast::CallExpression expr(create("outerProduct"), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol("outerProduct"), + "outerProduct"), + call_params); // Register the variable EXPECT_TRUE(td()->Determine()); @@ -2552,10 +2667,13 @@ TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct_TooFewParams) { mod->AddGlobalVariable(var2); ast::ExpressionList call_params; - call_params.push_back(create("v2")); + call_params.push_back( + create(mod->RegisterSymbol("v2"), "v2")); - ast::CallExpression expr(create("outerProduct"), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol("outerProduct"), + "outerProduct"), + call_params); // Register the variable EXPECT_TRUE(td()->Determine()); @@ -2579,12 +2697,17 @@ TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct_TooManyParams) { mod->AddGlobalVariable(var2); ast::ExpressionList call_params; - call_params.push_back(create("v2")); - call_params.push_back(create("v2")); - call_params.push_back(create("v2")); + call_params.push_back( + create(mod->RegisterSymbol("v2"), "v2")); + call_params.push_back( + create(mod->RegisterSymbol("v2"), "v2")); + call_params.push_back( + create(mod->RegisterSymbol("v2"), "v2")); - ast::CallExpression expr(create("outerProduct"), - call_params); + ast::CallExpression expr( + create(mod->RegisterSymbol("outerProduct"), + "outerProduct"), + call_params); // Register the variable EXPECT_TRUE(td()->Determine()); @@ -2613,7 +2736,8 @@ TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) { // Register the global EXPECT_TRUE(td()->Determine()); - ast::UnaryOpExpression der(op, create("ident")); + ast::UnaryOpExpression der(op, create( + mod->RegisterSymbol("ident"), "ident")); EXPECT_TRUE(td()->DetermineResultType(&der)); ASSERT_NE(der.result_type(), nullptr); ASSERT_TRUE(der.result_type()->Is()); @@ -2714,7 +2838,7 @@ using IntrinsicDataTest = TypeDeterminerTestWithParam; TEST_P(IntrinsicDataTest, Lookup) { auto param = GetParam(); - ast::IdentifierExpression ident(param.name); + ast::IdentifierExpression ident(mod->RegisterSymbol(param.name), param.name); EXPECT_TRUE(td()->SetIntrinsicIfNeeded(&ident)); EXPECT_EQ(ident.intrinsic(), param.intrinsic); EXPECT_TRUE(ident.IsIntrinsic()); @@ -2795,7 +2919,8 @@ INSTANTIATE_TEST_SUITE_P( IntrinsicData{"trunc", ast::Intrinsic::kTrunc})); TEST_F(TypeDeterminerTest, IntrinsicNotSetIfNotMatched) { - ast::IdentifierExpression ident("not_intrinsic"); + ast::IdentifierExpression ident(mod->RegisterSymbol("not_intrinsic"), + "not_intrinsic"); EXPECT_FALSE(td()->SetIntrinsicIfNeeded(&ident)); EXPECT_EQ(ident.intrinsic(), ast::Intrinsic::kNone); EXPECT_FALSE(ident.IsIntrinsic()); @@ -2811,7 +2936,8 @@ TEST_P(ImportData_SingleParamTest, Scalar) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -2837,7 +2963,8 @@ TEST_P(ImportData_SingleParamTest, Vector) { ast::ExpressionList params; params.push_back(create(&vec, vals)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -2856,7 +2983,8 @@ TEST_P(ImportData_SingleParamTest, Error_Integer) { params.push_back(create( create(&i32, 1))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -2870,7 +2998,8 @@ TEST_P(ImportData_SingleParamTest, Error_NoParams) { ast::ExpressionList params; - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -2890,7 +3019,8 @@ TEST_P(ImportData_SingleParamTest, Error_MultipleParams) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -2935,7 +3065,8 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Float_Scalar) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -2961,7 +3092,8 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Float_Vector) { ast::ExpressionList params; params.push_back(create(&vec, vals)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -2980,7 +3112,8 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Sint_Scalar) { params.push_back(create( create(&i32, -11))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -3006,7 +3139,8 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Sint_Vector) { ast::ExpressionList params; params.push_back(create(&vec, vals)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -3025,7 +3159,8 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Uint_Scalar) { params.push_back(create( create(&u32, 1))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -3051,7 +3186,8 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Uint_Vector) { ast::ExpressionList params; params.push_back(create(&vec, vals)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -3070,7 +3206,8 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Error_Bool) { params.push_back(create( create(&bool_type, false))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3084,7 +3221,8 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Error_NoParams) { ast::ExpressionList params; - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3104,7 +3242,8 @@ TEST_P(ImportData_SingleParam_FloatOrInt_Test, Error_MultipleParams) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3126,7 +3265,8 @@ TEST_F(TypeDeterminerTest, ImportData_Length_Scalar) { ASSERT_TRUE(td()->DetermineResultType(params)) << td()->error(); - auto* ident = create("length"); + auto* ident = create(mod->RegisterSymbol("length"), + "length"); ast::CallExpression call(ident, params); @@ -3150,7 +3290,8 @@ TEST_F(TypeDeterminerTest, ImportData_Length_FloatVector) { ast::ExpressionList params; params.push_back(create(&vec, vals)); - auto* ident = create("length"); + auto* ident = create(mod->RegisterSymbol("length"), + "length"); ast::CallExpression call(ident, params); @@ -3166,7 +3307,8 @@ TEST_F(TypeDeterminerTest, ImportData_Length_Error_Integer) { params.push_back(create( create(&i32, 1))); - auto* ident = create("length"); + auto* ident = create(mod->RegisterSymbol("length"), + "length"); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3178,7 +3320,8 @@ TEST_F(TypeDeterminerTest, ImportData_Length_Error_Integer) { TEST_F(TypeDeterminerTest, ImportData_Length_Error_NoParams) { ast::ExpressionList params; - auto* ident = create("length"); + auto* ident = create(mod->RegisterSymbol("length"), + "length"); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3196,7 +3339,8 @@ TEST_F(TypeDeterminerTest, ImportData_Length_Error_MultipleParams) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create("length"); + auto* ident = create(mod->RegisterSymbol("length"), + "length"); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3216,7 +3360,8 @@ TEST_P(ImportData_TwoParamTest, Scalar) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -3251,7 +3396,8 @@ TEST_P(ImportData_TwoParamTest, Vector) { params.push_back(create(&vec, vals_1)); params.push_back(create(&vec, vals_2)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -3272,7 +3418,8 @@ TEST_P(ImportData_TwoParamTest, Error_Integer) { params.push_back(create( create(&i32, 2))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3286,7 +3433,8 @@ TEST_P(ImportData_TwoParamTest, Error_NoParams) { ast::ExpressionList params; - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3302,7 +3450,8 @@ TEST_P(ImportData_TwoParamTest, Error_OneParam) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3335,7 +3484,8 @@ TEST_P(ImportData_TwoParamTest, Error_MismatchedParamCount) { params.push_back(create(&vec2, vals_1)); params.push_back(create(&vec3, vals_2)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3362,7 +3512,8 @@ TEST_P(ImportData_TwoParamTest, Error_MismatchedParamType) { create(&f32, 1.0f))); params.push_back(create(&vec, vals)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3382,7 +3533,8 @@ TEST_P(ImportData_TwoParamTest, Error_TooManyParams) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3407,7 +3559,8 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Scalar) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create("distance"); + auto* ident = create( + mod->RegisterSymbol("distance"), "distance"); ast::CallExpression call(ident, params); @@ -3440,7 +3593,8 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Vector) { params.push_back(create(&vec, vals_1)); params.push_back(create(&vec, vals_2)); - auto* ident = create("distance"); + auto* ident = create( + mod->RegisterSymbol("distance"), "distance"); ast::CallExpression call(ident, params); @@ -3458,7 +3612,8 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_Integer) { params.push_back(create( create(&i32, 2))); - auto* ident = create("distance"); + auto* ident = create( + mod->RegisterSymbol("distance"), "distance"); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3470,7 +3625,8 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_Integer) { TEST_F(TypeDeterminerTest, ImportData_Distance_Error_NoParams) { ast::ExpressionList params; - auto* ident = create("distance"); + auto* ident = create( + mod->RegisterSymbol("distance"), "distance"); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3484,7 +3640,8 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_OneParam) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create("distance"); + auto* ident = create( + mod->RegisterSymbol("distance"), "distance"); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3515,7 +3672,8 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_MismatchedParamCount) { params.push_back(create(&vec2, vals_1)); params.push_back(create(&vec3, vals_2)); - auto* ident = create("distance"); + auto* ident = create( + mod->RegisterSymbol("distance"), "distance"); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3539,7 +3697,8 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_MismatchedParamType) { create(&f32, 1.0f))); params.push_back(create(&vec, vals)); - auto* ident = create("distance"); + auto* ident = create( + mod->RegisterSymbol("distance"), "distance"); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3556,7 +3715,8 @@ TEST_F(TypeDeterminerTest, ImportData_Distance_Error_TooManyParams) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create("distance"); + auto* ident = create( + mod->RegisterSymbol("distance"), "distance"); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3588,7 +3748,8 @@ TEST_F(TypeDeterminerTest, ImportData_Cross) { params.push_back(create(&vec, vals_1)); params.push_back(create(&vec, vals_2)); - auto* ident = create("cross"); + auto* ident = + create(mod->RegisterSymbol("cross"), "cross"); ast::CallExpression call(ident, params); @@ -3607,7 +3768,8 @@ TEST_F(TypeDeterminerTest, ImportData_Cross_Error_Scalar) { params.push_back(create( create(&f32, 1.0f))); - auto* ident = create("cross"); + auto* ident = + create(mod->RegisterSymbol("cross"), "cross"); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3639,7 +3801,8 @@ TEST_F(TypeDeterminerTest, ImportData_Cross_Error_IntType) { params.push_back(create(&vec, vals_1)); params.push_back(create(&vec, vals_2)); - auto* ident = create("cross"); + auto* ident = + create(mod->RegisterSymbol("cross"), "cross"); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3649,7 +3812,8 @@ TEST_F(TypeDeterminerTest, ImportData_Cross_Error_IntType) { TEST_F(TypeDeterminerTest, ImportData_Cross_Error_MissingParams) { ast::ExpressionList params; - auto* ident = create("cross"); + auto* ident = + create(mod->RegisterSymbol("cross"), "cross"); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3672,7 +3836,8 @@ TEST_F(TypeDeterminerTest, ImportData_Cross_Error_TooFewParams) { ast::ExpressionList params; params.push_back(create(&vec, vals_1)); - auto* ident = create("cross"); + auto* ident = + create(mod->RegisterSymbol("cross"), "cross"); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3713,7 +3878,8 @@ TEST_F(TypeDeterminerTest, ImportData_Cross_Error_TooManyParams) { params.push_back(create(&vec, vals_2)); params.push_back(create(&vec, vals_3)); - auto* ident = create("cross"); + auto* ident = + create(mod->RegisterSymbol("cross"), "cross"); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3735,7 +3901,8 @@ TEST_P(ImportData_ThreeParamTest, Scalar) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -3779,7 +3946,8 @@ TEST_P(ImportData_ThreeParamTest, Vector) { params.push_back(create(&vec, vals_2)); params.push_back(create(&vec, vals_3)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -3802,7 +3970,8 @@ TEST_P(ImportData_ThreeParamTest, Error_Integer) { params.push_back(create( create(&i32, 3))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3816,7 +3985,8 @@ TEST_P(ImportData_ThreeParamTest, Error_NoParams) { ast::ExpressionList params; - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3832,7 +4002,8 @@ TEST_P(ImportData_ThreeParamTest, Error_OneParam) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3850,7 +4021,8 @@ TEST_P(ImportData_ThreeParamTest, Error_TwoParams) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3892,7 +4064,8 @@ TEST_P(ImportData_ThreeParamTest, Error_MismatchedParamCount) { params.push_back(create(&vec3, vals_2)); params.push_back(create(&vec3, vals_3)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3921,7 +4094,8 @@ TEST_P(ImportData_ThreeParamTest, Error_MismatchedParamType) { create(&f32, 1.0f))); params.push_back(create(&vec, vals)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3943,7 +4117,8 @@ TEST_P(ImportData_ThreeParamTest, Error_TooManyParams) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -3975,7 +4150,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Float_Scalar) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -4019,7 +4195,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Float_Vector) { params.push_back(create(&vec, vals_2)); params.push_back(create(&vec, vals_3)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -4042,7 +4219,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Sint_Scalar) { params.push_back(create( create(&i32, 1))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -4086,7 +4264,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Sint_Vector) { params.push_back(create(&vec, vals_2)); params.push_back(create(&vec, vals_3)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -4109,7 +4288,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Uint_Scalar) { params.push_back(create( create(&u32, 1))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -4153,7 +4333,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Uint_Vector) { params.push_back(create(&vec, vals_2)); params.push_back(create(&vec, vals_3)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -4176,7 +4357,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_Bool) { params.push_back(create( create(&bool_type, true))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4190,7 +4372,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_NoParams) { ast::ExpressionList params; - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4206,7 +4389,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_OneParam) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4224,7 +4408,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_TwoParams) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4266,7 +4451,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_MismatchedParamCount) { params.push_back(create(&vec3, vals_2)); params.push_back(create(&vec3, vals_3)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4295,7 +4481,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_MismatchedParamType) { create(&f32, 1.0f))); params.push_back(create(&vec, vals)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4317,7 +4504,8 @@ TEST_P(ImportData_ThreeParam_FloatOrInt_Test, Error_TooManyParams) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4341,7 +4529,8 @@ TEST_P(ImportData_Int_SingleParamTest, Scalar) { params.push_back(create( create(&i32, 1))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -4367,7 +4556,8 @@ TEST_P(ImportData_Int_SingleParamTest, Vector) { ast::ExpressionList params; params.push_back(create(&vec, vals)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -4386,7 +4576,8 @@ TEST_P(ImportData_Int_SingleParamTest, Error_Float) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4400,7 +4591,8 @@ TEST_P(ImportData_Int_SingleParamTest, Error_NoParams) { ast::ExpressionList params; - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4420,7 +4612,8 @@ TEST_P(ImportData_Int_SingleParamTest, Error_MultipleParams) { params.push_back(create( create(&i32, 1))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4448,7 +4641,8 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Signed) { params.push_back(create( create(&i32, 1))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -4468,7 +4662,8 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Unsigned) { params.push_back(create( create(&u32, 1))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -4488,7 +4683,8 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Scalar_Float) { params.push_back(create( create(&f32, 1))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -4523,7 +4719,8 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Signed) { params.push_back(create(&vec, vals_1)); params.push_back(create(&vec, vals_2)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -4559,7 +4756,8 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Unsigned) { params.push_back(create(&vec, vals_1)); params.push_back(create(&vec, vals_2)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -4595,7 +4793,8 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Vector_Float) { params.push_back(create(&vec, vals_1)); params.push_back(create(&vec, vals_2)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -4616,7 +4815,8 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_Bool) { params.push_back(create( create(&bool_type, false))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4630,7 +4830,8 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_NoParams) { ast::ExpressionList params; - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4646,7 +4847,8 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_OneParam) { params.push_back(create( create(&i32, 1))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4679,7 +4881,8 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_MismatchedParamCount) { params.push_back(create(&vec2, vals_1)); params.push_back(create(&vec3, vals_2)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4706,7 +4909,8 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_MismatchedParamType) { create(&i32, 1))); params.push_back(create(&vec, vals)); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4726,7 +4930,8 @@ TEST_P(ImportData_FloatOrInt_TwoParamTest, Error_TooManyParams) { params.push_back(create( create(&i32, 1))); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4758,9 +4963,11 @@ TEST_F(TypeDeterminerTest, ImportData_GLSL_Determinant) { ASSERT_TRUE(td()->Determine()) << td()->error(); ast::ExpressionList params; - params.push_back(create("var")); + params.push_back( + create(mod->RegisterSymbol("var"), "var")); - auto* ident = create("determinant"); + auto* ident = create( + mod->RegisterSymbol("determinant"), "determinant"); ast::CallExpression call(ident, params); @@ -4790,9 +4997,11 @@ TEST_P(ImportData_Matrix_OneParam_Test, Error_Float) { ASSERT_TRUE(td()->Determine()) << td()->error(); ast::ExpressionList params; - params.push_back(create("var")); + params.push_back( + create(mod->RegisterSymbol("var"), "var")); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4805,7 +5014,8 @@ TEST_P(ImportData_Matrix_OneParam_Test, NoParams) { ast::ExpressionList params; - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4833,10 +5043,13 @@ TEST_P(ImportData_Matrix_OneParam_Test, TooManyParams) { ASSERT_TRUE(td()->Determine()) << td()->error(); ast::ExpressionList params; - params.push_back(create("var")); - params.push_back(create("var")); + params.push_back( + create(mod->RegisterSymbol("var"), "var")); + params.push_back( + create(mod->RegisterSymbol("var"), "var")); - auto* ident = create(param.name); + auto* ident = create( + mod->RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); EXPECT_FALSE(td()->DetermineResultType(&call)); @@ -4871,31 +5084,38 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) { body = create(); body->append(create( - create("second"), - create(create("b"), - ast::ExpressionList{}))); + create(mod->RegisterSymbol("second"), + "second"), + create( + create(mod->RegisterSymbol("b"), "b"), + ast::ExpressionList{}))); auto* func_c = create(Source{}, mod->RegisterSymbol("c"), "c", params, &f32, body, ast::FunctionDecorationList{}); body = create(); body->append(create( - create("first"), - create(create("c"), - ast::ExpressionList{}))); + create(mod->RegisterSymbol("first"), "first"), + create( + create(mod->RegisterSymbol("c"), "c"), + ast::ExpressionList{}))); auto* func_a = create(Source{}, mod->RegisterSymbol("a"), "a", params, &f32, body, ast::FunctionDecorationList{}); body = create(); body->append(create( - create("call_a"), - create(create("a"), - ast::ExpressionList{}))); + create(mod->RegisterSymbol("call_a"), + "call_a"), + create( + create(mod->RegisterSymbol("a"), "a"), + ast::ExpressionList{}))); body->append(create( - create("call_b"), - create(create("b"), - ast::ExpressionList{}))); + create(mod->RegisterSymbol("call_b"), + "call_b"), + create( + create(mod->RegisterSymbol("b"), "b"), + ast::ExpressionList{}))); auto* ep_1 = create( Source{}, mod->RegisterSymbol("ep_1"), "ep_1", params, &f32, body, ast::FunctionDecorationList{ @@ -4904,9 +5124,11 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) { body = create(); body->append(create( - create("call_c"), - create(create("c"), - ast::ExpressionList{}))); + create(mod->RegisterSymbol("call_c"), + "call_c"), + create( + create(mod->RegisterSymbol("c"), "c"), + ast::ExpressionList{}))); auto* ep_2 = create( Source{}, mod->RegisterSymbol("ep_2"), "ep_2", params, &f32, body, ast::FunctionDecorationList{ diff --git a/src/validator/validator_control_block_test.cc b/src/validator/validator_control_block_test.cc index b4c599090e..cffdf1e34d 100644 --- a/src/validator/validator_control_block_test.cc +++ b/src/validator/validator_control_block_test.cc @@ -53,8 +53,8 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) { create(&f32, 3.14f)), // constructor ast::VariableDecorationList{}); // decorations - auto* cond = - create(Source{Source::Location{12, 34}}, "a"); + auto* cond = create( + Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList default_csl; auto* block_default = create(); ast::CaseStatementList body; @@ -87,7 +87,8 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_Fail) { create(&i32, 2)), // constructor ast::VariableDecorationList{}); // decorations - auto* cond = create("a"); + auto* cond = + create(mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList csl; csl.push_back(create(&i32, 1)); ast::CaseStatementList body; @@ -125,7 +126,8 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) { ast::VariableDecorationList{}); // decorations ast::CaseStatementList switch_body; - auto* cond = create("a"); + auto* cond = + create(mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList default_csl_1; auto* block_default_1 = create(); @@ -174,7 +176,8 @@ TEST_F(ValidateControlBlockTest, ast::VariableDecorationList{}); // decorations ast::CaseStatementList switch_body; - auto* cond = create("a"); + auto* cond = + create(mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList csl; csl.push_back(create(&u32, 1)); @@ -216,7 +219,8 @@ TEST_F(ValidateControlBlockTest, ast::VariableDecorationList{}); // decorations ast::CaseStatementList switch_body; - auto* cond = create("a"); + auto* cond = + create(mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList csl; csl.push_back(create(&i32, -1)); @@ -257,7 +261,8 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) { ast::VariableDecorationList{}); // decorations ast::CaseStatementList switch_body; - auto* cond = create("a"); + auto* cond = + create(mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList csl_1; csl_1.push_back(create(&u32, 0)); @@ -304,7 +309,8 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) { ast::VariableDecorationList{}); // decorations ast::CaseStatementList switch_body; - auto* cond = create("a"); + auto* cond = + create(mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList csl_1; csl_1.push_back(create(&i32, 10)); @@ -350,7 +356,8 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) { create(&i32, 2)), // constructor ast::VariableDecorationList{}); // decorations - auto* cond = create("a"); + auto* cond = + create(mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList default_csl; auto* block_default = create(); block_default->append( @@ -386,7 +393,8 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) { create(&i32, 2)), // constructor ast::VariableDecorationList{}); // decorations - auto* cond = create("a"); + auto* cond = + create(mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList default_csl; auto* block_default = create(); ast::CaseStatementList body; @@ -425,7 +433,8 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) { create(&u32, 2)), // constructor ast::VariableDecorationList{}); // decorations - auto* cond = create("a"); + auto* cond = + create(mod()->RegisterSymbol("a"), "a"); ast::CaseSelectorList default_csl; auto* block_default = create(); ast::CaseStatementList body; diff --git a/src/validator/validator_function_test.cc b/src/validator/validator_function_test.cc index 780b5427d2..8440faa8a1 100644 --- a/src/validator/validator_function_test.cc +++ b/src/validator/validator_function_test.cc @@ -237,7 +237,8 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) { ast::ExpressionList call_params; auto* call_expr = create( Source{Source::Location{12, 34}}, - create("func"), call_params); + create(mod()->RegisterSymbol("func"), "func"), + call_params); ast::VariableList params0; auto* body0 = create(); body0->append(create(call_expr)); @@ -258,7 +259,8 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) { ast::ExpressionList call_params; auto* call_expr = create( Source{Source::Location{12, 34}}, - create("func"), call_params); + create(mod()->RegisterSymbol("func"), "func"), + call_params); auto* var = create(Source{}, // source "a", // name @@ -267,6 +269,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) { false, // is_const call_expr, // constructor ast::VariableDecorationList{}); // decorations + ast::VariableList params0; auto* body0 = create(); body0->append(create(var)); diff --git a/src/validator/validator_test.cc b/src/validator/validator_test.cc index 5931fc0688..9c5c5d3049 100644 --- a/src/validator/validator_test.cc +++ b/src/validator/validator_test.cc @@ -66,7 +66,8 @@ TEST_F(ValidatorTest, DISABLED_AssignToScalar_Fail) { auto* lhs = create( create(&i32, 1)); - auto* rhs = create("my_var"); + auto* rhs = create(mod()->RegisterSymbol("my_var"), + "my_var"); ast::AssignmentStatement assign(Source{Source::Location{12, 34}}, lhs, rhs); // TODO(sarahM0): Invalidate assignment to scalar. @@ -79,8 +80,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariable_Fail) { // b = 2; ast::type::I32 i32; - auto* lhs = - create(Source{Source::Location{12, 34}}, "b"); + auto* lhs = create( + Source{Source::Location{12, 34}}, mod()->RegisterSymbol("b"), "b"); auto* rhs = create( create(&i32, 2)); auto* assign = create( @@ -97,8 +98,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInBlockStatement_Fail) { // } ast::type::I32 i32; - auto* lhs = - create(Source{Source::Location{12, 34}}, "b"); + auto* lhs = create( + Source{Source::Location{12, 34}}, mod()->RegisterSymbol("b"), "b"); auto* rhs = create( create(&i32, 2)); @@ -125,7 +126,8 @@ TEST_F(ValidatorTest, AssignCompatibleTypes_Pass) { create(&i32, 2)), // constructor ast::VariableDecorationList{}); // decorations - auto* lhs = create("a"); + auto* lhs = + create(mod()->RegisterSymbol("a"), "a"); auto* rhs = create( create(&i32, 2)); @@ -155,7 +157,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypes_Fail) { create(&i32, 2)), // constructor ast::VariableDecorationList{}); // decorations - auto* lhs = create("a"); + auto* lhs = + create(mod()->RegisterSymbol("a"), "a"); auto* rhs = create( create(&f32, 2.3f)); @@ -188,7 +191,8 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) { create(&i32, 2)), // constructor ast::VariableDecorationList{}); // decorations - auto* lhs = create("a"); + auto* lhs = + create(mod()->RegisterSymbol("a"), "a"); auto* rhs = create( create(&i32, 2)); @@ -221,7 +225,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) { create( create(&i32, 2)), // constructor ast::VariableDecorationList{}); // decorations - auto* lhs = create("a"); + auto* lhs = + create(mod()->RegisterSymbol("a"), "a"); auto* rhs = create( create(&f32, 2.3f)); @@ -323,7 +328,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) { ast::VariableDecorationList{})); // decorations auto* lhs = create( - Source{Source::Location{12, 34}}, "not_global_var"); + Source{Source::Location{12, 34}}, mod()->RegisterSymbol("not_global_var"), + "not_global_var"); auto* rhs = create( create(&f32, 3.14f)); @@ -360,7 +366,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) { create(&f32, 2.1)), // constructor ast::VariableDecorationList{})); // decorations - auto* lhs = create("global_var"); + auto* lhs = create( + mod()->RegisterSymbol("global_var"), "global_var"); auto* rhs = create( create(&f32, 3.14f)); @@ -404,8 +411,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) { auto* body = create(); body->append(create(var)); - auto* lhs = - create(Source{Source::Location{12, 34}}, "a"); + auto* lhs = create( + Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a"); auto* rhs = create( create(&f32, 3.14f)); @@ -438,8 +445,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) { create(&f32, 2.0)), // constructor ast::VariableDecorationList{}); // decorations - auto* lhs = - create(Source{Source::Location{12, 34}}, "a"); + auto* lhs = create( + Source{Source::Location{12, 34}}, mod()->RegisterSymbol("a"), "a"); auto* rhs = create( create(&f32, 3.14f)); @@ -539,7 +546,8 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) { create(&i32, 2)), // constructor ast::VariableDecorationList{}); // decorations - auto* lhs = create("a"); + auto* lhs = + create(mod()->RegisterSymbol("a"), "a"); auto* rhs = create( create(&i32, 2)); @@ -802,7 +810,8 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) { ast::VariableDecorationList{}); // decorations td()->RegisterVariableForTesting(var); - auto* lhs = create("a"); + auto* lhs = + create(mod()->RegisterSymbol("a"), "a"); auto* rhs = create( create(&i32, 2)); diff --git a/src/writer/hlsl/generator_impl_array_accessor_test.cc b/src/writer/hlsl/generator_impl_array_accessor_test.cc index 53cee1abf2..ddf140c9ce 100644 --- a/src/writer/hlsl/generator_impl_array_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_array_accessor_test.cc @@ -33,7 +33,8 @@ TEST_F(HlslGeneratorImplTest_Expression, EmitExpression_ArrayAccessor) { ast::type::I32 i32; auto* lit = create(&i32, 5); auto* idx = create(lit); - auto* ary = create("ary"); + auto* ary = + create(mod.RegisterSymbol("ary"), "ary"); ast::ArrayAccessorExpression expr(ary, idx); @@ -42,8 +43,10 @@ TEST_F(HlslGeneratorImplTest_Expression, EmitExpression_ArrayAccessor) { } TEST_F(HlslGeneratorImplTest_Expression, EmitArrayAccessor) { - auto* ary = create("ary"); - auto* idx = create("idx"); + auto* ary = + create(mod.RegisterSymbol("ary"), "ary"); + auto* idx = + create(mod.RegisterSymbol("idx"), "idx"); ast::ArrayAccessorExpression expr(ary, idx); diff --git a/src/writer/hlsl/generator_impl_assign_test.cc b/src/writer/hlsl/generator_impl_assign_test.cc index a34d9ac6a0..0b89944c5a 100644 --- a/src/writer/hlsl/generator_impl_assign_test.cc +++ b/src/writer/hlsl/generator_impl_assign_test.cc @@ -28,8 +28,10 @@ namespace { using HlslGeneratorImplTest_Assign = TestHelper; TEST_F(HlslGeneratorImplTest_Assign, Emit_Assign) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = + create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = + create(mod.RegisterSymbol("rhs"), "rhs"); ast::AssignmentStatement assign(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 318c68b720..106d27954c 100644 --- a/src/writer/hlsl/generator_impl_binary_test.cc +++ b/src/writer/hlsl/generator_impl_binary_test.cc @@ -79,8 +79,10 @@ TEST_P(HlslBinaryTest, Emit_f32) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* left = create("left"); - auto* right = create("right"); + auto* left = + create(mod.RegisterSymbol("left"), "left"); + auto* right = + create(mod.RegisterSymbol("right"), "right"); td.RegisterVariableForTesting(left_var); td.RegisterVariableForTesting(right_var); @@ -113,8 +115,10 @@ TEST_P(HlslBinaryTest, Emit_u32) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* left = create("left"); - auto* right = create("right"); + auto* left = + create(mod.RegisterSymbol("left"), "left"); + auto* right = + create(mod.RegisterSymbol("right"), "right"); td.RegisterVariableForTesting(left_var); td.RegisterVariableForTesting(right_var); @@ -147,8 +151,10 @@ TEST_P(HlslBinaryTest, Emit_i32) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* left = create("left"); - auto* right = create("right"); + auto* left = + create(mod.RegisterSymbol("left"), "left"); + auto* right = + create(mod.RegisterSymbol("right"), "right"); td.RegisterVariableForTesting(left_var); td.RegisterVariableForTesting(right_var); @@ -243,7 +249,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar) { false, // is_const nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* lhs = create("mat"); + auto* lhs = + create(mod.RegisterSymbol("mat"), "mat"); auto* rhs = create( create(&f32, 1.f)); @@ -270,7 +277,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) { ast::VariableDecorationList{}); // decorations auto* lhs = create( create(&f32, 1.f)); - auto* rhs = create("mat"); + auto* rhs = + create(mod.RegisterSymbol("mat"), "mat"); td.RegisterVariableForTesting(var); @@ -294,7 +302,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector) { false, // is_const nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* lhs = create("mat"); + auto* lhs = + create(mod.RegisterSymbol("mat"), "mat"); ast::ExpressionList vals; vals.push_back(create( @@ -337,7 +346,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix) { create(&f32, 1.f))); auto* lhs = create(&vec3, vals); - auto* rhs = create("mat"); + auto* rhs = + create(mod.RegisterSymbol("mat"), "mat"); td.RegisterVariableForTesting(var); @@ -361,8 +371,10 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixMatrix) { false, // is_const nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* lhs = create("mat"); - auto* rhs = create("mat"); + auto* lhs = + create(mod.RegisterSymbol("mat"), "mat"); + auto* rhs = + create(mod.RegisterSymbol("mat"), "mat"); td.RegisterVariableForTesting(var); @@ -374,8 +386,10 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixMatrix) { } TEST_F(HlslGeneratorImplTest_Binary, Logical_And) { - auto* left = create("left"); - auto* right = create("right"); + auto* left = + create(mod.RegisterSymbol("left"), "left"); + auto* right = + create(mod.RegisterSymbol("right"), "right"); ast::BinaryExpression expr(ast::BinaryOp::kLogicalAnd, left, right); @@ -390,10 +404,10 @@ if (_tint_tmp) { TEST_F(HlslGeneratorImplTest_Binary, Logical_Multi) { // (a && b) || (c || d) - auto* a = create("a"); - auto* b = create("b"); - auto* c = create("c"); - auto* d = create("d"); + auto* a = create(mod.RegisterSymbol("a"), "a"); + auto* b = create(mod.RegisterSymbol("b"), "b"); + auto* c = create(mod.RegisterSymbol("c"), "c"); + auto* d = create(mod.RegisterSymbol("d"), "d"); ast::BinaryExpression expr( ast::BinaryOp::kLogicalOr, @@ -418,8 +432,10 @@ if (!_tint_tmp_0) { } TEST_F(HlslGeneratorImplTest_Binary, Logical_Or) { - auto* left = create("left"); - auto* right = create("right"); + auto* left = + create(mod.RegisterSymbol("left"), "left"); + auto* right = + create(mod.RegisterSymbol("right"), "right"); ast::BinaryExpression expr(ast::BinaryOp::kLogicalOr, left, right); @@ -454,9 +470,10 @@ TEST_F(HlslGeneratorImplTest_Binary, If_WithLogical) { Source{}, create( create(&i32, 2)))); auto* else_if_stmt = create( - create(ast::BinaryOp::kLogicalOr, - create("b"), - create("c")), + create( + ast::BinaryOp::kLogicalOr, + create(mod.RegisterSymbol("b"), "b"), + create(mod.RegisterSymbol("c"), "c")), body); body = create(); @@ -466,9 +483,10 @@ TEST_F(HlslGeneratorImplTest_Binary, If_WithLogical) { ast::IfStatement expr( Source{}, - create(ast::BinaryOp::kLogicalAnd, - create("a"), - create("b")), + create( + ast::BinaryOp::kLogicalAnd, + create(mod.RegisterSymbol("a"), "a"), + create(mod.RegisterSymbol("b"), "b")), body, { else_if_stmt, @@ -498,9 +516,9 @@ if ((_tint_tmp)) { TEST_F(HlslGeneratorImplTest_Binary, Return_WithLogical) { // return (a && b) || c; - auto* a = create("a"); - auto* b = create("b"); - auto* c = create("c"); + auto* a = create(mod.RegisterSymbol("a"), "a"); + auto* b = create(mod.RegisterSymbol("b"), "b"); + auto* c = create(mod.RegisterSymbol("c"), "c"); ast::ReturnStatement expr( Source{}, @@ -523,10 +541,10 @@ return (_tint_tmp_0); TEST_F(HlslGeneratorImplTest_Binary, Assign_WithLogical) { // a = (b || c) && d; - auto* a = create("a"); - auto* b = create("b"); - auto* c = create("c"); - auto* d = create("d"); + auto* a = create(mod.RegisterSymbol("a"), "a"); + auto* b = create(mod.RegisterSymbol("b"), "b"); + auto* c = create(mod.RegisterSymbol("c"), "c"); + auto* d = create(mod.RegisterSymbol("d"), "d"); ast::AssignmentStatement expr( a, @@ -551,9 +569,9 @@ TEST_F(HlslGeneratorImplTest_Binary, Decl_WithLogical) { // var a : bool = (b && c) || d; ast::type::Bool bool_type; - auto* b = create("b"); - auto* c = create("c"); - auto* d = create("d"); + auto* b = create(mod.RegisterSymbol("b"), "b"); + auto* c = create(mod.RegisterSymbol("c"), "c"); + auto* d = create(mod.RegisterSymbol("d"), "d"); auto* var = create( Source{}, // source @@ -586,9 +604,9 @@ TEST_F(HlslGeneratorImplTest_Binary, Bitcast_WithLogical) { // as(a && (b || c)) ast::type::I32 i32; - auto* a = create("a"); - auto* b = create("b"); - auto* c = create("c"); + auto* a = create(mod.RegisterSymbol("a"), "a"); + auto* b = create(mod.RegisterSymbol("b"), "b"); + auto* c = create(mod.RegisterSymbol("c"), "c"); ast::BitcastExpression expr(&i32, create( ast::BinaryOp::kLogicalAnd, a, @@ -620,22 +638,27 @@ TEST_F(HlslGeneratorImplTest_Binary, Call_WithLogical) { ast::ExpressionList params; params.push_back(create( - ast::BinaryOp::kLogicalAnd, create("a"), - create("b"))); + ast::BinaryOp::kLogicalAnd, + create(mod.RegisterSymbol("a"), "a"), + create(mod.RegisterSymbol("b"), "b"))); params.push_back(create( - ast::BinaryOp::kLogicalOr, create("c"), - create("d"))); + ast::BinaryOp::kLogicalOr, + create(mod.RegisterSymbol("c"), "c"), + create(mod.RegisterSymbol("d"), "d"))); params.push_back(create( ast::BinaryOp::kLogicalAnd, - create(ast::BinaryOp::kLogicalOr, - create("a"), - create("c")), - create(ast::BinaryOp::kLogicalOr, - create("b"), - create("d")))); + create( + ast::BinaryOp::kLogicalOr, + create(mod.RegisterSymbol("a"), "a"), + create(mod.RegisterSymbol("c"), "c")), + create( + ast::BinaryOp::kLogicalOr, + create(mod.RegisterSymbol("b"), "b"), + create(mod.RegisterSymbol("d"), "d")))); ast::CallStatement expr(create( - create("foo"), params)); + create(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_bitcast_test.cc b/src/writer/hlsl/generator_impl_bitcast_test.cc index 9d6d214d27..a95de598f4 100644 --- a/src/writer/hlsl/generator_impl_bitcast_test.cc +++ b/src/writer/hlsl/generator_impl_bitcast_test.cc @@ -31,7 +31,7 @@ using HlslGeneratorImplTest_Bitcast = TestHelper; TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) { ast::type::F32 f32; - auto* id = create("id"); + auto* id = create(mod.RegisterSymbol("id"), "id"); ast::BitcastExpression bitcast(&f32, id); ASSERT_TRUE(gen.EmitExpression(pre, out, &bitcast)) << gen.error(); @@ -40,7 +40,7 @@ TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) { TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) { ast::type::I32 i32; - auto* id = create("id"); + auto* id = create(mod.RegisterSymbol("id"), "id"); ast::BitcastExpression bitcast(&i32, id); ASSERT_TRUE(gen.EmitExpression(pre, out, &bitcast)) << gen.error(); @@ -49,7 +49,7 @@ TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) { TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Uint) { ast::type::U32 u32; - auto* id = create("id"); + auto* id = create(mod.RegisterSymbol("id"), "id"); ast::BitcastExpression bitcast(&u32, id); ASSERT_TRUE(gen.EmitExpression(pre, out, &bitcast)) << gen.error(); diff --git a/src/writer/hlsl/generator_impl_call_test.cc b/src/writer/hlsl/generator_impl_call_test.cc index 3311837bae..14f9791e0e 100644 --- a/src/writer/hlsl/generator_impl_call_test.cc +++ b/src/writer/hlsl/generator_impl_call_test.cc @@ -32,7 +32,8 @@ using HlslGeneratorImplTest_Call = TestHelper; TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) { ast::type::Void void_type; - auto* id = create("my_func"); + auto* id = create(mod.RegisterSymbol("my_func"), + "my_func"); ast::CallExpression call(id, {}); auto* func = create( @@ -47,10 +48,13 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) { TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) { ast::type::Void void_type; - auto* id = create("my_func"); + auto* id = create(mod.RegisterSymbol("my_func"), + "my_func"); ast::ExpressionList params; - params.push_back(create("param1")); - params.push_back(create("param2")); + params.push_back(create( + mod.RegisterSymbol("param1"), "param1")); + params.push_back(create( + mod.RegisterSymbol("param2"), "param2")); ast::CallExpression call(id, params); auto* func = create( @@ -65,10 +69,13 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) { TEST_F(HlslGeneratorImplTest_Call, EmitStatement_Call) { ast::type::Void void_type; - auto* id = create("my_func"); + auto* id = create(mod.RegisterSymbol("my_func"), + "my_func"); ast::ExpressionList params; - params.push_back(create("param1")); - params.push_back(create("param2")); + params.push_back(create( + mod.RegisterSymbol("param1"), "param1")); + params.push_back(create( + mod.RegisterSymbol("param2"), "param2")); ast::CallStatement call(create(id, params)); auto* func = create( diff --git a/src/writer/hlsl/generator_impl_cast_test.cc b/src/writer/hlsl/generator_impl_cast_test.cc index 1fc3c702d7..b53f3e0d1f 100644 --- a/src/writer/hlsl/generator_impl_cast_test.cc +++ b/src/writer/hlsl/generator_impl_cast_test.cc @@ -32,7 +32,8 @@ TEST_F(HlslGeneratorImplTest_Cast, EmitExpression_Cast_Scalar) { ast::type::F32 f32; ast::ExpressionList params; - params.push_back(create("id")); + params.push_back( + create(mod.RegisterSymbol("id"), "id")); ast::TypeConstructorExpression cast(&f32, params); @@ -45,7 +46,8 @@ TEST_F(HlslGeneratorImplTest_Cast, EmitExpression_Cast_Vector) { ast::type::Vector vec3(&f32, 3); ast::ExpressionList params; - params.push_back(create("id")); + params.push_back( + create(mod.RegisterSymbol("id"), "id")); ast::TypeConstructorExpression cast(&vec3, params); 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 320b478c32..b25ae35888 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 @@ -84,11 +84,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::VariableList params; auto* body = create(); body->append(create( - create("foo"), - create("foo"))); + create(mod.RegisterSymbol("foo"), "foo"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create( - create("bar"), - create("bar"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("bar"), "bar"))); auto* func = create( Source{}, mod.RegisterSymbol("vtx_main"), "vtx_main", params, &f32, body, @@ -157,11 +157,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, auto* body = create(); body->append(create( - create("foo"), - create("foo"))); + create(mod.RegisterSymbol("foo"), "foo"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create( - create("bar"), - create("bar"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("bar"), "bar"))); auto* func = create( Source{}, mod.RegisterSymbol("vtx_main"), "vtx_main", params, &f32, body, @@ -230,11 +230,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, auto* body = create(); body->append(create( - create("foo"), - create("foo"))); + create(mod.RegisterSymbol("foo"), "foo"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create( - create("bar"), - create("bar"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("bar"), "bar"))); auto* func = create( Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body, @@ -302,11 +302,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::VariableList params; auto* body = create(); body->append(create( - create("foo"), - create("foo"))); + create(mod.RegisterSymbol("foo"), "foo"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create( - create("bar"), - create("bar"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("bar"), "bar"))); auto* func = create( Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body, @@ -371,11 +371,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::VariableList params; auto* body = create(); body->append(create( - create("foo"), - create("foo"))); + create(mod.RegisterSymbol("foo"), "foo"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create( - create("bar"), - create("bar"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("bar"), "bar"))); auto* func = create( Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body, @@ -435,11 +435,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::VariableList params; auto* body = create(); body->append(create( - create("foo"), - create("foo"))); + create(mod.RegisterSymbol("foo"), "foo"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create( - create("bar"), - create("bar"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("bar"), "bar"))); auto* func = create( Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body, @@ -506,10 +506,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::VariableList params; auto* body = create(); body->append(create( - create("depth"), + create(mod.RegisterSymbol("depth"), "depth"), create( - create("coord"), - create("x")))); + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("x"), "x")))); auto* func = create( Source{}, mod.RegisterSymbol("main"), "main", params, &void_type, body, diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc index cab53fc611..f05f0f76d0 100644 --- a/src/writer/hlsl/generator_impl_function_test.cc +++ b/src/writer/hlsl/generator_impl_function_test.cc @@ -171,8 +171,8 @@ TEST_F(HlslGeneratorImplTest_Function, ast::VariableList params; auto* body = create(); body->append(create( - create("bar"), - create("foo"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create(Source{})); auto* func = create( Source{}, mod.RegisterSymbol("frag_main"), "frag_main", params, @@ -241,10 +241,11 @@ TEST_F(HlslGeneratorImplTest_Function, ast::VariableList params; auto* body = create(); body->append(create( - create("depth"), + create(mod.RegisterSymbol("depth"), "depth"), create( - create("coord"), - create("x")))); + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("x"), "x")))); body->append(create(Source{})); auto* func = create( Source{}, mod.RegisterSymbol("frag_main"), "frag_main", params, @@ -304,8 +305,10 @@ TEST_F(HlslGeneratorImplTest_Function, &f32, // type false, // is_const create( - create("coord"), - create("x")), // constructor + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("x"), + "x")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); @@ -375,9 +378,12 @@ TEST_F(HlslGeneratorImplTest_Function, false, // is_const create( create( - create("uniforms"), - create("coord")), - create("x")), // constructor + create(mod.RegisterSymbol("uniforms"), + "uniforms"), + create(mod.RegisterSymbol("coord"), + "coord")), + create(mod.RegisterSymbol("x"), + "x")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); @@ -452,8 +458,10 @@ TEST_F(HlslGeneratorImplTest_Function, &f32, // type false, // is_const create( - create("coord"), - create("b")), // constructor + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("b"), + "b")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); @@ -524,8 +532,10 @@ TEST_F(HlslGeneratorImplTest_Function, &f32, // type false, // is_const create( - create("coord"), - create("b")), // constructor + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("b"), + "b")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); @@ -592,8 +602,9 @@ TEST_F(HlslGeneratorImplTest_Function, ast::VariableList params; auto* assign = create( create( - create("coord"), - create("b")), + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("b"), "b")), create( create(&f32, 2.0f))); @@ -683,13 +694,14 @@ TEST_F( auto* body = create(); body->append(create( - create("bar"), - create("foo"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create( - create("val"), - create("param"))); + create(mod.RegisterSymbol("val"), "val"), + create(mod.RegisterSymbol("param"), "param"))); body->append(create( - Source{}, create("foo"))); + Source{}, + create(mod.RegisterSymbol("foo"), "foo"))); auto* sub_func = create( Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body, ast::FunctionDecorationList{}); @@ -702,9 +714,11 @@ TEST_F( body = create(); body->append(create( - create("bar"), - create(create("sub_func"), - expr))); + create(mod.RegisterSymbol("bar"), "bar"), + create( + create(mod.RegisterSymbol("sub_func"), + "sub_func"), + expr))); body->append(create(Source{})); auto* func_1 = create( Source{}, mod.RegisterSymbol("ep_1"), "ep_1", params, &void_type, body, @@ -774,7 +788,8 @@ TEST_F(HlslGeneratorImplTest_Function, auto* body = create(); body->append(create( - Source{}, create("param"))); + Source{}, + create(mod.RegisterSymbol("param"), "param"))); auto* sub_func = create( Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body, ast::FunctionDecorationList{}); @@ -787,9 +802,11 @@ TEST_F(HlslGeneratorImplTest_Function, body = create(); body->append(create( - create("depth"), - create(create("sub_func"), - expr))); + create(mod.RegisterSymbol("depth"), "depth"), + create( + create(mod.RegisterSymbol("sub_func"), + "sub_func"), + expr))); body->append(create(Source{})); auto* func_1 = create( Source{}, mod.RegisterSymbol("ep_1"), "ep_1", params, &void_type, body, @@ -867,12 +884,14 @@ TEST_F( auto* body = create(); body->append(create( - create("depth"), + create(mod.RegisterSymbol("depth"), "depth"), create( - create("coord"), - create("x")))); + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("x"), "x")))); body->append(create( - Source{}, create("param"))); + Source{}, + create(mod.RegisterSymbol("param"), "param"))); auto* sub_func = create( Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body, ast::FunctionDecorationList{}); @@ -885,9 +904,11 @@ TEST_F( body = create(); body->append(create( - create("depth"), - create(create("sub_func"), - expr))); + create(mod.RegisterSymbol("depth"), "depth"), + create( + create(mod.RegisterSymbol("sub_func"), + "sub_func"), + expr))); body->append(create(Source{})); auto* func_1 = create( Source{}, mod.RegisterSymbol("ep_1"), "ep_1", params, &void_type, body, @@ -956,9 +977,11 @@ TEST_F(HlslGeneratorImplTest_Function, auto* body = create(); body->append(create( - Source{}, create( - create("coord"), - create("x")))); + Source{}, + create( + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("x"), "x")))); auto* sub_func = create( Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body, ast::FunctionDecorationList{}); @@ -969,15 +992,17 @@ TEST_F(HlslGeneratorImplTest_Function, expr.push_back(create( create(&f32, 1.0f))); - auto* var = create( - Source{}, // source - "v", // name - ast::StorageClass::kFunction, // storage_class - &f32, // type - false, // is_const - create(create("sub_func"), - expr), // constructor - ast::VariableDecorationList{}); // decorations + auto* var = + create(Source{}, // source + "v", // name + ast::StorageClass::kFunction, // storage_class + &f32, // type + false, // is_const + create( + create( + mod.RegisterSymbol("sub_func"), "sub_func"), + expr), // constructor + ast::VariableDecorationList{}); // decorations body = create(); body->append(create(var)); @@ -1044,9 +1069,11 @@ TEST_F(HlslGeneratorImplTest_Function, auto* body = create(); body->append(create( - Source{}, create( - create("coord"), - create("x")))); + Source{}, + create( + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("x"), "x")))); auto* sub_func = create( Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body, ast::FunctionDecorationList{}); @@ -1057,15 +1084,17 @@ TEST_F(HlslGeneratorImplTest_Function, expr.push_back(create( create(&f32, 1.0f))); - auto* var = create( - Source{}, // source - "v", // name - ast::StorageClass::kFunction, // storage_class - &f32, // type - false, // is_const - create(create("sub_func"), - expr), // constructor - ast::VariableDecorationList{}); // decorations + auto* var = + create(Source{}, // source + "v", // name + ast::StorageClass::kFunction, // storage_class + &f32, // type + false, // is_const + create( + create( + mod.RegisterSymbol("sub_func"), "sub_func"), + expr), // constructor + ast::VariableDecorationList{}); // decorations body = create(); body->append(create(var)); @@ -1119,7 +1148,7 @@ TEST_F(HlslGeneratorImplTest_Function, ast::VariableList params; auto* body = create(); body->append(create( - create("bar"), + create(mod.RegisterSymbol("bar"), "bar"), create( create(&f32, 1.0f)))); @@ -1326,8 +1355,10 @@ TEST_F(HlslGeneratorImplTest_Function, &f32, // type false, // is_const create( - create("data"), - create("d")), // constructor + create(mod.RegisterSymbol("data"), + "data"), + create(mod.RegisterSymbol("d"), + "d")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); @@ -1352,8 +1383,10 @@ TEST_F(HlslGeneratorImplTest_Function, &f32, // type false, // is_const create( - create("data"), - create("d")), // constructor + create(mod.RegisterSymbol("data"), + "data"), + create(mod.RegisterSymbol("d"), + "d")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); diff --git a/src/writer/hlsl/generator_impl_identifier_test.cc b/src/writer/hlsl/generator_impl_identifier_test.cc index 2c0bfd2614..c573ec448a 100644 --- a/src/writer/hlsl/generator_impl_identifier_test.cc +++ b/src/writer/hlsl/generator_impl_identifier_test.cc @@ -24,14 +24,14 @@ namespace { using HlslGeneratorImplTest_Identifier = TestHelper; TEST_F(HlslGeneratorImplTest_Identifier, EmitIdentifierExpression) { - ast::IdentifierExpression i("foo"); + ast::IdentifierExpression i(mod.RegisterSymbol("foo"), "foo"); ASSERT_TRUE(gen.EmitExpression(pre, out, &i)) << gen.error(); EXPECT_EQ(result(), "foo"); } TEST_F(HlslGeneratorImplTest_Identifier, EmitIdentifierExpression_Single_WithCollision) { - ast::IdentifierExpression i("virtual"); + ast::IdentifierExpression i(mod.RegisterSymbol("virtual"), "virtual"); ASSERT_TRUE(gen.EmitExpression(pre, out, &i)) << gen.error(); EXPECT_EQ(result(), "virtual_tint_0"); } diff --git a/src/writer/hlsl/generator_impl_if_test.cc b/src/writer/hlsl/generator_impl_if_test.cc index c5993621a2..9d4845f278 100644 --- a/src/writer/hlsl/generator_impl_if_test.cc +++ b/src/writer/hlsl/generator_impl_if_test.cc @@ -27,7 +27,8 @@ namespace { using HlslGeneratorImplTest_If = TestHelper; TEST_F(HlslGeneratorImplTest_If, Emit_If) { - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create(Source{})); @@ -42,11 +43,13 @@ TEST_F(HlslGeneratorImplTest_If, Emit_If) { } TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElseIf) { - auto* else_cond = create("else_cond"); + auto* else_cond = create( + mod.RegisterSymbol("else_cond"), "else_cond"); auto* else_body = create(); else_body->append(create(Source{})); - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create(Source{})); @@ -70,7 +73,8 @@ TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElse) { auto* else_body = create(); else_body->append(create(Source{})); - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create(Source{})); @@ -89,7 +93,8 @@ TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElse) { } TEST_F(HlslGeneratorImplTest_If, Emit_IfWithMultiple) { - auto* else_cond = create("else_cond"); + auto* else_cond = create( + mod.RegisterSymbol("else_cond"), "else_cond"); auto* else_body = create(); else_body->append(create(Source{})); @@ -97,7 +102,8 @@ TEST_F(HlslGeneratorImplTest_If, Emit_IfWithMultiple) { auto* else_body_2 = create(); else_body_2->append(create(Source{})); - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create(Source{})); diff --git a/src/writer/hlsl/generator_impl_import_test.cc b/src/writer/hlsl/generator_impl_import_test.cc index 09d9c2d678..de3e4b5387 100644 --- a/src/writer/hlsl/generator_impl_import_test.cc +++ b/src/writer/hlsl/generator_impl_import_test.cc @@ -56,7 +56,8 @@ TEST_P(HlslImportData_SingleParamTest, FloatScalar) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod.RegisterSymbol(param.name), param.name); ast::CallExpression expr(ident, params); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -101,7 +102,8 @@ TEST_P(HlslImportData_SingleIntParamTest, IntScalar) { params.push_back(create( create(&i32, 1))); - ast::CallExpression expr(create(param.name), + ast::CallExpression expr(create( + mod.RegisterSymbol(param.name), param.name), params); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -124,7 +126,8 @@ TEST_P(HlslImportData_DualParamTest, FloatScalar) { params.push_back(create( create(&f32, 2.f))); - ast::CallExpression expr(create(param.name), + ast::CallExpression expr(create( + mod.RegisterSymbol(param.name), param.name), params); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -169,7 +172,8 @@ TEST_P(HlslImportData_DualParam_VectorTest, FloatVector) { create(&f32, 6.f)), })); - ast::CallExpression expr(create(param.name), + ast::CallExpression expr(create( + mod.RegisterSymbol(param.name), param.name), params); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -194,7 +198,8 @@ TEST_P(HlslImportData_DualParam_Int_Test, IntScalar) { params.push_back(create( create(&i32, 2))); - ast::CallExpression expr(create(param.name), + ast::CallExpression expr(create( + mod.RegisterSymbol(param.name), param.name), params); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -220,7 +225,8 @@ TEST_P(HlslImportData_TripleParamTest, FloatScalar) { params.push_back(create( create(&f32, 3.f))); - ast::CallExpression expr(create(param.name), + ast::CallExpression expr(create( + mod.RegisterSymbol(param.name), param.name), params); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -253,7 +259,8 @@ TEST_P(HlslImportData_TripleParam_Int_Test, IntScalar) { params.push_back(create( create(&i32, 3))); - ast::CallExpression expr(create(param.name), + ast::CallExpression expr(create( + mod.RegisterSymbol(param.name), param.name), params); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -278,10 +285,13 @@ TEST_F(HlslGeneratorImplTest_Import, HlslImportData_Determinant) { ast::VariableDecorationList{}); // decorations ast::ExpressionList params; - params.push_back(create("var")); + params.push_back( + create(mod.RegisterSymbol("var"), "var")); - ast::CallExpression expr(create("determinant"), - params); + ast::CallExpression expr( + create(mod.RegisterSymbol("determinant"), + "determinant"), + params); mod.AddGlobalVariable(var); diff --git a/src/writer/hlsl/generator_impl_intrinsic_test.cc b/src/writer/hlsl/generator_impl_intrinsic_test.cc index 528718015e..375aa9b2d8 100644 --- a/src/writer/hlsl/generator_impl_intrinsic_test.cc +++ b/src/writer/hlsl/generator_impl_intrinsic_test.cc @@ -93,11 +93,15 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, DISABLED_Intrinsic_OuterProduct) { ast::VariableDecorationList{}); // decorations ast::ExpressionList params; - params.push_back(create("a")); - params.push_back(create("b")); + params.push_back( + create(mod.RegisterSymbol("a"), "a")); + params.push_back( + create(mod.RegisterSymbol("b"), "b")); - ast::CallExpression call(create("outer_product"), - params); + ast::CallExpression call( + create(mod.RegisterSymbol("outer_product"), + "outer_product"), + params); td.RegisterVariableForTesting(a); td.RegisterVariableForTesting(b); @@ -122,10 +126,14 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Intrinsic_Call) { ast::type::Vector vec(&f32, 3); ast::ExpressionList params; - params.push_back(create("param1")); - params.push_back(create("param2")); + params.push_back(create( + mod.RegisterSymbol("param1"), "param1")); + params.push_back(create( + mod.RegisterSymbol("param2"), "param2")); - ast::CallExpression call(create("dot"), params); + ast::CallExpression call( + create(mod.RegisterSymbol("dot"), "dot"), + params); ast::Variable v1(Source{}, "param1", ast::StorageClass::kFunction, &vec, false, nullptr, ast::VariableDecorationList{}); diff --git a/src/writer/hlsl/generator_impl_loop_test.cc b/src/writer/hlsl/generator_impl_loop_test.cc index 383442e704..b06f1bc81b 100644 --- a/src/writer/hlsl/generator_impl_loop_test.cc +++ b/src/writer/hlsl/generator_impl_loop_test.cc @@ -86,8 +86,10 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) { body = create(); body->append(inner); - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = + create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = + create(mod.RegisterSymbol("rhs"), "rhs"); continuing = create(); continuing->append(create(lhs, rhs)); @@ -165,8 +167,10 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) { nullptr, // constructor ast::VariableDecorationList{}))); // decorations - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = + create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = + create(mod.RegisterSymbol("rhs"), "rhs"); auto* continuing = create(); continuing->append(create(lhs, rhs)); diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc index ccf706d9a6..8bbc18ee6d 100644 --- a/src/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc @@ -66,8 +66,10 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) { nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* str = create("str"); - auto* mem = create("mem"); + auto* str = + create(mod.RegisterSymbol("str"), "str"); + auto* mem = + create(mod.RegisterSymbol("mem"), "mem"); ast::MemberAccessorExpression expr(str, mem); @@ -115,8 +117,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::MemberAccessorExpression expr(create("data"), - create("b")); + ast::MemberAccessorExpression expr( + create(mod.RegisterSymbol("data"), "data"), + create(mod.RegisterSymbol("b"), "b")); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -164,8 +167,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::MemberAccessorExpression expr(create("data"), - create("a")); + ast::MemberAccessorExpression expr( + create(mod.RegisterSymbol("data"), "data"), + create(mod.RegisterSymbol("a"), "a")); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -226,9 +230,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::VariableDecorationList{}); // decorations auto* lhs = create( - create("data"), - create("a")); - auto* rhs = create("b"); + create(mod.RegisterSymbol("data"), "data"), + create(mod.RegisterSymbol("a"), "a")); + auto* rhs = create(mod.RegisterSymbol("b"), "b"); ast::AssignmentStatement assign(lhs, rhs); @@ -289,8 +293,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::VariableDecorationList{}); // decorations auto* lhs = create( - create("data"), - create("a")); + create(mod.RegisterSymbol("data"), "data"), + create(mod.RegisterSymbol("a"), "a")); auto* rhs = create(&mat, ast::ExpressionList{}); @@ -349,8 +353,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::MemberAccessorExpression expr(create("data"), - create("a")); + ast::MemberAccessorExpression expr( + create(mod.RegisterSymbol("data"), "data"), + create(mod.RegisterSymbol("a"), "a")); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -405,8 +410,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::MemberAccessorExpression expr(create("data"), - create("a")); + ast::MemberAccessorExpression expr( + create(mod.RegisterSymbol("data"), "data"), + create(mod.RegisterSymbol("a"), "a")); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -453,8 +459,9 @@ TEST_F( nullptr, // constructor ast::VariableDecorationList{}); // decorations - ast::MemberAccessorExpression expr(create("data"), - create("a")); + ast::MemberAccessorExpression expr( + create(mod.RegisterSymbol("data"), "data"), + create(mod.RegisterSymbol("a"), "a")); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -508,8 +515,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::ArrayAccessorExpression expr( create( create( - create("data"), - create("a")), + create(mod.RegisterSymbol("data"), + "data"), + create(mod.RegisterSymbol("a"), "a")), create( create(&i32, 2))), create( @@ -562,8 +570,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::ArrayAccessorExpression expr( create( - create("data"), - create("a")), + create(mod.RegisterSymbol("data"), "data"), + create(mod.RegisterSymbol("a"), "a")), create( create(&i32, 2))); @@ -614,8 +622,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::ArrayAccessorExpression expr( create( - create("data"), - create("a")), + create(mod.RegisterSymbol("data"), "data"), + create(mod.RegisterSymbol("a"), "a")), create( ast::BinaryOp::kSubtract, create( @@ -681,8 +689,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ASSERT_TRUE(td.Determine()) << td.error(); auto* lhs = create( - create("data"), - create("b")); + create(mod.RegisterSymbol("data"), "data"), + create(mod.RegisterSymbol("b"), "b")); auto* rhs = create( create(&f32, 2.0f)); ast::AssignmentStatement assign(lhs, rhs); @@ -736,8 +744,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* lhs = create( create( - create("data"), - create("a")), + create(mod.RegisterSymbol("data"), "data"), + create(mod.RegisterSymbol("a"), "a")), create( create(&i32, 2))); auto* rhs = create( @@ -793,8 +801,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ASSERT_TRUE(td.Determine()) << td.error(); auto* lhs = create( - create("data"), - create("a")); + create(mod.RegisterSymbol("data"), "data"), + create(mod.RegisterSymbol("a"), "a")); auto* rhs = create( create(&i32, 2)); ast::AssignmentStatement assign(lhs, rhs); @@ -849,8 +857,9 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ASSERT_TRUE(td.Determine()) << td.error(); - ast::MemberAccessorExpression expr(create("data"), - create("b")); + ast::MemberAccessorExpression expr( + create(mod.RegisterSymbol("data"), "data"), + create(mod.RegisterSymbol("b"), "b")); ASSERT_TRUE(td.DetermineResultType(&expr)); ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error(); @@ -910,8 +919,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, values.push_back(create(lit3)); auto* lhs = create( - create("data"), - create("b")); + create(mod.RegisterSymbol("data"), "data"), + create(mod.RegisterSymbol("b"), "b")); auto* rhs = create(&fvec3, values); ast::AssignmentStatement assign(lhs, rhs); @@ -988,11 +997,12 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::MemberAccessorExpression expr( create( create( - create("data"), - create("c")), + create(mod.RegisterSymbol("data"), + "data"), + create(mod.RegisterSymbol("c"), "c")), create( create(&i32, 2))), - create("b")); + create(mod.RegisterSymbol("b"), "b")); ASSERT_TRUE(td.DetermineResultType(&expr)); ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error(); @@ -1066,12 +1076,14 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create( create( create( - create("data"), - create("c")), + create(mod.RegisterSymbol("data"), + "data"), + create(mod.RegisterSymbol("c"), + "c")), create( create(&i32, 2))), - create("b")), - create("xy")); + create(mod.RegisterSymbol("b"), "b")), + create(mod.RegisterSymbol("xy"), "xy")); ASSERT_TRUE(td.DetermineResultType(&expr)); ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error(); @@ -1144,12 +1156,14 @@ TEST_F( create( create( create( - create("data"), - create("c")), + create(mod.RegisterSymbol("data"), + "data"), + create(mod.RegisterSymbol("c"), + "c")), create( create(&i32, 2))), - create("b")), - create("g")); + create(mod.RegisterSymbol("b"), "b")), + create(mod.RegisterSymbol("g"), "g")); ASSERT_TRUE(td.DetermineResultType(&expr)); ASSERT_TRUE(gen.EmitExpression(pre, out, &expr)) << gen.error(); @@ -1221,11 +1235,13 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create( create( create( - create("data"), - create("c")), + create(mod.RegisterSymbol("data"), + "data"), + create(mod.RegisterSymbol("c"), + "c")), create( create(&i32, 2))), - create("b")), + create(mod.RegisterSymbol("b"), "b")), create( create(&i32, 1))); @@ -1298,11 +1314,12 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* lhs = create( create( create( - create("data"), - create("c")), + create(mod.RegisterSymbol("data"), + "data"), + create(mod.RegisterSymbol("c"), "c")), create( create(&i32, 2))), - create("b")); + create(mod.RegisterSymbol("b"), "b")); auto* lit1 = create(&f32, 1.f); auto* lit2 = create(&f32, 2.f); @@ -1388,12 +1405,14 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create( create( create( - create("data"), - create("c")), + create(mod.RegisterSymbol("data"), + "data"), + create(mod.RegisterSymbol("c"), + "c")), create( create(&i32, 2))), - create("b")), - create("y")); + create(mod.RegisterSymbol("b"), "b")), + create(mod.RegisterSymbol("y"), "y")); auto* rhs = create( create(&i32, 1.f)); diff --git a/src/writer/hlsl/generator_impl_return_test.cc b/src/writer/hlsl/generator_impl_return_test.cc index d2a6ad64e3..0b54dc036d 100644 --- a/src/writer/hlsl/generator_impl_return_test.cc +++ b/src/writer/hlsl/generator_impl_return_test.cc @@ -36,7 +36,8 @@ TEST_F(HlslGeneratorImplTest_Return, Emit_Return) { } TEST_F(HlslGeneratorImplTest_Return, Emit_ReturnWithValue) { - auto* expr = create("expr"); + auto* expr = + create(mod.RegisterSymbol("expr"), "expr"); ast::ReturnStatement r(Source{}, expr); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_switch_test.cc b/src/writer/hlsl/generator_impl_switch_test.cc index fa5f12d722..7e8ef38a75 100644 --- a/src/writer/hlsl/generator_impl_switch_test.cc +++ b/src/writer/hlsl/generator_impl_switch_test.cc @@ -48,7 +48,8 @@ TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) { body.push_back(case_stmt); body.push_back(def); - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); ast::SwitchStatement s(cond, body); gen.increment_indent(); diff --git a/src/writer/hlsl/generator_impl_test.cc b/src/writer/hlsl/generator_impl_test.cc index 1494fcf5e9..c93304a6ca 100644 --- a/src/writer/hlsl/generator_impl_test.cc +++ b/src/writer/hlsl/generator_impl_test.cc @@ -56,7 +56,8 @@ TEST_F(HlslGeneratorImplTest, InputStructName_ConflictWithExisting) { TEST_F(HlslGeneratorImplTest, NameConflictWith_InputStructName) { ASSERT_EQ(gen.generate_name("func_main_in"), "func_main_in"); - ast::IdentifierExpression ident("func_main_in"); + ast::IdentifierExpression ident(mod.RegisterSymbol("func_main_in"), + "func_main_in"); ASSERT_TRUE(gen.EmitIdentifier(pre, out, &ident)); EXPECT_EQ(result(), "func_main_in_0"); } diff --git a/src/writer/hlsl/generator_impl_unary_op_test.cc b/src/writer/hlsl/generator_impl_unary_op_test.cc index 7b9ed5fb7d..8a87e93d20 100644 --- a/src/writer/hlsl/generator_impl_unary_op_test.cc +++ b/src/writer/hlsl/generator_impl_unary_op_test.cc @@ -37,7 +37,8 @@ using HlslUnaryOpTest = TestParamHelper; TEST_P(HlslUnaryOpTest, Emit) { auto params = GetParam(); - auto* expr = create("expr"); + auto* expr = + create(mod.RegisterSymbol("expr"), "expr"); ast::UnaryOpExpression op(params.op, expr); ASSERT_TRUE(gen.EmitExpression(pre, out, &op)) << 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 35e2387885..a3609181d9 100644 --- a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc @@ -127,7 +127,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) { TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initializer_Private) { - auto* ident = create("initializer"); + auto* ident = create( + mod.RegisterSymbol("initializer"), "initializer"); ast::type::F32 f32; auto* var = diff --git a/src/writer/msl/generator_impl_array_accessor_test.cc b/src/writer/msl/generator_impl_array_accessor_test.cc index a584f80006..156077358c 100644 --- a/src/writer/msl/generator_impl_array_accessor_test.cc +++ b/src/writer/msl/generator_impl_array_accessor_test.cc @@ -35,7 +35,8 @@ TEST_F(MslGeneratorImplTest, EmitExpression_ArrayAccessor) { ast::type::I32 i32; auto* lit = create(&i32, 5); auto* idx = create(lit); - auto* ary = create("ary"); + auto* ary = + create(mod.RegisterSymbol("ary"), "ary"); ast::ArrayAccessorExpression expr(ary, idx); @@ -44,8 +45,10 @@ TEST_F(MslGeneratorImplTest, EmitExpression_ArrayAccessor) { } TEST_F(MslGeneratorImplTest, EmitArrayAccessor) { - auto* ary = create("ary"); - auto* idx = create("idx"); + auto* ary = + create(mod.RegisterSymbol("ary"), "ary"); + auto* idx = + create(mod.RegisterSymbol("idx"), "idx"); ast::ArrayAccessorExpression expr(ary, idx); diff --git a/src/writer/msl/generator_impl_assign_test.cc b/src/writer/msl/generator_impl_assign_test.cc index eb673fecf4..44df0fa331 100644 --- a/src/writer/msl/generator_impl_assign_test.cc +++ b/src/writer/msl/generator_impl_assign_test.cc @@ -30,8 +30,10 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_Assign) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = + create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = + create(mod.RegisterSymbol("rhs"), "rhs"); ast::AssignmentStatement assign(lhs, rhs); gen.increment_indent(); diff --git a/src/writer/msl/generator_impl_binary_test.cc b/src/writer/msl/generator_impl_binary_test.cc index 62e48ade14..dc378bdbe8 100644 --- a/src/writer/msl/generator_impl_binary_test.cc +++ b/src/writer/msl/generator_impl_binary_test.cc @@ -38,8 +38,10 @@ using MslBinaryTest = TestParamHelper; TEST_P(MslBinaryTest, Emit) { auto params = GetParam(); - auto* left = create("left"); - auto* right = create("right"); + auto* left = + create(mod.RegisterSymbol("left"), "left"); + auto* right = + create(mod.RegisterSymbol("right"), "right"); ast::BinaryExpression expr(params.op, left, right); diff --git a/src/writer/msl/generator_impl_bitcast_test.cc b/src/writer/msl/generator_impl_bitcast_test.cc index d6c1546b0c..bba7e43feb 100644 --- a/src/writer/msl/generator_impl_bitcast_test.cc +++ b/src/writer/msl/generator_impl_bitcast_test.cc @@ -31,7 +31,7 @@ using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitExpression_Bitcast) { ast::type::F32 f32; - auto* id = create("id"); + auto* id = create(mod.RegisterSymbol("id"), "id"); ast::BitcastExpression bitcast(&f32, id); ASSERT_TRUE(gen.EmitExpression(&bitcast)) << gen.error(); diff --git a/src/writer/msl/generator_impl_call_test.cc b/src/writer/msl/generator_impl_call_test.cc index 71024249ca..897a819dac 100644 --- a/src/writer/msl/generator_impl_call_test.cc +++ b/src/writer/msl/generator_impl_call_test.cc @@ -34,7 +34,8 @@ using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) { ast::type::Void void_type; - auto* id = create("my_func"); + auto* id = create(mod.RegisterSymbol("my_func"), + "my_func"); ast::CallExpression call(id, {}); auto* func = create( @@ -49,10 +50,13 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) { TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) { ast::type::Void void_type; - auto* id = create("my_func"); + auto* id = create(mod.RegisterSymbol("my_func"), + "my_func"); ast::ExpressionList params; - params.push_back(create("param1")); - params.push_back(create("param2")); + params.push_back(create( + mod.RegisterSymbol("param1"), "param1")); + params.push_back(create( + mod.RegisterSymbol("param2"), "param2")); ast::CallExpression call(id, params); auto* func = create( @@ -67,10 +71,13 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) { TEST_F(MslGeneratorImplTest, EmitStatement_Call) { ast::type::Void void_type; - auto* id = create("my_func"); + auto* id = create(mod.RegisterSymbol("my_func"), + "my_func"); ast::ExpressionList params; - params.push_back(create("param1")); - params.push_back(create("param2")); + params.push_back(create( + mod.RegisterSymbol("param1"), "param1")); + params.push_back(create( + mod.RegisterSymbol("param2"), "param2")); ast::CallStatement call(create(id, params)); auto* func = create( diff --git a/src/writer/msl/generator_impl_cast_test.cc b/src/writer/msl/generator_impl_cast_test.cc index 22ebedf7a9..c63fef312c 100644 --- a/src/writer/msl/generator_impl_cast_test.cc +++ b/src/writer/msl/generator_impl_cast_test.cc @@ -34,7 +34,8 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Cast_Scalar) { ast::type::F32 f32; ast::ExpressionList params; - params.push_back(create("id")); + params.push_back( + create(mod.RegisterSymbol("id"), "id")); ast::TypeConstructorExpression cast(&f32, params); @@ -47,7 +48,8 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Cast_Vector) { ast::type::Vector vec3(&f32, 3); ast::ExpressionList params; - params.push_back(create("id")); + params.push_back( + create(mod.RegisterSymbol("id"), "id")); ast::TypeConstructorExpression cast(&vec3, params); 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 f43ea3233b..eaf49e3887 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 @@ -83,11 +83,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Input) { ast::VariableList params; auto* body = create(); body->append(create( - create("foo"), - create("foo"))); + create(mod.RegisterSymbol("foo"), "foo"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create( - create("bar"), - create("bar"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("bar"), "bar"))); auto* func = create( Source{}, mod.RegisterSymbol("vtx_main"), "vtx_main", params, &f32, body, @@ -153,11 +153,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Output) { ast::VariableList params; auto* body = create(); body->append(create( - create("foo"), - create("foo"))); + create(mod.RegisterSymbol("foo"), "foo"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create( - create("bar"), - create("bar"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("bar"), "bar"))); auto* func = create( Source{}, mod.RegisterSymbol("vtx_main"), "vtx_main", params, &f32, body, @@ -223,11 +223,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Input) { ast::VariableList params; auto* body = create(); body->append(create( - create("foo"), - create("foo"))); + create(mod.RegisterSymbol("foo"), "foo"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create( - create("bar"), - create("bar"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("bar"), "bar"))); auto* func = create( Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body, ast::FunctionDecorationList{ @@ -292,11 +292,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Output) { ast::VariableList params; auto* body = create(); body->append(create( - create("foo"), - create("foo"))); + create(mod.RegisterSymbol("foo"), "foo"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create( - create("bar"), - create("bar"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("bar"), "bar"))); auto* func = create( Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body, @@ -359,11 +359,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Input) { ast::VariableList params; auto* body = create(); body->append(create( - create("foo"), - create("foo"))); + create(mod.RegisterSymbol("foo"), "foo"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create( - create("bar"), - create("bar"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("bar"), "bar"))); auto* func = create( Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body, @@ -421,11 +421,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Output) { ast::VariableList params; auto* body = create(); body->append(create( - create("foo"), - create("foo"))); + create(mod.RegisterSymbol("foo"), "foo"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create( - create("bar"), - create("bar"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("bar"), "bar"))); auto* func = create( Source{}, mod.RegisterSymbol("main"), "main", params, &f32, body, @@ -490,10 +490,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Builtins) { auto* body = create(); body->append(create( - create("depth"), + create(mod.RegisterSymbol("depth"), "depth"), create( - create("coord"), - create("x")))); + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("x"), "x")))); auto* func = create( Source{}, mod.RegisterSymbol("main"), "main", params, &void_type, body, diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc index 950e8fe8db..680441faae 100644 --- a/src/writer/msl/generator_impl_function_test.cc +++ b/src/writer/msl/generator_impl_function_test.cc @@ -179,8 +179,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithInOutVars) { ast::VariableList params; auto* body = create(); body->append(create( - create("bar"), - create("foo"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create(Source{})); auto* func = create( @@ -252,10 +252,11 @@ TEST_F(MslGeneratorImplTest, ast::VariableList params; auto* body = create(); body->append(create( - create("depth"), + create(mod.RegisterSymbol("depth"), "depth"), create( - create("coord"), - create("x")))); + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("x"), "x")))); body->append(create(Source{})); auto* func = create( @@ -315,8 +316,10 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) { &f32, // type false, // is_const create( - create("coord"), - create("x")), // constructor + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("x"), + "x")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); @@ -392,8 +395,10 @@ TEST_F(MslGeneratorImplTest, &f32, // type false, // is_const create( - create("coord"), - create("b")), // constructor + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("b"), + "b")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); @@ -474,8 +479,10 @@ TEST_F(MslGeneratorImplTest, &f32, // type false, // is_const create( - create("coord"), - create("b")), // constructor + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("b"), + "b")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); @@ -571,13 +578,14 @@ TEST_F( auto* body = create(); body->append(create( - create("bar"), - create("foo"))); + create(mod.RegisterSymbol("bar"), "bar"), + create(mod.RegisterSymbol("foo"), "foo"))); body->append(create( - create("val"), - create("param"))); + create(mod.RegisterSymbol("val"), "val"), + create(mod.RegisterSymbol("param"), "param"))); body->append(create( - Source{}, create("foo"))); + Source{}, + create(mod.RegisterSymbol("foo"), "foo"))); auto* sub_func = create( Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body, ast::FunctionDecorationList{}); @@ -590,9 +598,11 @@ TEST_F( body = create(); body->append(create( - create("bar"), - create(create("sub_func"), - expr))); + create(mod.RegisterSymbol("bar"), "bar"), + create( + create(mod.RegisterSymbol("sub_func"), + "sub_func"), + expr))); body->append(create(Source{})); auto* func_1 = create( Source{}, mod.RegisterSymbol("ep_1"), "ep_1", params, &void_type, body, @@ -665,7 +675,8 @@ TEST_F(MslGeneratorImplTest, auto* body = create(); body->append(create( - Source{}, create("param"))); + Source{}, + create(mod.RegisterSymbol("param"), "param"))); auto* sub_func = create( Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body, ast::FunctionDecorationList{}); @@ -678,9 +689,11 @@ TEST_F(MslGeneratorImplTest, body = create(); body->append(create( - create("depth"), - create(create("sub_func"), - expr))); + create(mod.RegisterSymbol("depth"), "depth"), + create( + create(mod.RegisterSymbol("sub_func"), + "sub_func"), + expr))); body->append(create(Source{})); auto* func_1 = create( @@ -762,12 +775,14 @@ TEST_F( auto* body = create(); body->append(create( - create("depth"), + create(mod.RegisterSymbol("depth"), "depth"), create( - create("coord"), - create("x")))); + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("x"), "x")))); body->append(create( - Source{}, create("param"))); + Source{}, + create(mod.RegisterSymbol("param"), "param"))); auto* sub_func = create( Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body, ast::FunctionDecorationList{}); @@ -780,9 +795,11 @@ TEST_F( body = create(); body->append(create( - create("depth"), - create(create("sub_func"), - expr))); + create(mod.RegisterSymbol("depth"), "depth"), + create( + create(mod.RegisterSymbol("sub_func"), + "sub_func"), + expr))); body->append(create(Source{})); auto* func_1 = create( Source{}, mod.RegisterSymbol("ep_1"), "ep_1", params, &void_type, body, @@ -849,9 +866,11 @@ TEST_F(MslGeneratorImplTest, auto* body = create(); body->append(create( - Source{}, create( - create("coord"), - create("x")))); + Source{}, + create( + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("x"), "x")))); auto* sub_func = create( Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body, ast::FunctionDecorationList{}); @@ -862,15 +881,17 @@ TEST_F(MslGeneratorImplTest, expr.push_back(create( create(&f32, 1.0f))); - auto* var = create( - Source{}, // source - "v", // name - ast::StorageClass::kFunction, // storage_class - &f32, // type - false, // is_const - create(create("sub_func"), - expr), // constructor - ast::VariableDecorationList{}); // decorations + auto* var = + create(Source{}, // source + "v", // name + ast::StorageClass::kFunction, // storage_class + &f32, // type + false, // is_const + create( + create( + mod.RegisterSymbol("sub_func"), "sub_func"), + expr), // constructor + ast::VariableDecorationList{}); // decorations body = create(); body->append(create(var)); @@ -951,9 +972,11 @@ TEST_F(MslGeneratorImplTest, auto* body = create(); body->append(create( - Source{}, create( - create("coord"), - create("b")))); + Source{}, + create( + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("b"), "b")))); auto* sub_func = create( Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body, ast::FunctionDecorationList{}); @@ -964,15 +987,17 @@ TEST_F(MslGeneratorImplTest, expr.push_back(create( create(&f32, 1.0f))); - auto* var = create( - Source{}, // source - "v", // name - ast::StorageClass::kFunction, // storage_class - &f32, // type - false, // is_const - create(create("sub_func"), - expr), // constructor - ast::VariableDecorationList{}); // decorations + auto* var = + create(Source{}, // source + "v", // name + ast::StorageClass::kFunction, // storage_class + &f32, // type + false, // is_const + create( + create( + mod.RegisterSymbol("sub_func"), "sub_func"), + expr), // constructor + ast::VariableDecorationList{}); // decorations body = create(); body->append(create(var)); @@ -1059,9 +1084,11 @@ TEST_F(MslGeneratorImplTest, auto* body = create(); body->append(create( - Source{}, create( - create("coord"), - create("b")))); + Source{}, + create( + create(mod.RegisterSymbol("coord"), + "coord"), + create(mod.RegisterSymbol("b"), "b")))); auto* sub_func = create( Source{}, mod.RegisterSymbol("sub_func"), "sub_func", params, &f32, body, ast::FunctionDecorationList{}); @@ -1072,15 +1099,17 @@ TEST_F(MslGeneratorImplTest, expr.push_back(create( create(&f32, 1.0f))); - auto* var = create( - Source{}, // source - "v", // name - ast::StorageClass::kFunction, // storage_class - &f32, // type - false, // is_const - create(create("sub_func"), - expr), // constructor - ast::VariableDecorationList{}); // decorations + auto* var = + create(Source{}, // source + "v", // name + ast::StorageClass::kFunction, // storage_class + &f32, // type + false, // is_const + create( + create( + mod.RegisterSymbol("sub_func"), "sub_func"), + expr), // constructor + ast::VariableDecorationList{}); // decorations body = create(); body->append(create(var)); @@ -1141,7 +1170,7 @@ TEST_F(MslGeneratorImplTest, ast::VariableList params; auto* body = create(); body->append(create( - create("bar"), + create(mod.RegisterSymbol("bar"), "bar"), create( create(&f32, 1.0f)))); @@ -1306,8 +1335,10 @@ TEST_F(MslGeneratorImplTest, &f32, // type false, // is_const create( - create("data"), - create("d")), // constructor + create(mod.RegisterSymbol("data"), + "data"), + create(mod.RegisterSymbol("d"), + "d")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); @@ -1333,8 +1364,10 @@ TEST_F(MslGeneratorImplTest, &f32, // type false, // is_const create( - create("data"), - create("d")), // constructor + create(mod.RegisterSymbol("data"), + "data"), + create(mod.RegisterSymbol("d"), + "d")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); diff --git a/src/writer/msl/generator_impl_identifier_test.cc b/src/writer/msl/generator_impl_identifier_test.cc index d5be38b04f..94f6be87c8 100644 --- a/src/writer/msl/generator_impl_identifier_test.cc +++ b/src/writer/msl/generator_impl_identifier_test.cc @@ -26,14 +26,14 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitIdentifierExpression) { - ast::IdentifierExpression i("foo"); + ast::IdentifierExpression i(mod.RegisterSymbol("foo"), "foo"); ASSERT_TRUE(gen.EmitExpression(&i)) << gen.error(); EXPECT_EQ(gen.result(), "foo"); } TEST_F(MslGeneratorImplTest, EmitIdentifierExpression_Single_WithCollision) { - ast::IdentifierExpression i("virtual"); + ast::IdentifierExpression i(mod.RegisterSymbol("virtual"), "virtual"); ASSERT_TRUE(gen.EmitExpression(&i)) << gen.error(); EXPECT_EQ(gen.result(), "virtual_tint_0"); diff --git a/src/writer/msl/generator_impl_if_test.cc b/src/writer/msl/generator_impl_if_test.cc index 3a86c4d165..be01567ad0 100644 --- a/src/writer/msl/generator_impl_if_test.cc +++ b/src/writer/msl/generator_impl_if_test.cc @@ -29,7 +29,8 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_If) { - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create(Source{})); @@ -45,11 +46,13 @@ TEST_F(MslGeneratorImplTest, Emit_If) { } TEST_F(MslGeneratorImplTest, Emit_IfWithElseIf) { - auto* else_cond = create("else_cond"); + auto* else_cond = create( + mod.RegisterSymbol("else_cond"), "else_cond"); auto* else_body = create(); else_body->append(create(Source{})); - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create(Source{})); @@ -71,7 +74,8 @@ TEST_F(MslGeneratorImplTest, Emit_IfWithElse) { auto* else_body = create(); else_body->append(create(Source{})); - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create(Source{})); @@ -90,7 +94,8 @@ TEST_F(MslGeneratorImplTest, Emit_IfWithElse) { } TEST_F(MslGeneratorImplTest, Emit_IfWithMultiple) { - auto* else_cond = create("else_cond"); + auto* else_cond = create( + mod.RegisterSymbol("else_cond"), "else_cond"); auto* else_body = create(); else_body->append(create(Source{})); @@ -98,7 +103,8 @@ TEST_F(MslGeneratorImplTest, Emit_IfWithMultiple) { auto* else_body_2 = create(); else_body_2->append(create(Source{})); - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create(Source{})); diff --git a/src/writer/msl/generator_impl_import_test.cc b/src/writer/msl/generator_impl_import_test.cc index 76b5e1c4af..d543348bb3 100644 --- a/src/writer/msl/generator_impl_import_test.cc +++ b/src/writer/msl/generator_impl_import_test.cc @@ -57,7 +57,8 @@ TEST_P(MslImportData_SingleParamTest, FloatScalar) { params.push_back(create( create(&f32, 1.f))); - auto* ident = create(param.name); + auto* ident = create( + mod.RegisterSymbol(param.name), param.name); ast::CallExpression call(ident, params); @@ -100,7 +101,9 @@ TEST_F(MslGeneratorImplTest, MslImportData_SingleParamTest_IntScalar) { params.push_back(create( create(&i32, 1))); - ast::CallExpression expr(create("abs"), params); + ast::CallExpression expr( + create(mod.RegisterSymbol("abs"), "abs"), + params); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -120,7 +123,8 @@ TEST_P(MslImportData_DualParamTest, FloatScalar) { params.push_back(create( create(&f32, 2.f))); - ast::CallExpression expr(create(param.name), + ast::CallExpression expr(create( + mod.RegisterSymbol(param.name), param.name), params); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -168,7 +172,8 @@ TEST_P(MslImportData_DualParam_VectorTest, FloatVector) { create(&f32, 6.f)), })); - ast::CallExpression expr(create(param.name), + ast::CallExpression expr(create( + mod.RegisterSymbol(param.name), param.name), params); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -193,7 +198,8 @@ TEST_P(MslImportData_DualParam_Int_Test, IntScalar) { params.push_back(create( create(&i32, 2))); - ast::CallExpression expr(create(param.name), + ast::CallExpression expr(create( + mod.RegisterSymbol(param.name), param.name), params); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -219,7 +225,8 @@ TEST_P(MslImportData_TripleParamTest, FloatScalar) { params.push_back(create( create(&f32, 3.f))); - ast::CallExpression expr(create(param.name), + ast::CallExpression expr(create( + mod.RegisterSymbol(param.name), param.name), params); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -250,7 +257,8 @@ TEST_P(MslImportData_TripleParam_Int_Test, IntScalar) { params.push_back(create( create(&i32, 3))); - ast::CallExpression expr(create(param.name), + ast::CallExpression expr(create( + mod.RegisterSymbol(param.name), param.name), params); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -277,10 +285,13 @@ TEST_F(MslGeneratorImplTest, MslImportData_Determinant) { ast::VariableDecorationList{}); // decorations ast::ExpressionList params; - params.push_back(create("var")); + params.push_back( + create(mod.RegisterSymbol("var"), "var")); - ast::CallExpression expr(create("determinant"), - params); + ast::CallExpression expr( + create(mod.RegisterSymbol("determinant"), + "determinant"), + params); mod.AddGlobalVariable(var); diff --git a/src/writer/msl/generator_impl_intrinsic_test.cc b/src/writer/msl/generator_impl_intrinsic_test.cc index 33b5a63313..c8199431de 100644 --- a/src/writer/msl/generator_impl_intrinsic_test.cc +++ b/src/writer/msl/generator_impl_intrinsic_test.cc @@ -88,11 +88,15 @@ TEST_F(MslGeneratorImplTest, DISABLED_Intrinsic_OuterProduct) { ast::VariableDecorationList{}); // decorations ast::ExpressionList params; - params.push_back(create("a")); - params.push_back(create("b")); + params.push_back( + create(mod.RegisterSymbol("a"), "a")); + params.push_back( + create(mod.RegisterSymbol("b"), "b")); - ast::CallExpression call(create("outer_product"), - params); + ast::CallExpression call( + create(mod.RegisterSymbol("outer_product"), + "outer_product"), + params); td.RegisterVariableForTesting(a); td.RegisterVariableForTesting(b); @@ -117,10 +121,14 @@ TEST_F(MslGeneratorImplTest, Intrinsic_Call) { ast::type::Vector vec(&f32, 3); ast::ExpressionList params; - params.push_back(create("param1")); - params.push_back(create("param2")); + params.push_back(create( + mod.RegisterSymbol("param1"), "param1")); + params.push_back(create( + mod.RegisterSymbol("param2"), "param2")); - ast::CallExpression call(create("dot"), params); + ast::CallExpression call( + create(mod.RegisterSymbol("dot"), "dot"), + params); ast::Variable v1(Source{}, "param1", ast::StorageClass::kFunction, &vec, false, nullptr, ast::VariableDecorationList{}); diff --git a/src/writer/msl/generator_impl_loop_test.cc b/src/writer/msl/generator_impl_loop_test.cc index fa18cb3da3..b6c91fdf9d 100644 --- a/src/writer/msl/generator_impl_loop_test.cc +++ b/src/writer/msl/generator_impl_loop_test.cc @@ -90,8 +90,10 @@ TEST_F(MslGeneratorImplTest, Emit_LoopNestedWithContinuing) { body = create(); body->append(inner); - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = + create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = + create(mod.RegisterSymbol("rhs"), "rhs"); continuing = create(); continuing->append(create(lhs, rhs)); @@ -170,8 +172,10 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) { nullptr, // constructor ast::VariableDecorationList{}))); // decorations - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = + create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = + create(mod.RegisterSymbol("rhs"), "rhs"); auto* continuing = create(); continuing->append(create(lhs, rhs)); diff --git a/src/writer/msl/generator_impl_member_accessor_test.cc b/src/writer/msl/generator_impl_member_accessor_test.cc index 7672a01cf9..643f34e7e4 100644 --- a/src/writer/msl/generator_impl_member_accessor_test.cc +++ b/src/writer/msl/generator_impl_member_accessor_test.cc @@ -29,8 +29,10 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor) { - auto* str = create("str"); - auto* mem = create("mem"); + auto* str = + create(mod.RegisterSymbol("str"), "str"); + auto* mem = + create(mod.RegisterSymbol("mem"), "mem"); ast::MemberAccessorExpression expr(str, mem); diff --git a/src/writer/msl/generator_impl_return_test.cc b/src/writer/msl/generator_impl_return_test.cc index be2138e25b..c285996a56 100644 --- a/src/writer/msl/generator_impl_return_test.cc +++ b/src/writer/msl/generator_impl_return_test.cc @@ -39,7 +39,8 @@ TEST_F(MslGeneratorImplTest, Emit_Return) { } TEST_F(MslGeneratorImplTest, Emit_ReturnWithValue) { - auto* expr = create("expr"); + auto* expr = + create(mod.RegisterSymbol("expr"), "expr"); ast::ReturnStatement r(Source{}, expr); gen.increment_indent(); diff --git a/src/writer/msl/generator_impl_switch_test.cc b/src/writer/msl/generator_impl_switch_test.cc index 88dd603062..fd69599ce3 100644 --- a/src/writer/msl/generator_impl_switch_test.cc +++ b/src/writer/msl/generator_impl_switch_test.cc @@ -50,7 +50,8 @@ TEST_F(MslGeneratorImplTest, Emit_Switch) { body.push_back(case_stmt); body.push_back(def); - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); ast::SwitchStatement s(cond, body); gen.increment_indent(); diff --git a/src/writer/msl/generator_impl_test.cc b/src/writer/msl/generator_impl_test.cc index 0ba3247204..de0bbf279d 100644 --- a/src/writer/msl/generator_impl_test.cc +++ b/src/writer/msl/generator_impl_test.cc @@ -79,7 +79,8 @@ TEST_F(MslGeneratorImplTest, InputStructName_ConflictWithExisting) { TEST_F(MslGeneratorImplTest, NameConflictWith_InputStructName) { ASSERT_EQ(gen.generate_name("func_main_in"), "func_main_in"); - ast::IdentifierExpression ident("func_main_in"); + ast::IdentifierExpression ident(mod.RegisterSymbol("func_main_in"), + "func_main_in"); ASSERT_TRUE(gen.EmitIdentifier(&ident)); EXPECT_EQ(gen.result(), "func_main_in_0"); } diff --git a/src/writer/msl/generator_impl_unary_op_test.cc b/src/writer/msl/generator_impl_unary_op_test.cc index a676558c56..d054bce510 100644 --- a/src/writer/msl/generator_impl_unary_op_test.cc +++ b/src/writer/msl/generator_impl_unary_op_test.cc @@ -39,7 +39,8 @@ using MslUnaryOpTest = TestParamHelper; TEST_P(MslUnaryOpTest, Emit) { auto params = GetParam(); - auto* expr = create("expr"); + auto* expr = + create(mod.RegisterSymbol("expr"), "expr"); ast::UnaryOpExpression op(params.op, expr); ASSERT_TRUE(gen.EmitExpression(&op)) << gen.error(); 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 8397d508fb..50a2830fbc 100644 --- a/src/writer/msl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/msl/generator_impl_variable_decl_statement_test.cc @@ -193,7 +193,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) { } TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) { - auto* ident = create("initializer"); + auto* ident = create( + mod.RegisterSymbol("initializer"), "initializer"); ast::type::F32 f32; auto* var = diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc index f46d48e383..6fbdbf5967 100644 --- a/src/writer/spirv/builder_accessor_expression_test.cc +++ b/src/writer/spirv/builder_accessor_expression_test.cc @@ -56,7 +56,8 @@ TEST_F(BuilderTest, ArrayAccessor) { ast::Variable var(Source{}, "ary", ast::StorageClass::kFunction, &vec3, false, nullptr, ast::VariableDecorationList{}); - auto* ary = create("ary"); + auto* ary = + create(mod->RegisterSymbol("ary"), "ary"); auto* idx_expr = create( create(&i32, 1)); @@ -100,8 +101,10 @@ TEST_F(BuilderTest, Accessor_Array_LoadIndex) { ast::Variable idx(Source{}, "idx", ast::StorageClass::kFunction, &i32, false, nullptr, ast::VariableDecorationList{}); - auto* ary = create("ary"); - auto* idx_expr = create("idx"); + auto* ary = + create(mod->RegisterSymbol("ary"), "ary"); + auto* idx_expr = + create(mod->RegisterSymbol("idx"), "idx"); ast::ArrayAccessorExpression expr(ary, idx_expr); @@ -145,7 +148,8 @@ TEST_F(BuilderTest, ArrayAccessor_Dynamic) { ast::Variable var(Source{}, "ary", ast::StorageClass::kFunction, &vec3, false, nullptr, ast::VariableDecorationList{}); - auto* ary = create("ary"); + auto* ary = + create(mod->RegisterSymbol("ary"), "ary"); ast::ArrayAccessorExpression expr( ary, @@ -195,7 +199,7 @@ TEST_F(BuilderTest, ArrayAccessor_MultiLevel) { ast::ArrayAccessorExpression expr( create( - create("ary"), + create(mod->RegisterSymbol("ary"), "ary"), create( create(&i32, 3))), create( @@ -243,10 +247,10 @@ TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) { ast::MemberAccessorExpression expr( create( - create("ary"), + create(mod->RegisterSymbol("ary"), "ary"), create( create(&i32, 2))), - create("xy")); + create(mod->RegisterSymbol("xy"), "xy")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -298,8 +302,9 @@ TEST_F(BuilderTest, MemberAccessor) { ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type, false, nullptr, ast::VariableDecorationList{}); - ast::MemberAccessorExpression expr(create("ident"), - create("b")); + ast::MemberAccessorExpression expr( + create(mod->RegisterSymbol("ident"), "ident"), + create(mod->RegisterSymbol("b"), "b")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -355,9 +360,11 @@ TEST_F(BuilderTest, MemberAccessor_Nested) { ast::MemberAccessorExpression expr( create( - create("ident"), - create("inner")), - create("a")); + create(mod->RegisterSymbol("ident"), + "ident"), + create(mod->RegisterSymbol("inner"), + "inner")), + create(mod->RegisterSymbol("a"), "a")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -416,9 +423,11 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) { ast::MemberAccessorExpression expr( create( - create("ident"), - create("inner")), - create("a")); + create(mod->RegisterSymbol("ident"), + "ident"), + create(mod->RegisterSymbol("inner"), + "inner")), + create(mod->RegisterSymbol("a"), "a")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -476,9 +485,11 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) { auto* lhs = create( create( - create("ident"), - create("inner")), - create("a")); + create(mod->RegisterSymbol("ident"), + "ident"), + create(mod->RegisterSymbol("inner"), + "inner")), + create(mod->RegisterSymbol("a"), "a")); auto* rhs = create( create(&f32, 2.f)); @@ -543,13 +554,16 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) { ast::Variable store(Source{}, "store", ast::StorageClass::kFunction, &f32, false, nullptr, ast::VariableDecorationList{}); - auto* lhs = create("store"); + auto* lhs = + create(mod->RegisterSymbol("store"), "store"); auto* rhs = create( create( - create("ident"), - create("inner")), - create("a")); + create(mod->RegisterSymbol("ident"), + "ident"), + create(mod->RegisterSymbol("inner"), + "inner")), + create(mod->RegisterSymbol("a"), "a")); ast::AssignmentStatement expr(lhs, rhs); @@ -593,8 +607,9 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_Single) { ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &vec3, false, nullptr, ast::VariableDecorationList{}); - ast::MemberAccessorExpression expr(create("ident"), - create("y")); + ast::MemberAccessorExpression expr( + create(mod->RegisterSymbol("ident"), "ident"), + create(mod->RegisterSymbol("y"), "y")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -629,8 +644,9 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_MultipleNames) { ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &vec3, false, nullptr, ast::VariableDecorationList{}); - ast::MemberAccessorExpression expr(create("ident"), - create("yx")); + ast::MemberAccessorExpression expr( + create(mod->RegisterSymbol("ident"), "ident"), + create(mod->RegisterSymbol("yx"), "yx")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -666,9 +682,10 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_of_Swizzle) { ast::MemberAccessorExpression expr( create( - create("ident"), - create("yxz")), - create("xz")); + create(mod->RegisterSymbol("ident"), + "ident"), + create(mod->RegisterSymbol("yxz"), "yxz")), + create(mod->RegisterSymbol("xz"), "xz")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -705,9 +722,10 @@ TEST_F(BuilderTest, MemberAccessor_Member_of_Swizzle) { ast::MemberAccessorExpression expr( create( - create("ident"), - create("yxz")), - create("x")); + create(mod->RegisterSymbol("ident"), + "ident"), + create(mod->RegisterSymbol("yxz"), "yxz")), + create(mod->RegisterSymbol("x"), "x")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -744,8 +762,9 @@ TEST_F(BuilderTest, MemberAccessor_Array_of_Swizzle) { ast::ArrayAccessorExpression expr( create( - create("ident"), - create("yxz")), + create(mod->RegisterSymbol("ident"), + "ident"), + create(mod->RegisterSymbol("yxz"), "yxz")), create( create(&i32, 1))); @@ -818,15 +837,18 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) { create( create( create( - create("index"), + create( + mod->RegisterSymbol("index"), "index"), create( create(&i32, 0))), - create("foo")), + create( + mod->RegisterSymbol("foo"), "foo")), create( create(&i32, 2))), - create("bar")), - create("baz")), - create("yx")); + create(mod->RegisterSymbol("bar"), + "bar")), + create(mod->RegisterSymbol("baz"), "baz")), + create(mod->RegisterSymbol("yx"), "yx")); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); @@ -906,9 +928,10 @@ TEST_F(BuilderTest, Accessor_Array_Of_Vec) { create(&arr, ary_params), ast::VariableDecorationList{}); - ast::ArrayAccessorExpression expr(create("pos"), - create( - create(&u32, 1))); + ast::ArrayAccessorExpression expr( + create(mod->RegisterSymbol("pos"), "pos"), + create( + create(&u32, 1))); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(var.constructor())) << td.error(); @@ -963,9 +986,10 @@ TEST_F(BuilderTest, Accessor_Const_Vec) { create(&vec, std::move(vec_params)), ast::VariableDecorationList{}); - ast::ArrayAccessorExpression expr(create("pos"), - create( - create(&u32, 1))); + ast::ArrayAccessorExpression expr( + create(mod->RegisterSymbol("pos"), "pos"), + create( + create(&u32, 1))); td.RegisterVariableForTesting(&var); ASSERT_TRUE(td.DetermineResultType(var.constructor())) << td.error(); diff --git a/src/writer/spirv/builder_assign_test.cc b/src/writer/spirv/builder_assign_test.cc index cee9950f1b..2285beb8bd 100644 --- a/src/writer/spirv/builder_assign_test.cc +++ b/src/writer/spirv/builder_assign_test.cc @@ -47,7 +47,8 @@ TEST_F(BuilderTest, Assign_Var) { ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32, false, nullptr, ast::VariableDecorationList{}); - auto* ident = create("var"); + auto* ident = + create(mod->RegisterSymbol("var"), "var"); auto* val = create( create(&f32, 1.0f)); @@ -82,7 +83,8 @@ TEST_F(BuilderTest, Assign_Var_ZeroConstructor) { ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec, false, nullptr, ast::VariableDecorationList{}); - auto* ident = create("var"); + auto* ident = + create(mod->RegisterSymbol("var"), "var"); ast::ExpressionList vals; auto* val = create(&vec, vals); @@ -133,8 +135,9 @@ TEST_F(BuilderTest, Assign_Var_Complex_ConstructorWithExtract) { ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3, false, nullptr, ast::VariableDecorationList{}); - ast::AssignmentStatement assign(create("var"), - init); + ast::AssignmentStatement assign( + create(mod->RegisterSymbol("var"), "var"), + init); td.RegisterVariableForTesting(&v); ASSERT_TRUE(td.DetermineResultType(&assign)) << td.error(); @@ -182,8 +185,9 @@ TEST_F(BuilderTest, Assign_Var_Complex_Constructor) { ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3, false, nullptr, ast::VariableDecorationList{}); - ast::AssignmentStatement assign(create("var"), - init); + ast::AssignmentStatement assign( + create(mod->RegisterSymbol("var"), "var"), + init); td.RegisterVariableForTesting(&v); ASSERT_TRUE(td.DetermineResultType(&assign)) << td.error(); @@ -231,8 +235,8 @@ TEST_F(BuilderTest, Assign_StructMember) { false, nullptr, ast::VariableDecorationList{}); auto* ident = create( - create("ident"), - create("b")); + create(mod->RegisterSymbol("ident"), "ident"), + create(mod->RegisterSymbol("b"), "b")); auto* val = create( create(&f32, 4.0f)); @@ -273,7 +277,8 @@ TEST_F(BuilderTest, Assign_Vector) { ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3, false, nullptr, ast::VariableDecorationList{}); - auto* ident = create("var"); + auto* ident = + create(mod->RegisterSymbol("var"), "var"); ast::ExpressionList vals; vals.push_back(create( @@ -322,8 +327,8 @@ TEST_F(BuilderTest, Assign_Vector_MemberByName) { nullptr, ast::VariableDecorationList{}); auto* ident = create( - create("var"), - create("y")); + create(mod->RegisterSymbol("var"), "var"), + create(mod->RegisterSymbol("y"), "y")); auto* val = create( create(&f32, 1.0f)); @@ -368,7 +373,7 @@ TEST_F(BuilderTest, Assign_Vector_MemberByIndex) { nullptr, ast::VariableDecorationList{}); auto* ident = create( - create("var"), + create(mod->RegisterSymbol("var"), "var"), create( create(&i32, 1))); auto* val = create( diff --git a/src/writer/spirv/builder_binary_expression_test.cc b/src/writer/spirv/builder_binary_expression_test.cc index 60d9828b87..880834ea71 100644 --- a/src/writer/spirv/builder_binary_expression_test.cc +++ b/src/writer/spirv/builder_binary_expression_test.cc @@ -124,8 +124,10 @@ TEST_P(BinaryArithSignedIntegerTest, Scalar_Loads) { ast::Variable var(Source{}, "param", ast::StorageClass::kFunction, &i32, false, nullptr, ast::VariableDecorationList{}); - auto* lhs = create("param"); - auto* rhs = create("param"); + auto* lhs = + create(mod->RegisterSymbol("param"), "param"); + auto* rhs = + create(mod->RegisterSymbol("param"), "param"); ast::BinaryExpression expr(param.op, lhs, rhs); @@ -642,7 +644,8 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixScalar) { false, // is_const nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* lhs = create("mat"); + auto* lhs = + create(mod->RegisterSymbol("mat"), "mat"); auto* rhs = create( create(&f32, 1.f)); @@ -683,7 +686,8 @@ TEST_F(BuilderTest, Binary_Multiply_ScalarMatrix) { ast::VariableDecorationList{}); // decorations auto* lhs = create( create(&f32, 1.f)); - auto* rhs = create("mat"); + auto* rhs = + create(mod->RegisterSymbol("mat"), "mat"); td.RegisterVariableForTesting(var); @@ -721,7 +725,8 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixVector) { false, // is_const nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* lhs = create("mat"); + auto* lhs = + create(mod->RegisterSymbol("mat"), "mat"); ast::ExpressionList vals; vals.push_back(create( @@ -779,7 +784,8 @@ TEST_F(BuilderTest, Binary_Multiply_VectorMatrix) { create(&f32, 1.f))); auto* lhs = create(&vec3, vals); - auto* rhs = create("mat"); + auto* rhs = + create(mod->RegisterSymbol("mat"), "mat"); td.RegisterVariableForTesting(var); @@ -818,8 +824,10 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixMatrix) { false, // is_const nullptr, // constructor ast::VariableDecorationList{}); // decorations - auto* lhs = create("mat"); - auto* rhs = create("mat"); + auto* lhs = + create(mod->RegisterSymbol("mat"), "mat"); + auto* rhs = + create(mod->RegisterSymbol("mat"), "mat"); td.RegisterVariableForTesting(var); @@ -911,8 +919,8 @@ TEST_F(BuilderTest, Binary_LogicalAnd_WithLoads) { create(&bool_type, false)), // constructor ast::VariableDecorationList{}); // decorations - auto* lhs = create("a"); - auto* rhs = create("b"); + auto* lhs = create(mod->RegisterSymbol("a"), "a"); + auto* rhs = create(mod->RegisterSymbol("b"), "b"); td.RegisterVariableForTesting(a_var); td.RegisterVariableForTesting(b_var); @@ -1107,8 +1115,8 @@ TEST_F(BuilderTest, Binary_LogicalOr_WithLoads) { create(&bool_type, false)), // constructor ast::VariableDecorationList{}); // decorations - auto* lhs = create("a"); - auto* rhs = create("b"); + auto* lhs = create(mod->RegisterSymbol("a"), "a"); + auto* rhs = create(mod->RegisterSymbol("b"), "b"); td.RegisterVariableForTesting(a_var); td.RegisterVariableForTesting(b_var); diff --git a/src/writer/spirv/builder_block_test.cc b/src/writer/spirv/builder_block_test.cc index 9d82125938..838a08445a 100644 --- a/src/writer/spirv/builder_block_test.cc +++ b/src/writer/spirv/builder_block_test.cc @@ -50,7 +50,7 @@ TEST_F(BuilderTest, Block) { nullptr, // constructor ast::VariableDecorationList{}))); // decorations outer.append(create( - create("var"), + create(mod->RegisterSymbol("var"), "var"), create( create(&f32, 1.0f)))); @@ -64,13 +64,13 @@ TEST_F(BuilderTest, Block) { nullptr, // constructor ast::VariableDecorationList{}))); // decorations inner->append(create( - create("var"), + create(mod->RegisterSymbol("var"), "var"), create( create(&f32, 2.0f)))); outer.append(inner); outer.append(create( - create("var"), + create(mod->RegisterSymbol("var"), "var"), create( create(&f32, 3.0f)))); diff --git a/src/writer/spirv/builder_call_test.cc b/src/writer/spirv/builder_call_test.cc index a4585a5189..8cc1ba25d1 100644 --- a/src/writer/spirv/builder_call_test.cc +++ b/src/writer/spirv/builder_call_test.cc @@ -1,3 +1,4 @@ + // Copyright 2020 The Tint Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -62,9 +63,11 @@ TEST_F(BuilderTest, Expression_Call) { auto* body = create(); body->append(create( - Source{}, create( - ast::BinaryOp::kAdd, create("a"), - create("b")))); + Source{}, + create( + ast::BinaryOp::kAdd, + create(mod->RegisterSymbol("a"), "a"), + create(mod->RegisterSymbol("b"), "b")))); ast::Function a_func(Source{}, mod->RegisterSymbol("a_func"), "a_func", func_params, &f32, body, ast::FunctionDecorationList{}); @@ -78,7 +81,8 @@ TEST_F(BuilderTest, Expression_Call) { call_params.push_back(create( create(&f32, 1.f))); - ast::CallExpression expr(create("a_func"), + ast::CallExpression expr(create( + mod->RegisterSymbol("a_func"), "a_func"), call_params); ASSERT_TRUE(td.DetermineFunction(&func)) << td.error(); @@ -139,9 +143,11 @@ TEST_F(BuilderTest, Statement_Call) { auto* body = create(); body->append(create( - Source{}, create( - ast::BinaryOp::kAdd, create("a"), - create("b")))); + Source{}, + create( + ast::BinaryOp::kAdd, + create(mod->RegisterSymbol("a"), "a"), + create(mod->RegisterSymbol("b"), "b")))); ast::Function a_func(Source{}, mod->RegisterSymbol("a_func"), "a_func", func_params, &void_type, body, @@ -157,8 +163,10 @@ TEST_F(BuilderTest, Statement_Call) { call_params.push_back(create( create(&f32, 1.f))); - ast::CallStatement expr(create( - create("a_func"), call_params)); + ast::CallStatement expr( + create(create( + 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_function_decoration_test.cc b/src/writer/spirv/builder_function_decoration_test.cc index dfab021c72..f349f2eb9c 100644 --- a/src/writer/spirv/builder_function_decoration_test.cc +++ b/src/writer/spirv/builder_function_decoration_test.cc @@ -165,15 +165,20 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUsedInterfaceIds) { auto* body = create(); body->append(create( - create("my_out"), - create("my_in"))); + create(mod->RegisterSymbol("my_out"), + "my_out"), + create(mod->RegisterSymbol("my_in"), + "my_in"))); body->append(create( - create("my_wg"), - create("my_wg"))); + create(mod->RegisterSymbol("my_wg"), "my_wg"), + create(mod->RegisterSymbol("my_wg"), + "my_wg"))); // Add duplicate usages so we show they don't get output multiple times. body->append(create( - create("my_out"), - create("my_in"))); + create(mod->RegisterSymbol("my_out"), + "my_out"), + create(mod->RegisterSymbol("my_in"), + "my_in"))); ast::Function func( Source{}, mod->RegisterSymbol("main"), "main", {}, &void_type, body, diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc index 983a3b2f0b..db78c031a0 100644 --- a/src/writer/spirv/builder_function_test.cc +++ b/src/writer/spirv/builder_function_test.cc @@ -98,7 +98,8 @@ TEST_F(BuilderTest, Function_Terminator_ReturnValue) { auto* body = create(); body->append(create( - Source{}, create("a"))); + Source{}, + create(mod->RegisterSymbol("a"), "a"))); ASSERT_TRUE(td.DetermineResultType(body)) << td.error(); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", {}, @@ -167,7 +168,8 @@ TEST_F(BuilderTest, Function_WithParams) { auto* body = create(); body->append(create( - Source{}, create("a"))); + Source{}, + create(mod->RegisterSymbol("a"), "a"))); ast::Function func(Source{}, mod->RegisterSymbol("a_func"), "a_func", params, &f32, body, ast::FunctionDecorationList{}); @@ -299,8 +301,10 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { &f32, // type false, // is_const create( - create("data"), - create("d")), // constructor + create(mod->RegisterSymbol("data"), + "data"), + create(mod->RegisterSymbol("d"), + "d")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); @@ -326,8 +330,10 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { &f32, // type false, // is_const create( - create("data"), - create("d")), // constructor + create(mod->RegisterSymbol("data"), + "data"), + create(mod->RegisterSymbol("d"), + "d")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); diff --git a/src/writer/spirv/builder_function_variable_test.cc b/src/writer/spirv/builder_function_variable_test.cc index 31b030a9b5..fcdfeb3ba6 100644 --- a/src/writer/spirv/builder_function_variable_test.cc +++ b/src/writer/spirv/builder_function_variable_test.cc @@ -168,9 +168,10 @@ TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructorLoadedFromVar) { init, ast::VariableDecorationList{}); td.RegisterVariableForTesting(&v); - ast::Variable v2(Source{}, "v2", ast::StorageClass::kFunction, &f32, false, - create("v"), - ast::VariableDecorationList{}); + ast::Variable v2( + Source{}, "v2", ast::StorageClass::kFunction, &f32, false, + create(mod->RegisterSymbol("v"), "v"), + ast::VariableDecorationList{}); td.RegisterVariableForTesting(&v2); ASSERT_TRUE(td.DetermineResultType(v2.constructor())) << td.error(); @@ -214,9 +215,10 @@ TEST_F(BuilderTest, FunctionVar_ConstWithVarInitializer) { init, ast::VariableDecorationList{}); td.RegisterVariableForTesting(&v); - ast::Variable v2(Source{}, "v2", ast::StorageClass::kFunction, &f32, true, - create("v"), - ast::VariableDecorationList{}); + ast::Variable v2( + Source{}, "v2", ast::StorageClass::kFunction, &f32, true, + create(mod->RegisterSymbol("v"), "v"), + ast::VariableDecorationList{}); td.RegisterVariableForTesting(&v2); ASSERT_TRUE(td.DetermineResultType(v2.constructor())) << td.error(); diff --git a/src/writer/spirv/builder_ident_expression_test.cc b/src/writer/spirv/builder_ident_expression_test.cc index 18f25f37b1..d678c7621e 100644 --- a/src/writer/spirv/builder_ident_expression_test.cc +++ b/src/writer/spirv/builder_ident_expression_test.cc @@ -68,7 +68,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalConst) { %5 = OpConstantComposite %1 %3 %3 %4 )"); - ast::IdentifierExpression expr("var"); + ast::IdentifierExpression expr(mod->RegisterSymbol("var"), "var"); ASSERT_TRUE(td.DetermineResultType(&expr)); EXPECT_EQ(b.GenerateIdentifierExpression(&expr), 5u); @@ -91,7 +91,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalVar) { %1 = OpVariable %2 Output %4 )"); - ast::IdentifierExpression expr("var"); + ast::IdentifierExpression expr(mod->RegisterSymbol("var"), "var"); ASSERT_TRUE(td.DetermineResultType(&expr)); EXPECT_EQ(b.GenerateIdentifierExpression(&expr), 1u); } @@ -126,7 +126,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionConst) { %5 = OpConstantComposite %1 %3 %3 %4 )"); - ast::IdentifierExpression expr("var"); + ast::IdentifierExpression expr(mod->RegisterSymbol("var"), "var"); ASSERT_TRUE(td.DetermineResultType(&expr)); EXPECT_EQ(b.GenerateIdentifierExpression(&expr), 5u); } @@ -152,7 +152,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionVar) { R"(%1 = OpVariable %2 Function %4 )"); - ast::IdentifierExpression expr("var"); + ast::IdentifierExpression expr(mod->RegisterSymbol("var"), "var"); ASSERT_TRUE(td.DetermineResultType(&expr)); EXPECT_EQ(b.GenerateIdentifierExpression(&expr), 1u); } @@ -165,8 +165,10 @@ TEST_F(BuilderTest, IdentifierExpression_Load) { td.RegisterVariableForTesting(&var); - auto* lhs = create("var"); - auto* rhs = create("var"); + auto* lhs = + create(mod->RegisterSymbol("var"), "var"); + auto* rhs = + create(mod->RegisterSymbol("var"), "var"); ast::BinaryExpression expr(ast::BinaryOp::kAdd, lhs, rhs); @@ -198,8 +200,10 @@ TEST_F(BuilderTest, IdentifierExpression_NoLoadConst) { td.RegisterVariableForTesting(&var); - auto* lhs = create("var"); - auto* rhs = create("var"); + auto* lhs = + create(mod->RegisterSymbol("var"), "var"); + auto* rhs = + create(mod->RegisterSymbol("var"), "var"); ast::BinaryExpression expr(ast::BinaryOp::kAdd, lhs, rhs); diff --git a/src/writer/spirv/builder_if_test.cc b/src/writer/spirv/builder_if_test.cc index c484be6cd9..b85dff9a3d 100644 --- a/src/writer/spirv/builder_if_test.cc +++ b/src/writer/spirv/builder_if_test.cc @@ -85,10 +85,10 @@ TEST_F(BuilderTest, If_WithStatements) { ast::VariableDecorationList{}); // decorations auto* body = create(); - body->append( - create(create("v"), - create( - create(&i32, 2)))); + body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 2)))); auto* cond = create( create(&bool_type, true)); @@ -139,16 +139,16 @@ TEST_F(BuilderTest, If_WithElse) { ast::VariableDecorationList{}); // decorations auto* body = create(); - body->append( - create(create("v"), - create( - create(&i32, 2)))); + body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 2)))); auto* else_body = create(); - else_body->append( - create(create("v"), - create( - create(&i32, 3)))); + else_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 3)))); auto* cond = create( create(&bool_type, true)); @@ -205,16 +205,16 @@ TEST_F(BuilderTest, If_WithElseIf) { ast::VariableDecorationList{}); // decorations auto* body = create(); - body->append( - create(create("v"), - create( - create(&i32, 2)))); + body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 2)))); auto* else_body = create(); - else_body->append( - create(create("v"), - create( - create(&i32, 3)))); + else_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 3)))); auto* else_cond = create( create(&bool_type, true)); @@ -283,25 +283,25 @@ TEST_F(BuilderTest, If_WithMultiple) { ast::VariableDecorationList{}); // decorations auto* body = create(); - body->append( - create(create("v"), - create( - create(&i32, 2)))); + body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 2)))); auto* elseif_1_body = create(); - elseif_1_body->append( - create(create("v"), - create( - create(&i32, 3)))); + elseif_1_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 3)))); auto* elseif_2_body = create(); - elseif_2_body->append( - create(create("v"), - create( - create(&i32, 4)))); + elseif_2_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 4)))); auto* else_body = create(); - else_body->append( - create(create("v"), - create( - create(&i32, 5)))); + else_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 5)))); auto* elseif_1_cond = create( create(&bool_type, true)); @@ -643,9 +643,10 @@ TEST_F(BuilderTest, If_WithLoad_Bug327) { ast::VariableDecorationList{}); // decorations td.RegisterVariableForTesting(var); - ast::IfStatement expr(Source{}, create("a"), - create(), - ast::ElseStatementList{}); + ast::IfStatement expr( + Source{}, + create(mod->RegisterSymbol("a"), "a"), + create(), ast::ElseStatementList{}); ASSERT_TRUE(td.DetermineResultType(&expr)) << td.error(); diff --git a/src/writer/spirv/builder_loop_test.cc b/src/writer/spirv/builder_loop_test.cc index 6a5776ca16..5bc1327ee7 100644 --- a/src/writer/spirv/builder_loop_test.cc +++ b/src/writer/spirv/builder_loop_test.cc @@ -75,10 +75,10 @@ TEST_F(BuilderTest, Loop_WithoutContinuing) { ast::VariableDecorationList{}); // decorations auto* body = create(); - body->append( - create(create("v"), - create( - create(&i32, 2)))); + body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 2)))); ast::LoopStatement expr(body, create()); @@ -128,16 +128,16 @@ TEST_F(BuilderTest, Loop_WithContinuing) { ast::VariableDecorationList{}); // decorations auto* body = create(); - body->append( - create(create("v"), - create( - create(&i32, 2)))); + body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 2)))); auto* continuing = create(); - continuing->append( - create(create("v"), - create( - create(&i32, 3)))); + continuing->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 3)))); ast::LoopStatement expr(body, continuing); td.RegisterVariableForTesting(var); diff --git a/src/writer/spirv/builder_return_test.cc b/src/writer/spirv/builder_return_test.cc index 973efd6771..a219649b03 100644 --- a/src/writer/spirv/builder_return_test.cc +++ b/src/writer/spirv/builder_return_test.cc @@ -84,8 +84,9 @@ TEST_F(BuilderTest, Return_WithValue_GeneratesLoad) { ast::Variable var(Source{}, "param", ast::StorageClass::kFunction, &f32, false, nullptr, ast::VariableDecorationList{}); - ast::ReturnStatement ret(Source{}, - create("param")); + ast::ReturnStatement ret( + Source{}, + create(mod->RegisterSymbol("param"), "param")); td.RegisterVariableForTesting(&var); EXPECT_TRUE(td.DetermineResultType(&ret)) << td.error(); diff --git a/src/writer/spirv/builder_switch_test.cc b/src/writer/spirv/builder_switch_test.cc index b57cee98a5..c8d7be0642 100644 --- a/src/writer/spirv/builder_switch_test.cc +++ b/src/writer/spirv/builder_switch_test.cc @@ -94,16 +94,16 @@ TEST_F(BuilderTest, Switch_WithCase) { ast::VariableDecorationList{}); // decorations auto* case_1_body = create(); - case_1_body->append( - create(create("v"), - create( - create(&i32, 1)))); + case_1_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 1)))); auto* case_2_body = create(); - case_2_body->append( - create(create("v"), - create( - create(&i32, 2)))); + case_2_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 2)))); ast::CaseSelectorList selector_1; selector_1.push_back(create(&i32, 1)); @@ -115,7 +115,8 @@ TEST_F(BuilderTest, Switch_WithCase) { cases.push_back(create(selector_1, case_1_body)); cases.push_back(create(selector_2, case_2_body)); - ast::SwitchStatement expr(create("a"), cases); + ast::SwitchStatement expr( + create(mod->RegisterSymbol("a"), "a"), cases); td.RegisterVariableForTesting(v); td.RegisterVariableForTesting(a); @@ -187,15 +188,16 @@ TEST_F(BuilderTest, Switch_WithDefault) { ast::VariableDecorationList{}); // decorations auto* default_body = create(); - default_body->append( - create(create("v"), - create( - create(&i32, 1)))); + default_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 1)))); ast::CaseStatementList cases; cases.push_back(create(default_body)); - ast::SwitchStatement expr(create("a"), cases); + ast::SwitchStatement expr( + create(mod->RegisterSymbol("a"), "a"), cases); td.RegisterVariableForTesting(v); td.RegisterVariableForTesting(a); @@ -265,22 +267,22 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) { ast::VariableDecorationList{}); // decorations auto* case_1_body = create(); - case_1_body->append( - create(create("v"), - create( - create(&i32, 1)))); + case_1_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 1)))); auto* case_2_body = create(); - case_2_body->append( - create(create("v"), - create( - create(&i32, 2)))); + case_2_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 2)))); auto* default_body = create(); - default_body->append( - create(create("v"), - create( - create(&i32, 3)))); + default_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 3)))); ast::CaseSelectorList selector_1; selector_1.push_back(create(&i32, 1)); @@ -294,7 +296,8 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) { cases.push_back(create(selector_2, case_2_body)); cases.push_back(create(default_body)); - ast::SwitchStatement expr(create("a"), cases); + ast::SwitchStatement expr( + create(mod->RegisterSymbol("a"), "a"), cases); td.RegisterVariableForTesting(v); td.RegisterVariableForTesting(a); @@ -373,23 +376,23 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) { ast::VariableDecorationList{}); // decorations auto* case_1_body = create(); - case_1_body->append( - create(create("v"), - create( - create(&i32, 1)))); + case_1_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 1)))); case_1_body->append(create()); auto* case_2_body = create(); - case_2_body->append( - create(create("v"), - create( - create(&i32, 2)))); + case_2_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 2)))); auto* default_body = create(); - default_body->append( - create(create("v"), - create( - create(&i32, 3)))); + default_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 3)))); ast::CaseSelectorList selector_1; selector_1.push_back(create(&i32, 1)); @@ -402,7 +405,8 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) { cases.push_back(create(selector_2, case_2_body)); cases.push_back(create(default_body)); - ast::SwitchStatement expr(create("a"), cases); + ast::SwitchStatement expr( + create(mod->RegisterSymbol("a"), "a"), cases); td.RegisterVariableForTesting(v); td.RegisterVariableForTesting(a); @@ -477,10 +481,10 @@ TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) { ast::VariableDecorationList{}); // decorations auto* case_1_body = create(); - case_1_body->append( - create(create("v"), - create( - create(&i32, 1)))); + case_1_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 1)))); case_1_body->append(create()); ast::CaseSelectorList selector_1; @@ -489,7 +493,8 @@ TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) { ast::CaseStatementList cases; cases.push_back(create(selector_1, case_1_body)); - ast::SwitchStatement expr(create("a"), cases); + ast::SwitchStatement expr( + create(mod->RegisterSymbol("a"), "a"), cases); td.RegisterVariableForTesting(v); td.RegisterVariableForTesting(a); @@ -546,10 +551,10 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) { create(&bool_type, true)), if_body, ast::ElseStatementList{})); - case_1_body->append( - create(create("v"), - create( - create(&i32, 1)))); + case_1_body->append(create( + create(mod->RegisterSymbol("v"), "v"), + create( + create(&i32, 1)))); ast::CaseSelectorList selector_1; selector_1.push_back(create(&i32, 1)); @@ -557,7 +562,8 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) { ast::CaseStatementList cases; cases.push_back(create(selector_1, case_1_body)); - ast::SwitchStatement expr(create("a"), cases); + ast::SwitchStatement expr( + create(mod->RegisterSymbol("a"), "a"), cases); td.RegisterVariableForTesting(v); td.RegisterVariableForTesting(a); diff --git a/src/writer/spirv/builder_unary_op_expression_test.cc b/src/writer/spirv/builder_unary_op_expression_test.cc index ef173a583a..2579b87d75 100644 --- a/src/writer/spirv/builder_unary_op_expression_test.cc +++ b/src/writer/spirv/builder_unary_op_expression_test.cc @@ -101,8 +101,9 @@ TEST_F(BuilderTest, UnaryOp_LoadRequired) { ast::Variable var(Source{}, "param", ast::StorageClass::kFunction, &vec, false, nullptr, ast::VariableDecorationList{}); - ast::UnaryOpExpression expr(ast::UnaryOp::kNegation, - create("param")); + ast::UnaryOpExpression expr( + ast::UnaryOp::kNegation, + create(mod->RegisterSymbol("param"), "param")); td.RegisterVariableForTesting(&var); EXPECT_TRUE(td.DetermineResultType(&expr)) << td.error(); diff --git a/src/writer/wgsl/generator_impl_array_accessor_test.cc b/src/writer/wgsl/generator_impl_array_accessor_test.cc index 8678557aa3..034051d768 100644 --- a/src/writer/wgsl/generator_impl_array_accessor_test.cc +++ b/src/writer/wgsl/generator_impl_array_accessor_test.cc @@ -34,7 +34,8 @@ TEST_F(WgslGeneratorImplTest, EmitExpression_ArrayAccessor) { ast::type::I32 i32; auto* lit = create(&i32, 5); auto* idx = create(lit); - auto* ary = create("ary"); + auto* ary = + create(mod.RegisterSymbol("ary"), "ary"); ast::ArrayAccessorExpression expr(ary, idx); @@ -43,8 +44,10 @@ TEST_F(WgslGeneratorImplTest, EmitExpression_ArrayAccessor) { } TEST_F(WgslGeneratorImplTest, EmitArrayAccessor) { - auto* ary = create("ary"); - auto* idx = create("idx"); + auto* ary = + create(mod.RegisterSymbol("ary"), "ary"); + auto* idx = + create(mod.RegisterSymbol("idx"), "idx"); ast::ArrayAccessorExpression expr(ary, idx); diff --git a/src/writer/wgsl/generator_impl_assign_test.cc b/src/writer/wgsl/generator_impl_assign_test.cc index 9679c6b508..891eeed6ec 100644 --- a/src/writer/wgsl/generator_impl_assign_test.cc +++ b/src/writer/wgsl/generator_impl_assign_test.cc @@ -29,8 +29,10 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Assign) { - auto* lhs = create("lhs"); - auto* rhs = create("rhs"); + auto* lhs = + create(mod.RegisterSymbol("lhs"), "lhs"); + auto* rhs = + create(mod.RegisterSymbol("rhs"), "rhs"); ast::AssignmentStatement assign(lhs, rhs); gen.increment_indent(); diff --git a/src/writer/wgsl/generator_impl_binary_test.cc b/src/writer/wgsl/generator_impl_binary_test.cc index 825668f9a3..0ad8c07aa1 100644 --- a/src/writer/wgsl/generator_impl_binary_test.cc +++ b/src/writer/wgsl/generator_impl_binary_test.cc @@ -37,8 +37,10 @@ using WgslBinaryTest = TestParamHelper; TEST_P(WgslBinaryTest, Emit) { auto params = GetParam(); - auto* left = create("left"); - auto* right = create("right"); + auto* left = + create(mod.RegisterSymbol("left"), "left"); + auto* right = + create(mod.RegisterSymbol("right"), "right"); ast::BinaryExpression expr(params.op, left, right); diff --git a/src/writer/wgsl/generator_impl_bitcast_test.cc b/src/writer/wgsl/generator_impl_bitcast_test.cc index 2b9d5e881b..bf1cc6b964 100644 --- a/src/writer/wgsl/generator_impl_bitcast_test.cc +++ b/src/writer/wgsl/generator_impl_bitcast_test.cc @@ -30,7 +30,7 @@ using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitExpression_Bitcast) { ast::type::F32 f32; - auto* id = create("id"); + auto* id = create(mod.RegisterSymbol("id"), "id"); ast::BitcastExpression bitcast(&f32, id); ASSERT_TRUE(gen.EmitExpression(&bitcast)) << gen.error(); diff --git a/src/writer/wgsl/generator_impl_call_test.cc b/src/writer/wgsl/generator_impl_call_test.cc index 8afc062b27..77cf83ce83 100644 --- a/src/writer/wgsl/generator_impl_call_test.cc +++ b/src/writer/wgsl/generator_impl_call_test.cc @@ -29,7 +29,8 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitExpression_Call_WithoutParams) { - auto* id = create("my_func"); + auto* id = create(mod.RegisterSymbol("my_func"), + "my_func"); ast::CallExpression call(id, {}); ASSERT_TRUE(gen.EmitExpression(&call)) << gen.error(); @@ -37,10 +38,13 @@ TEST_F(WgslGeneratorImplTest, EmitExpression_Call_WithoutParams) { } TEST_F(WgslGeneratorImplTest, EmitExpression_Call_WithParams) { - auto* id = create("my_func"); + auto* id = create(mod.RegisterSymbol("my_func"), + "my_func"); ast::ExpressionList params; - params.push_back(create("param1")); - params.push_back(create("param2")); + params.push_back(create( + mod.RegisterSymbol("param1"), "param1")); + params.push_back(create( + mod.RegisterSymbol("param2"), "param2")); ast::CallExpression call(id, params); ASSERT_TRUE(gen.EmitExpression(&call)) << gen.error(); @@ -48,10 +52,13 @@ TEST_F(WgslGeneratorImplTest, EmitExpression_Call_WithParams) { } TEST_F(WgslGeneratorImplTest, EmitStatement_Call) { - auto* id = create("my_func"); + auto* id = create(mod.RegisterSymbol("my_func"), + "my_func"); ast::ExpressionList params; - params.push_back(create("param1")); - params.push_back(create("param2")); + params.push_back(create( + mod.RegisterSymbol("param1"), "param1")); + params.push_back(create( + mod.RegisterSymbol("param2"), "param2")); ast::CallStatement call(create(id, params)); diff --git a/src/writer/wgsl/generator_impl_cast_test.cc b/src/writer/wgsl/generator_impl_cast_test.cc index 6b0e933ad0..a0e9f1b4a0 100644 --- a/src/writer/wgsl/generator_impl_cast_test.cc +++ b/src/writer/wgsl/generator_impl_cast_test.cc @@ -32,7 +32,8 @@ TEST_F(WgslGeneratorImplTest, EmitExpression_Cast) { ast::type::F32 f32; ast::ExpressionList params; - params.push_back(create("id")); + params.push_back( + create(mod.RegisterSymbol("id"), "id")); ast::TypeConstructorExpression cast(&f32, params); diff --git a/src/writer/wgsl/generator_impl_function_test.cc b/src/writer/wgsl/generator_impl_function_test.cc index 573b391ae2..2f44fa9a8f 100644 --- a/src/writer/wgsl/generator_impl_function_test.cc +++ b/src/writer/wgsl/generator_impl_function_test.cc @@ -230,8 +230,10 @@ TEST_F(WgslGeneratorImplTest, &f32, // type false, // is_const create( - create("data"), - create("d")), // constructor + create(mod.RegisterSymbol("data"), + "data"), + create(mod.RegisterSymbol("d"), + "d")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); @@ -257,8 +259,10 @@ TEST_F(WgslGeneratorImplTest, &f32, // type false, // is_const create( - create("data"), - create("d")), // constructor + create(mod.RegisterSymbol("data"), + "data"), + create(mod.RegisterSymbol("d"), + "d")), // constructor ast::VariableDecorationList{}); // decorations auto* body = create(); diff --git a/src/writer/wgsl/generator_impl_identifier_test.cc b/src/writer/wgsl/generator_impl_identifier_test.cc index d0f6b31766..d01e3ea90a 100644 --- a/src/writer/wgsl/generator_impl_identifier_test.cc +++ b/src/writer/wgsl/generator_impl_identifier_test.cc @@ -24,7 +24,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitIdentifierExpression_Single) { - ast::IdentifierExpression i("glsl"); + ast::IdentifierExpression i(mod.RegisterSymbol("glsl"), "glsl"); ASSERT_TRUE(gen.EmitExpression(&i)) << gen.error(); EXPECT_EQ(gen.result(), "glsl"); diff --git a/src/writer/wgsl/generator_impl_if_test.cc b/src/writer/wgsl/generator_impl_if_test.cc index b2e22059d8..29051a9e61 100644 --- a/src/writer/wgsl/generator_impl_if_test.cc +++ b/src/writer/wgsl/generator_impl_if_test.cc @@ -28,7 +28,8 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_If) { - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); @@ -44,11 +45,13 @@ TEST_F(WgslGeneratorImplTest, Emit_If) { } TEST_F(WgslGeneratorImplTest, Emit_IfWithElseIf) { - auto* else_cond = create("else_cond"); + auto* else_cond = create( + mod.RegisterSymbol("else_cond"), "else_cond"); auto* else_body = create(); else_body->append(create()); - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); @@ -70,7 +73,8 @@ TEST_F(WgslGeneratorImplTest, Emit_IfWithElse) { auto* else_body = create(); else_body->append(create()); - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); @@ -89,7 +93,8 @@ TEST_F(WgslGeneratorImplTest, Emit_IfWithElse) { } TEST_F(WgslGeneratorImplTest, Emit_IfWithMultiple) { - auto* else_cond = create("else_cond"); + auto* else_cond = create( + mod.RegisterSymbol("else_cond"), "else_cond"); auto* else_body = create(); else_body->append(create()); @@ -97,7 +102,8 @@ TEST_F(WgslGeneratorImplTest, Emit_IfWithMultiple) { auto* else_body_2 = create(); else_body_2->append(create()); - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); auto* body = create(); body->append(create()); diff --git a/src/writer/wgsl/generator_impl_member_accessor_test.cc b/src/writer/wgsl/generator_impl_member_accessor_test.cc index 8ff995ea3a..fd5be5ad28 100644 --- a/src/writer/wgsl/generator_impl_member_accessor_test.cc +++ b/src/writer/wgsl/generator_impl_member_accessor_test.cc @@ -28,8 +28,10 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitExpression_MemberAccessor) { - auto* str = create("str"); - auto* mem = create("mem"); + auto* str = + create(mod.RegisterSymbol("str"), "str"); + auto* mem = + create(mod.RegisterSymbol("mem"), "mem"); ast::MemberAccessorExpression expr(str, mem); diff --git a/src/writer/wgsl/generator_impl_return_test.cc b/src/writer/wgsl/generator_impl_return_test.cc index 12703a7bd2..0cad4a031b 100644 --- a/src/writer/wgsl/generator_impl_return_test.cc +++ b/src/writer/wgsl/generator_impl_return_test.cc @@ -38,7 +38,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Return) { } TEST_F(WgslGeneratorImplTest, Emit_ReturnWithValue) { - auto* expr = create("expr"); + auto* expr = + create(mod.RegisterSymbol("expr"), "expr"); ast::ReturnStatement r(Source{}, expr); gen.increment_indent(); diff --git a/src/writer/wgsl/generator_impl_switch_test.cc b/src/writer/wgsl/generator_impl_switch_test.cc index 29f22cc256..732998fdbe 100644 --- a/src/writer/wgsl/generator_impl_switch_test.cc +++ b/src/writer/wgsl/generator_impl_switch_test.cc @@ -49,7 +49,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Switch) { body.push_back(case_stmt); body.push_back(def); - auto* cond = create("cond"); + auto* cond = + create(mod.RegisterSymbol("cond"), "cond"); ast::SwitchStatement s(cond, body); gen.increment_indent(); diff --git a/src/writer/wgsl/generator_impl_unary_op_test.cc b/src/writer/wgsl/generator_impl_unary_op_test.cc index 518be49088..dbac9fc200 100644 --- a/src/writer/wgsl/generator_impl_unary_op_test.cc +++ b/src/writer/wgsl/generator_impl_unary_op_test.cc @@ -38,7 +38,8 @@ using WgslUnaryOpTest = TestParamHelper; TEST_P(WgslUnaryOpTest, Emit) { auto params = GetParam(); - auto* expr = create("expr"); + auto* expr = + create(mod.RegisterSymbol("expr"), "expr"); ast::UnaryOpExpression op(params.op, expr); ASSERT_TRUE(gen.EmitExpression(&op)) << gen.error(); diff --git a/src/writer/wgsl/generator_impl_variable_test.cc b/src/writer/wgsl/generator_impl_variable_test.cc index 6fcc325b97..39cffac305 100644 --- a/src/writer/wgsl/generator_impl_variable_test.cc +++ b/src/writer/wgsl/generator_impl_variable_test.cc @@ -87,7 +87,8 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) { } TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) { - auto* ident = create("initializer"); + auto* ident = create( + mod.RegisterSymbol("initializer"), "initializer"); ast::type::F32 f32; ast::Variable v(Source{}, "a", ast::StorageClass::kNone, &f32, false, ident, @@ -99,7 +100,8 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) { } TEST_F(WgslGeneratorImplTest, EmitVariable_Const) { - auto* ident = create("initializer"); + auto* ident = create( + mod.RegisterSymbol("initializer"), "initializer"); ast::type::F32 f32; ast::Variable v(Source{}, "a", ast::StorageClass::kNone, &f32, true, ident,