From 321e5a9d7ed060ff740b0809cdde3b05a2d106fe Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 7 Dec 2020 21:08:07 +0000 Subject: [PATCH] ast: Remove Variable constructor that doesn't take a source set_source() will be removed, so sources will only be specifiable at construction time. Bug: tint:390 Change-Id: I5c79efd3fa501ebd9308f7f93cfb77bc12198047 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35009 Commit-Queue: Ben Clayton Reviewed-by: dan sinclair --- src/ast/builder.cc | 4 +- src/ast/decorated_variable_test.cc | 15 +- src/ast/function_test.cc | 60 ++-- src/ast/module_test.cc | 4 +- src/ast/variable.cc | 8 +- src/ast/variable.h | 5 - src/ast/variable_decl_statement_test.cc | 12 +- src/ast/variable_test.cc | 16 +- src/inspector/inspector_test.cc | 37 +-- src/reader/spirv/function.cc | 11 +- src/reader/spirv/parser_impl.cc | 2 +- src/scope_stack_test.cc | 2 +- src/transform/emit_vertex_point_size.cc | 2 +- src/transform/vertex_pulling.cc | 16 +- src/transform/vertex_pulling_test.cc | 10 +- src/type_determiner_test.cc | 283 ++++++++++-------- src/validator/validator_control_block_test.cc | 30 +- src/validator/validator_function_test.cc | 12 +- src/validator/validator_test.cc | 66 ++-- src/validator/validator_type_test.cc | 3 +- src/writer/hlsl/generator_impl_binary_test.cc | 43 +-- ...tor_impl_function_entry_point_data_test.cc | 32 +- .../hlsl/generator_impl_function_test.cc | 117 ++++---- src/writer/hlsl/generator_impl_import_test.cc | 3 +- .../hlsl/generator_impl_intrinsic_test.cc | 10 +- src/writer/hlsl/generator_impl_loop_test.cc | 7 +- .../generator_impl_member_accessor_test.cc | 77 ++--- .../generator_impl_module_constant_test.cc | 7 +- ...rator_impl_variable_decl_statement_test.cc | 24 +- ...tor_impl_function_entry_point_data_test.cc | 32 +- .../msl/generator_impl_function_test.cc | 117 ++++---- src/writer/msl/generator_impl_import_test.cc | 3 +- .../msl/generator_impl_intrinsic_test.cc | 10 +- src/writer/msl/generator_impl_loop_test.cc | 7 +- .../generator_impl_module_constant_test.cc | 5 +- ...rator_impl_variable_decl_statement_test.cc | 27 +- .../spirv/builder_accessor_expression_test.cc | 41 +-- src/writer/spirv/builder_assign_test.cc | 16 +- .../spirv/builder_binary_expression_test.cc | 33 +- src/writer/spirv/builder_block_test.cc | 8 +- src/writer/spirv/builder_call_test.cc | 8 +- .../spirv/builder_function_decoration_test.cc | 22 +- src/writer/spirv/builder_function_test.cc | 19 +- .../spirv/builder_function_variable_test.cc | 16 +- .../spirv/builder_global_variable_test.cc | 55 ++-- .../spirv/builder_ident_expression_test.cc | 12 +- src/writer/spirv/builder_if_test.cc | 16 +- src/writer/spirv/builder_loop_test.cc | 6 +- src/writer/spirv/builder_return_test.cc | 2 +- src/writer/spirv/builder_switch_test.cc | 36 ++- .../spirv/builder_unary_op_expression_test.cc | 2 +- .../wgsl/generator_impl_function_test.cc | 16 +- ...rator_impl_variable_decl_statement_test.cc | 9 +- .../wgsl/generator_impl_variable_test.cc | 8 +- 54 files changed, 813 insertions(+), 631 deletions(-) diff --git a/src/ast/builder.cc b/src/ast/builder.cc index 7fa5bd2fbe..6045083251 100644 --- a/src/ast/builder.cc +++ b/src/ast/builder.cc @@ -32,7 +32,7 @@ Builder::~Builder() = default; Variable* Builder::Var(const std::string& name, StorageClass storage, type::Type* type) { - auto* var = create(name, storage, type); + auto* var = create(Source{}, name, storage, type); OnVariableBuilt(var); return var; } @@ -40,7 +40,7 @@ Variable* Builder::Var(const std::string& name, Variable* Builder::Const(const std::string& name, StorageClass storage, type::Type* type) { - auto* var = create(name, storage, type); + auto* var = create(Source{}, name, storage, type); var->set_is_const(true); OnVariableBuilt(var); return var; diff --git a/src/ast/decorated_variable_test.cc b/src/ast/decorated_variable_test.cc index d31a7cfce1..31ac563be9 100644 --- a/src/ast/decorated_variable_test.cc +++ b/src/ast/decorated_variable_test.cc @@ -34,7 +34,7 @@ using DecoratedVariableTest = TestHelper; TEST_F(DecoratedVariableTest, Creation) { type::I32 t; - auto* var = create("my_var", StorageClass::kFunction, &t); + auto* var = create(Source{}, "my_var", StorageClass::kFunction, &t); DecoratedVariable dv(var); EXPECT_EQ(dv.name(), "my_var"); @@ -63,7 +63,7 @@ TEST_F(DecoratedVariableTest, CreationWithSource) { TEST_F(DecoratedVariableTest, NoDecorations) { type::I32 t; - auto* var = create("my_var", StorageClass::kFunction, &t); + auto* var = create(Source{}, "my_var", StorageClass::kFunction, &t); DecoratedVariable dv(var); EXPECT_FALSE(dv.HasLocationDecoration()); EXPECT_FALSE(dv.HasBuiltinDecoration()); @@ -72,7 +72,7 @@ TEST_F(DecoratedVariableTest, NoDecorations) { TEST_F(DecoratedVariableTest, WithDecorations) { type::F32 t; - auto* var = create("my_var", StorageClass::kFunction, &t); + auto* var = create(Source{}, "my_var", StorageClass::kFunction, &t); DecoratedVariable dv(var); VariableDecorationList decos; @@ -89,7 +89,7 @@ TEST_F(DecoratedVariableTest, WithDecorations) { TEST_F(DecoratedVariableTest, ConstantId) { type::F32 t; - auto* var = create("my_var", StorageClass::kFunction, &t); + auto* var = create(Source{}, "my_var", StorageClass::kFunction, &t); DecoratedVariable dv(var); VariableDecorationList decos; @@ -101,20 +101,21 @@ TEST_F(DecoratedVariableTest, ConstantId) { TEST_F(DecoratedVariableTest, IsValid) { type::I32 t; - auto* var = create("my_var", StorageClass::kNone, &t); + auto* var = create(Source{}, "my_var", StorageClass::kNone, &t); DecoratedVariable dv(var); EXPECT_TRUE(dv.IsValid()); } TEST_F(DecoratedVariableTest, IsDecorated) { type::I32 t; - DecoratedVariable dv(create("my_var", StorageClass::kNone, &t)); + DecoratedVariable dv( + create(Source{}, "my_var", StorageClass::kNone, &t)); EXPECT_TRUE(dv.Is()); } TEST_F(DecoratedVariableTest, to_str) { type::F32 t; - auto* var = create("my_var", StorageClass::kFunction, &t); + auto* var = create(Source{}, "my_var", StorageClass::kFunction, &t); DecoratedVariable dv(var); dv.set_constructor(create("expr")); diff --git a/src/ast/function_test.cc b/src/ast/function_test.cc index 08b0e448a2..db0e995060 100644 --- a/src/ast/function_test.cc +++ b/src/ast/function_test.cc @@ -37,7 +37,8 @@ TEST_F(FunctionTest, Creation) { type::I32 i32; VariableList params; - params.push_back(create("var", StorageClass::kNone, &i32)); + params.push_back( + create(Source{}, "var", StorageClass::kNone, &i32)); auto* var = params[0]; Function f(Source{}, "func", params, &void_type, create(), @@ -53,7 +54,8 @@ TEST_F(FunctionTest, Creation_WithSource) { type::I32 i32; VariableList params; - params.push_back(create("var", StorageClass::kNone, &i32)); + params.push_back( + create(Source{}, "var", StorageClass::kNone, &i32)); Function f(Source{Source::Location{20, 2}}, "func", params, &void_type, create(), FunctionDecorationList{}); @@ -66,7 +68,7 @@ TEST_F(FunctionTest, AddDuplicateReferencedVariables) { type::Void void_type; type::I32 i32; - Variable v("var", StorageClass::kInput, &i32); + Variable v(Source{}, "var", StorageClass::kInput, &i32); Function f(Source{}, "func", VariableList{}, &void_type, create(), FunctionDecorationList{}); @@ -77,7 +79,7 @@ TEST_F(FunctionTest, AddDuplicateReferencedVariables) { f.add_referenced_module_variable(&v); ASSERT_EQ(f.referenced_module_variables().size(), 1u); - Variable v2("var2", StorageClass::kOutput, &i32); + Variable v2(Source{}, "var2", StorageClass::kOutput, &i32); f.add_referenced_module_variable(&v2); ASSERT_EQ(f.referenced_module_variables().size(), 2u); EXPECT_EQ(f.referenced_module_variables()[1], &v2); @@ -87,19 +89,21 @@ TEST_F(FunctionTest, GetReferenceLocations) { type::Void void_type; type::I32 i32; - DecoratedVariable loc1(create("loc1", StorageClass::kInput, &i32)); + DecoratedVariable loc1( + create(Source{}, "loc1", StorageClass::kInput, &i32)); loc1.set_decorations({create(0, Source{})}); - DecoratedVariable loc2(create("loc2", StorageClass::kInput, &i32)); + DecoratedVariable loc2( + create(Source{}, "loc2", StorageClass::kInput, &i32)); loc2.set_decorations({create(1, Source{})}); DecoratedVariable builtin1( - create("builtin1", StorageClass::kInput, &i32)); + create(Source{}, "builtin1", StorageClass::kInput, &i32)); builtin1.set_decorations( {create(Builtin::kPosition, Source{})}); DecoratedVariable builtin2( - create("builtin2", StorageClass::kInput, &i32)); + create(Source{}, "builtin2", StorageClass::kInput, &i32)); builtin2.set_decorations( {create(Builtin::kFragDepth, Source{})}); @@ -124,19 +128,21 @@ TEST_F(FunctionTest, GetReferenceBuiltins) { type::Void void_type; type::I32 i32; - DecoratedVariable loc1(create("loc1", StorageClass::kInput, &i32)); + DecoratedVariable loc1( + create(Source{}, "loc1", StorageClass::kInput, &i32)); loc1.set_decorations({create(0, Source{})}); - DecoratedVariable loc2(create("loc2", StorageClass::kInput, &i32)); + DecoratedVariable loc2( + create(Source{}, "loc2", StorageClass::kInput, &i32)); loc2.set_decorations({create(1, Source{})}); DecoratedVariable builtin1( - create("builtin1", StorageClass::kInput, &i32)); + create(Source{}, "builtin1", StorageClass::kInput, &i32)); builtin1.set_decorations( {create(Builtin::kPosition, Source{})}); DecoratedVariable builtin2( - create("builtin2", StorageClass::kInput, &i32)); + create(Source{}, "builtin2", StorageClass::kInput, &i32)); builtin2.set_decorations( {create(Builtin::kFragDepth, Source{})}); @@ -176,7 +182,8 @@ TEST_F(FunctionTest, IsValid) { type::I32 i32; VariableList params; - params.push_back(create("var", StorageClass::kNone, &i32)); + params.push_back( + create(Source{}, "var", StorageClass::kNone, &i32)); auto* block = create(); block->append(create()); @@ -192,7 +199,8 @@ TEST_F(FunctionTest, IsValid_EmptyName) { type::I32 i32; VariableList params; - params.push_back(create("var", StorageClass::kNone, &i32)); + params.push_back( + create(Source{}, "var", StorageClass::kNone, &i32)); Function f(Source{}, "", params, &void_type, create(), FunctionDecorationList{}); @@ -203,7 +211,8 @@ TEST_F(FunctionTest, IsValid_MissingReturnType) { type::I32 i32; VariableList params; - params.push_back(create("var", StorageClass::kNone, &i32)); + params.push_back( + create(Source{}, "var", StorageClass::kNone, &i32)); Function f(Source{}, "func", params, nullptr, create(), FunctionDecorationList{}); @@ -215,7 +224,8 @@ TEST_F(FunctionTest, IsValid_NullParam) { type::I32 i32; VariableList params; - params.push_back(create("var", StorageClass::kNone, &i32)); + params.push_back( + create(Source{}, "var", StorageClass::kNone, &i32)); params.push_back(nullptr); Function f(Source{}, "func", params, &void_type, create(), @@ -227,7 +237,8 @@ TEST_F(FunctionTest, IsValid_InvalidParam) { type::Void void_type; VariableList params; - params.push_back(create("var", StorageClass::kNone, nullptr)); + params.push_back( + create(Source{}, "var", StorageClass::kNone, nullptr)); Function f(Source{}, "func", params, &void_type, create(), FunctionDecorationList{}); @@ -239,7 +250,8 @@ TEST_F(FunctionTest, IsValid_NullBodyStatement) { type::I32 i32; VariableList params; - params.push_back(create("var", StorageClass::kNone, &i32)); + params.push_back( + create(Source{}, "var", StorageClass::kNone, &i32)); auto* block = create(); block->append(create()); @@ -256,7 +268,8 @@ TEST_F(FunctionTest, IsValid_InvalidBodyStatement) { type::I32 i32; VariableList params; - params.push_back(create("var", StorageClass::kNone, &i32)); + params.push_back( + create(Source{}, "var", StorageClass::kNone, &i32)); auto* block = create(); block->append(create()); @@ -316,7 +329,8 @@ TEST_F(FunctionTest, ToStr_WithParams) { type::I32 i32; VariableList params; - params.push_back(create("var", StorageClass::kNone, &i32)); + params.push_back( + create(Source{}, "var", StorageClass::kNone, &i32)); auto* block = create(); block->append(create()); @@ -355,8 +369,10 @@ TEST_F(FunctionTest, TypeName_WithParams) { type::F32 f32; VariableList params; - params.push_back(create("var1", StorageClass::kNone, &i32)); - params.push_back(create("var2", StorageClass::kNone, &f32)); + params.push_back( + create(Source{}, "var1", StorageClass::kNone, &i32)); + params.push_back( + create(Source{}, "var2", StorageClass::kNone, &f32)); Function f(Source{}, "func", params, &void_type, create(), FunctionDecorationList{}); diff --git a/src/ast/module_test.cc b/src/ast/module_test.cc index c5ff933f1b..6a1978ac56 100644 --- a/src/ast/module_test.cc +++ b/src/ast/module_test.cc @@ -67,7 +67,7 @@ TEST_F(ModuleTest, IsValid_Empty) { TEST_F(ModuleTest, IsValid_GlobalVariable) { type::F32 f32; - auto* var = create("var", StorageClass::kInput, &f32); + auto* var = create(Source{}, "var", StorageClass::kInput, &f32); Module m; m.AddGlobalVariable(var); @@ -81,7 +81,7 @@ TEST_F(ModuleTest, IsValid_Null_GlobalVariable) { } TEST_F(ModuleTest, IsValid_Invalid_GlobalVariable) { - auto* var = create("var", StorageClass::kInput, nullptr); + auto* var = create(Source{}, "var", StorageClass::kInput, nullptr); Module m; m.AddGlobalVariable(var); diff --git a/src/ast/variable.cc b/src/ast/variable.cc index dbfe7d5c1d..d97253e5c7 100644 --- a/src/ast/variable.cc +++ b/src/ast/variable.cc @@ -27,9 +27,6 @@ namespace ast { Variable::Variable() = default; -Variable::Variable(const std::string& name, StorageClass sc, type::Type* type) - : Base(), name_(name), storage_class_(sc), type_(type) {} - Variable::Variable(const Source& source, const std::string& name, StorageClass sc, @@ -41,9 +38,8 @@ Variable::Variable(Variable&&) = default; Variable::~Variable() = default; Variable* Variable::Clone(CloneContext* ctx) const { - auto* cloned = - ctx->mod->create(name(), storage_class(), ctx->Clone(type())); - cloned->set_source(ctx->Clone(source())); + auto* cloned = ctx->mod->create( + ctx->Clone(source()), name(), storage_class(), ctx->Clone(type())); cloned->set_constructor(ctx->Clone(constructor())); cloned->set_is_const(is_const()); return cloned; diff --git a/src/ast/variable.h b/src/ast/variable.h index 72de0f1243..a226bddcd9 100644 --- a/src/ast/variable.h +++ b/src/ast/variable.h @@ -78,11 +78,6 @@ namespace ast { /// The storage class for a formal parameter is always StorageClass::kNone. class Variable : public Castable { public: - /// Create a variable - /// @param name the variables name - /// @param sc the variable storage class - /// @param type the value type - Variable(const std::string& name, StorageClass sc, type::Type* type); /// Create a variable /// @param source the variable source /// @param name the variables name diff --git a/src/ast/variable_decl_statement_test.cc b/src/ast/variable_decl_statement_test.cc index daa7c2a086..c7e08be865 100644 --- a/src/ast/variable_decl_statement_test.cc +++ b/src/ast/variable_decl_statement_test.cc @@ -26,7 +26,7 @@ using VariableDeclStatementTest = TestHelper; TEST_F(VariableDeclStatementTest, Creation) { type::F32 f32; - auto* var = create("a", StorageClass::kNone, &f32); + auto* var = create(Source{}, "a", StorageClass::kNone, &f32); VariableDeclStatement stmt(var); EXPECT_EQ(stmt.variable(), var); @@ -34,7 +34,7 @@ TEST_F(VariableDeclStatementTest, Creation) { TEST_F(VariableDeclStatementTest, Creation_WithSource) { type::F32 f32; - auto* var = create("a", StorageClass::kNone, &f32); + auto* var = create(Source{}, "a", StorageClass::kNone, &f32); VariableDeclStatement stmt(Source{Source::Location{20, 2}}, var); auto src = stmt.source(); @@ -44,7 +44,7 @@ TEST_F(VariableDeclStatementTest, Creation_WithSource) { TEST_F(VariableDeclStatementTest, IsVariableDecl) { type::F32 f32; - auto* var = create("a", StorageClass::kNone, &f32); + auto* var = create(Source{}, "a", StorageClass::kNone, &f32); VariableDeclStatement s(var); EXPECT_TRUE(s.Is()); @@ -52,14 +52,14 @@ TEST_F(VariableDeclStatementTest, IsVariableDecl) { TEST_F(VariableDeclStatementTest, IsValid) { type::F32 f32; - auto* var = create("a", StorageClass::kNone, &f32); + auto* var = create(Source{}, "a", StorageClass::kNone, &f32); VariableDeclStatement stmt(var); EXPECT_TRUE(stmt.IsValid()); } TEST_F(VariableDeclStatementTest, IsValid_InvalidVariable) { type::F32 f32; - auto* var = create("", StorageClass::kNone, &f32); + auto* var = create(Source{}, "", StorageClass::kNone, &f32); VariableDeclStatement stmt(var); EXPECT_FALSE(stmt.IsValid()); } @@ -71,7 +71,7 @@ TEST_F(VariableDeclStatementTest, IsValid_NullVariable) { TEST_F(VariableDeclStatementTest, ToStr) { type::F32 f32; - auto* var = create("a", StorageClass::kNone, &f32); + auto* var = create(Source{}, "a", StorageClass::kNone, &f32); VariableDeclStatement stmt(Source{Source::Location{20, 2}}, var); std::ostringstream out; diff --git a/src/ast/variable_test.cc b/src/ast/variable_test.cc index 9f22a9417c..39dc9f6663 100644 --- a/src/ast/variable_test.cc +++ b/src/ast/variable_test.cc @@ -27,7 +27,7 @@ using VariableTest = TestHelper; TEST_F(VariableTest, Creation) { type::I32 t; - Variable v("my_var", StorageClass::kFunction, &t); + Variable v(Source{}, "my_var", StorageClass::kFunction, &t); EXPECT_EQ(v.name(), "my_var"); EXPECT_EQ(v.storage_class(), StorageClass::kFunction); @@ -68,43 +68,43 @@ TEST_F(VariableTest, CreationEmpty) { TEST_F(VariableTest, IsValid) { type::I32 t; - Variable v{"my_var", StorageClass::kNone, &t}; + Variable v{Source{}, "my_var", StorageClass::kNone, &t}; EXPECT_TRUE(v.IsValid()); } TEST_F(VariableTest, IsValid_WithConstructor) { type::I32 t; - Variable v{"my_var", StorageClass::kNone, &t}; + Variable v{Source{}, "my_var", StorageClass::kNone, &t}; v.set_constructor(create("ident")); EXPECT_TRUE(v.IsValid()); } TEST_F(VariableTest, IsValid_MissinName) { type::I32 t; - Variable v{"", StorageClass::kNone, &t}; + Variable v{Source{}, "", StorageClass::kNone, &t}; EXPECT_FALSE(v.IsValid()); } TEST_F(VariableTest, IsValid_MissingType) { - Variable v{"x", StorageClass::kNone, nullptr}; + Variable v{Source{}, "x", StorageClass::kNone, nullptr}; EXPECT_FALSE(v.IsValid()); } TEST_F(VariableTest, IsValid_MissingBoth) { - Variable v("", StorageClass::kNone, nullptr); + Variable v{Source{}, "", StorageClass::kNone, nullptr}; EXPECT_FALSE(v.IsValid()); } TEST_F(VariableTest, IsValid_InvalidConstructor) { type::I32 t; - Variable v{"my_var", StorageClass::kNone, &t}; + Variable v{Source{}, "my_var", StorageClass::kNone, &t}; v.set_constructor(create("")); EXPECT_FALSE(v.IsValid()); } TEST_F(VariableTest, to_str) { type::F32 t; - Variable v{"my_var", StorageClass::kFunction, &t}; + Variable v{Source{}, "my_var", StorageClass::kFunction, &t}; std::ostringstream out; v.to_str(out, 2); EXPECT_EQ(out.str(), R"( Variable{ diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index 50d9d1f843..9cddc87f3e 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -114,10 +114,10 @@ class InspectorHelper { for (auto inout : inout_vars) { std::string in, out; std::tie(in, out) = inout; - auto* in_var = - create(in, ast::StorageClass::kInput, u32_type()); - auto* out_var = - create(out, ast::StorageClass::kOutput, u32_type()); + auto* in_var = create( + Source{}, in, ast::StorageClass::kInput, u32_type()); + auto* out_var = create( + Source{}, out, ast::StorageClass::kOutput, u32_type()); mod()->AddGlobalVariable(in_var); mod()->AddGlobalVariable(out_var); } @@ -188,7 +188,7 @@ class InspectorHelper { ast::type::Type* type, T* val) { auto* dvar = create( - create(name, ast::StorageClass::kNone, type)); + create(Source{}, name, ast::StorageClass::kNone, type)); dvar->set_is_const(true); ast::VariableDecorationList decos; decos.push_back(create(id, Source{})); @@ -349,7 +349,7 @@ class InspectorHelper { uint32_t set, uint32_t binding) { auto* var = create( - create(name, storage_class, type)); + create(Source{}, name, storage_class, type)); ast::VariableDecorationList decorations; decorations.push_back(create(binding, Source{})); @@ -399,8 +399,9 @@ class InspectorHelper { ast::type::Type* member_type; std::tie(member_idx, member_type) = member; std::string member_name = StructMemberName(member_idx, member_type); - body->append(create(create( - "local" + member_name, ast::StorageClass::kNone, member_type))); + body->append(create( + create(Source{}, "local" + member_name, + ast::StorageClass::kNone, member_type))); } for (auto member : members) { @@ -494,16 +495,16 @@ class InspectorHelper { } void AddGlobalVariable(const std::string& name, ast::type::Type* type) { - mod()->AddGlobalVariable( - create(name, ast::StorageClass::kUniformConstant, type)); + mod()->AddGlobalVariable(create( + Source{}, name, ast::StorageClass::kUniformConstant, type)); } /// Adds a depth texture variable to the module /// @param name the name of the variable /// @param type the type to use void AddDepthTexture(const std::string& name, ast::type::Type* type) { - mod()->AddGlobalVariable( - create(name, ast::StorageClass::kUniformConstant, type)); + mod()->AddGlobalVariable(create( + Source{}, name, ast::StorageClass::kUniformConstant, type)); } /// Generates a function that references a specific sampler variable @@ -525,8 +526,9 @@ class InspectorHelper { auto* body = create(); - auto* call_result = create( - "sampler_result", ast::StorageClass::kFunction, vec_type(base_type, 4)); + auto* call_result = create(Source{}, "sampler_result", + ast::StorageClass::kFunction, + vec_type(base_type, 4)); body->append(create(call_result)); ast::ExpressionList call_params; @@ -565,8 +567,9 @@ class InspectorHelper { auto* body = create(); - auto* call_result = create( - "sampler_result", ast::StorageClass::kFunction, vec_type(base_type, 4)); + auto* call_result = create(Source{}, "sampler_result", + ast::StorageClass::kFunction, + vec_type(base_type, 4)); body->append(create(call_result)); ast::ExpressionList call_params; @@ -608,7 +611,7 @@ class InspectorHelper { auto* body = create(); auto* call_result = create( - "sampler_result", ast::StorageClass::kFunction, base_type); + Source{}, "sampler_result", ast::StorageClass::kFunction, base_type); body->append(create(call_result)); ast::ExpressionList call_params; diff --git a/src/reader/spirv/function.cc b/src/reader/spirv/function.cc index ee09c41f8a..03be176299 100644 --- a/src/reader/spirv/function.cc +++ b/src/reader/spirv/function.cc @@ -2094,8 +2094,9 @@ bool FunctionEmitter::EmitIfStart(const BlockInfo& block_info) { const std::string guard_name = block_info.flow_guard_name; if (!guard_name.empty()) { // Declare the guard variable just before the "if", initialized to true. - auto* guard_var = create( - guard_name, ast::StorageClass::kFunction, parser_impl_.Bool()); + auto* guard_var = create(Source{}, guard_name, + ast::StorageClass::kFunction, + parser_impl_.Bool()); guard_var->set_constructor(MakeTrue()); auto* guard_decl = create(guard_var); AddStatement(guard_decl); @@ -2637,9 +2638,9 @@ bool FunctionEmitter::EmitStatementsInBasicBlock(const BlockInfo& block_info, assert(def_inst); const auto phi_var_name = GetDefInfo(id)->phi_var; assert(!phi_var_name.empty()); - auto* var = - create(phi_var_name, ast::StorageClass::kFunction, - parser_impl_.ConvertType(def_inst->type_id())); + auto* var = create( + Source{}, phi_var_name, ast::StorageClass::kFunction, + parser_impl_.ConvertType(def_inst->type_id())); AddStatement(create(var)); } diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc index b0c01a9e93..202293d47e 100644 --- a/src/reader/spirv/parser_impl.cc +++ b/src/reader/spirv/parser_impl.cc @@ -1171,7 +1171,7 @@ ast::Variable* ParserImpl::MakeVariable(uint32_t id, type = ast_module_.create(access, type); } - auto* ast_var = create(namer_.Name(id), sc, type); + auto* ast_var = create(Source{}, namer_.Name(id), sc, type); ast::VariableDecorationList ast_decorations; for (auto& deco : GetDecorationsFor(id)) { diff --git a/src/scope_stack_test.cc b/src/scope_stack_test.cc index f1d81531d5..55ecb5d50c 100644 --- a/src/scope_stack_test.cc +++ b/src/scope_stack_test.cc @@ -33,7 +33,7 @@ TEST_F(ScopeStackTest, Global) { TEST_F(ScopeStackTest, Global_SetWithPointer) { ast::type::F32 f32; - ast::Variable v("test", ast::StorageClass::kNone, &f32); + ast::Variable v(Source{}, "test", ast::StorageClass::kNone, &f32); v.set_name("my_var"); ScopeStack s; diff --git a/src/transform/emit_vertex_point_size.cc b/src/transform/emit_vertex_point_size.cc index 32ac992ba1..7d69cb5827 100644 --- a/src/transform/emit_vertex_point_size.cc +++ b/src/transform/emit_vertex_point_size.cc @@ -52,7 +52,7 @@ Transform::Output EmitVertexPointSize::Run(ast::Module* in) { // Declare the pointsize builtin output variable. auto* pointsize_var = mod->create(mod->create( - kPointSizeVar, ast::StorageClass::kOutput, f32)); + Source{}, kPointSizeVar, ast::StorageClass::kOutput, f32)); pointsize_var->set_decorations({ mod->create(ast::Builtin::kPointSize, Source{}), }); diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc index 4e7130315f..5614ba449b 100644 --- a/src/transform/vertex_pulling.cc +++ b/src/transform/vertex_pulling.cc @@ -159,7 +159,7 @@ void VertexPulling::State::FindOrInsertVertexIndexIfUsed() { vertex_index_name = kDefaultVertexIndexName; auto* var = mod->create(mod->create( - vertex_index_name, ast::StorageClass::kInput, GetI32Type())); + Source{}, vertex_index_name, ast::StorageClass::kInput, GetI32Type())); ast::VariableDecorationList decorations; decorations.push_back( @@ -203,7 +203,7 @@ void VertexPulling::State::FindOrInsertInstanceIndexIfUsed() { instance_index_name = kDefaultInstanceIndexName; auto* var = mod->create(mod->create( - instance_index_name, ast::StorageClass::kInput, GetI32Type())); + Source{}, instance_index_name, ast::StorageClass::kInput, GetI32Type())); ast::VariableDecorationList decorations; decorations.push_back(mod->create( @@ -226,8 +226,8 @@ void VertexPulling::State::ConvertVertexInputVariablesToPrivate() { // This is where the replacement happens. Expressions use identifier // strings instead of pointers, so we don't need to update any other // place in the AST. - v = mod->create(v->name(), ast::StorageClass::kPrivate, - v->type()); + v = mod->create( + Source{}, v->name(), ast::StorageClass::kPrivate, v->type()); location_to_var[location] = v; break; } @@ -265,7 +265,7 @@ void VertexPulling::State::AddVertexStorageBuffers() { for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) { // The decorated variable with struct type auto* var = mod->create(mod->create( - GetVertexBufferName(i), ast::StorageClass::kStorageBuffer, + Source{}, GetVertexBufferName(i), ast::StorageClass::kStorageBuffer, struct_type)); // Add decorations @@ -289,9 +289,9 @@ void VertexPulling::State::AddVertexPullingPreamble( auto* block = mod->create(); // Declare the |kPullingPosVarName| variable in the shader - auto* pos_declaration = - mod->create(mod->create( - kPullingPosVarName, ast::StorageClass::kFunction, GetI32Type())); + auto* pos_declaration = mod->create( + mod->create(Source{}, kPullingPosVarName, + ast::StorageClass::kFunction, GetI32Type())); // |kPullingPosVarName| refers to the byte location of the current read. We // declare a variable in the shader to avoid having to reuse Expression diff --git a/src/transform/vertex_pulling_test.cc b/src/transform/vertex_pulling_test.cc index a2eb2c9a61..820d1e0ce2 100644 --- a/src/transform/vertex_pulling_test.cc +++ b/src/transform/vertex_pulling_test.cc @@ -70,7 +70,7 @@ class VertexPullingHelper { std::string name, ast::type::Type* type) { auto* var = create( - create(name, ast::StorageClass::kInput, type)); + create(Source{}, name, ast::StorageClass::kInput, type)); ast::VariableDecorationList decorations; decorations.push_back(create(location, Source{})); @@ -419,7 +419,7 @@ TEST_F(VertexPullingTest, ExistingVertexIndexAndInstanceIndex) { { auto* vertex_index_var = create(create( - "custom_vertex_index", ast::StorageClass::kInput, &i32)); + Source{}, "custom_vertex_index", ast::StorageClass::kInput, &i32)); ast::VariableDecorationList decorations; decorations.push_back( @@ -430,9 +430,9 @@ TEST_F(VertexPullingTest, ExistingVertexIndexAndInstanceIndex) { } { - auto* instance_index_var = - create(create( - "custom_instance_index", ast::StorageClass::kInput, &i32)); + auto* instance_index_var = create( + create(Source{}, "custom_instance_index", + ast::StorageClass::kInput, &i32)); ast::VariableDecorationList decorations; decorations.push_back( diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index 8af4a49a8d..f9a21ad6e3 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -389,7 +389,8 @@ TEST_F(TypeDeterminerTest, Stmt_Call_undeclared) { TEST_F(TypeDeterminerTest, Stmt_VariableDecl) { ast::type::I32 i32; - auto* var = create("my_var", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "my_var", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); auto* init = var->constructor(); @@ -403,7 +404,8 @@ TEST_F(TypeDeterminerTest, Stmt_VariableDecl) { TEST_F(TypeDeterminerTest, Stmt_VariableDecl_ModuleScope) { ast::type::I32 i32; - auto* var = create("my_var", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "my_var", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); auto* init = var->constructor(); @@ -430,8 +432,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array) { auto* idx = create( create(&i32, 2)); - auto* var = - create("my_var", ast::StorageClass::kFunction, &ary); + auto* var = create(Source{}, "my_var", + ast::StorageClass::kFunction, &ary); mod->AddGlobalVariable(var); // Register the global @@ -455,8 +457,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Alias_Array) { auto* idx = create( create(&i32, 2)); - auto* var = - create("my_var", ast::StorageClass::kFunction, &aary); + auto* var = create(Source{}, "my_var", + ast::StorageClass::kFunction, &aary); mod->AddGlobalVariable(var); // Register the global @@ -479,8 +481,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Array_Constant) { auto* idx = create( create(&i32, 2)); - auto* var = - create("my_var", ast::StorageClass::kFunction, &ary); + auto* var = create(Source{}, "my_var", + ast::StorageClass::kFunction, &ary); var->set_is_const(true); mod->AddGlobalVariable(var); @@ -502,7 +504,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix) { auto* idx = create( create(&i32, 2)); - auto* var = create("my_var", ast::StorageClass::kNone, &mat); + auto* var = + create(Source{}, "my_var", ast::StorageClass::kNone, &mat); mod->AddGlobalVariable(var); // Register the global @@ -528,7 +531,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Matrix_BothDimensions) { create(&i32, 2)); auto* idx2 = create( create(&i32, 1)); - auto* var = create("my_var", ast::StorageClass::kNone, &mat); + auto* var = + create(Source{}, "my_var", ast::StorageClass::kNone, &mat); mod->AddGlobalVariable(var); // Register the global @@ -554,7 +558,8 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Vector) { auto* idx = create( create(&i32, 2)); - auto* var = create("my_var", ast::StorageClass::kNone, &vec); + auto* var = + create(Source{}, "my_var", ast::StorageClass::kNone, &vec); mod->AddGlobalVariable(var); // Register the global @@ -575,7 +580,7 @@ TEST_F(TypeDeterminerTest, Expr_Bitcast) { ast::BitcastExpression bitcast(&f32, create("name")); - ast::Variable v("name", ast::StorageClass::kPrivate, &f32); + ast::Variable v(Source{}, "name", ast::StorageClass::kPrivate, &f32); td()->RegisterVariableForTesting(&v); EXPECT_TRUE(td()->DetermineResultType(&bitcast)); @@ -653,7 +658,7 @@ TEST_F(TypeDeterminerTest, Expr_Cast) { params.push_back(create("name")); ast::TypeConstructorExpression cast(&f32, params); - ast::Variable v("name", ast::StorageClass::kPrivate, &f32); + ast::Variable v(Source{}, "name", ast::StorageClass::kPrivate, &f32); td()->RegisterVariableForTesting(&v); EXPECT_TRUE(td()->DetermineResultType(&cast)); @@ -694,7 +699,8 @@ TEST_F(TypeDeterminerTest, Expr_Constructor_Type) { TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalVariable) { ast::type::F32 f32; - auto* var = create("my_var", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "my_var", ast::StorageClass::kNone, &f32); mod->AddGlobalVariable(var); // Register the global @@ -712,7 +718,8 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalVariable) { TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalConstant) { ast::type::F32 f32; - auto* var = create("my_var", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "my_var", ast::StorageClass::kNone, &f32); var->set_is_const(true); mod->AddGlobalVariable(var); @@ -730,7 +737,8 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable_Const) { auto* my_var = create("my_var"); - auto* var = create("my_var", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "my_var", ast::StorageClass::kNone, &f32); var->set_is_const(true); auto* body = create(); @@ -753,8 +761,8 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable) { auto* my_var = create("my_var"); auto* body = create(); - body->append(create( - create("my_var", ast::StorageClass::kNone, &f32))); + body->append(create(create( + Source{}, "my_var", ast::StorageClass::kNone, &f32))); body->append(create( my_var, create("my_var"))); @@ -779,8 +787,8 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) { auto* my_var = create("my_var"); auto* body = create(); - body->append(create( - create("my_var", ast::StorageClass::kNone, &ptr))); + body->append(create(create( + Source{}, "my_var", ast::StorageClass::kNone, &ptr))); body->append(create( my_var, create("my_var"))); @@ -824,16 +832,16 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Unknown) { TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) { ast::type::F32 f32; - auto* in_var = - create("in_var", ast::StorageClass::kInput, &f32); - auto* out_var = - create("out_var", ast::StorageClass::kOutput, &f32); - auto* sb_var = - create("sb_var", ast::StorageClass::kStorageBuffer, &f32); - auto* wg_var = - create("wg_var", ast::StorageClass::kWorkgroup, &f32); - auto* priv_var = - create("priv_var", ast::StorageClass::kPrivate, &f32); + auto* in_var = create(Source{}, "in_var", + ast::StorageClass::kInput, &f32); + auto* out_var = create(Source{}, "out_var", + ast::StorageClass::kOutput, &f32); + auto* sb_var = create(Source{}, "sb_var", + ast::StorageClass::kStorageBuffer, &f32); + auto* wg_var = create(Source{}, "wg_var", + ast::StorageClass::kWorkgroup, &f32); + auto* priv_var = create(Source{}, "priv_var", + ast::StorageClass::kPrivate, &f32); mod->AddGlobalVariable(in_var); mod->AddGlobalVariable(out_var); @@ -875,16 +883,16 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) { TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) { ast::type::F32 f32; - auto* in_var = - create("in_var", ast::StorageClass::kInput, &f32); - auto* out_var = - create("out_var", ast::StorageClass::kOutput, &f32); - auto* sb_var = - create("sb_var", ast::StorageClass::kStorageBuffer, &f32); - auto* wg_var = - create("wg_var", ast::StorageClass::kWorkgroup, &f32); - auto* priv_var = - create("priv_var", ast::StorageClass::kPrivate, &f32); + auto* in_var = create(Source{}, "in_var", + ast::StorageClass::kInput, &f32); + auto* out_var = create(Source{}, "out_var", + ast::StorageClass::kOutput, &f32); + auto* sb_var = create(Source{}, "sb_var", + ast::StorageClass::kStorageBuffer, &f32); + auto* wg_var = create(Source{}, "wg_var", + ast::StorageClass::kWorkgroup, &f32); + auto* priv_var = create(Source{}, "priv_var", + ast::StorageClass::kPrivate, &f32); mod->AddGlobalVariable(in_var); mod->AddGlobalVariable(out_var); @@ -936,8 +944,8 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) { TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) { ast::type::F32 f32; - auto* var = - create("in_var", ast::StorageClass::kFunction, &f32); + auto* var = create(Source{}, "in_var", + ast::StorageClass::kFunction, &f32); auto* body = create(); body->append(create(var)); @@ -952,7 +960,7 @@ TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) { mod->AddFunction(func); - ast::Variable v("var", ast::StorageClass::kFunction, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kFunction, &f32); td()->RegisterVariableForTesting(&v); // Register the function @@ -974,7 +982,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct) { ast::type::Struct st("S", strct); - auto* var = create("my_struct", ast::StorageClass::kNone, &st); + auto* var = create(Source{}, "my_struct", + ast::StorageClass::kNone, &st); mod->AddGlobalVariable(var); @@ -1007,8 +1016,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) { auto st = std::make_unique("alias", strct); ast::type::Alias alias("alias", st.get()); - auto* var = - create("my_struct", ast::StorageClass::kNone, &alias); + auto* var = create(Source{}, "my_struct", + ast::StorageClass::kNone, &alias); mod->AddGlobalVariable(var); @@ -1031,7 +1040,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle) { ast::type::F32 f32; ast::type::Vector vec3(&f32, 3); - auto* var = create("my_vec", ast::StorageClass::kNone, &vec3); + auto* var = create(Source{}, "my_vec", + ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); // Register the global @@ -1053,7 +1063,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_VectorSwizzle_SingleElement) { ast::type::F32 f32; ast::type::Vector vec3(&f32, 3); - auto* var = create("my_vec", ast::StorageClass::kNone, &vec3); + auto* var = create(Source{}, "my_vec", + ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); // Register the global @@ -1117,7 +1128,8 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) { ast::type::Struct stA("A", strctA); - auto* var = create("c", ast::StorageClass::kNone, &stA); + auto* var = + create(Source{}, "c", ast::StorageClass::kNone, &stA); mod->AddGlobalVariable(var); // Register the global @@ -1151,7 +1163,8 @@ TEST_P(Expr_Binary_BitwiseTest, Scalar) { ast::type::I32 i32; - auto* var = create("val", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "val", ast::StorageClass::kNone, &i32); mod->AddGlobalVariable(var); // Register the global @@ -1171,7 +1184,8 @@ TEST_P(Expr_Binary_BitwiseTest, Vector) { ast::type::I32 i32; ast::type::Vector vec3(&i32, 3); - auto* var = create("val", ast::StorageClass::kNone, &vec3); + auto* var = + create(Source{}, "val", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); // Register the global @@ -1207,8 +1221,8 @@ TEST_P(Expr_Binary_LogicalTest, Scalar) { ast::type::Bool bool_type; - auto* var = - create("val", ast::StorageClass::kNone, &bool_type); + auto* var = create(Source{}, "val", ast::StorageClass::kNone, + &bool_type); mod->AddGlobalVariable(var); // Register the global @@ -1228,7 +1242,8 @@ TEST_P(Expr_Binary_LogicalTest, Vector) { ast::type::Bool bool_type; ast::type::Vector vec3(&bool_type, 3); - auto* var = create("val", ast::StorageClass::kNone, &vec3); + auto* var = + create(Source{}, "val", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); // Register the global @@ -1257,7 +1272,8 @@ TEST_P(Expr_Binary_CompareTest, Scalar) { ast::type::I32 i32; - auto* var = create("val", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "val", ast::StorageClass::kNone, &i32); mod->AddGlobalVariable(var); // Register the global @@ -1277,7 +1293,8 @@ TEST_P(Expr_Binary_CompareTest, Vector) { ast::type::I32 i32; ast::type::Vector vec3(&i32, 3); - auto* var = create("val", ast::StorageClass::kNone, &vec3); + auto* var = + create(Source{}, "val", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); // Register the global @@ -1307,7 +1324,8 @@ INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest, TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Scalar) { ast::type::I32 i32; - auto* var = create("val", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "val", ast::StorageClass::kNone, &i32); mod->AddGlobalVariable(var); // Register the global @@ -1327,9 +1345,9 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Scalar) { ast::type::Vector vec3(&f32, 3); auto* scalar = - create("scalar", ast::StorageClass::kNone, &f32); - auto* vector = - create("vector", ast::StorageClass::kNone, &vec3); + create(Source{}, "scalar", ast::StorageClass::kNone, &f32); + auto* vector = create(Source{}, "vector", + ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(scalar); mod->AddGlobalVariable(vector); @@ -1355,9 +1373,9 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Vector) { ast::type::Vector vec3(&f32, 3); auto* scalar = - create("scalar", ast::StorageClass::kNone, &f32); - auto* vector = - create("vector", ast::StorageClass::kNone, &vec3); + create(Source{}, "scalar", ast::StorageClass::kNone, &f32); + auto* vector = create(Source{}, "vector", + ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(scalar); mod->AddGlobalVariable(vector); @@ -1382,8 +1400,8 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Vector) { ast::type::F32 f32; ast::type::Vector vec3(&f32, 3); - auto* vector = - create("vector", ast::StorageClass::kNone, &vec3); + auto* vector = create(Source{}, "vector", + ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(vector); // Register the global @@ -1408,9 +1426,9 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Scalar) { ast::type::Matrix mat3x2(&f32, 3, 2); auto* scalar = - create("scalar", ast::StorageClass::kNone, &f32); - auto* matrix = - create("matrix", ast::StorageClass::kNone, &mat3x2); + create(Source{}, "scalar", ast::StorageClass::kNone, &f32); + auto* matrix = create(Source{}, "matrix", + ast::StorageClass::kNone, &mat3x2); mod->AddGlobalVariable(scalar); mod->AddGlobalVariable(matrix); @@ -1436,9 +1454,9 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Matrix) { ast::type::Matrix mat3x2(&f32, 3, 2); auto* scalar = - create("scalar", ast::StorageClass::kNone, &f32); - auto* matrix = - create("matrix", ast::StorageClass::kNone, &mat3x2); + create(Source{}, "scalar", ast::StorageClass::kNone, &f32); + auto* matrix = create(Source{}, "matrix", + ast::StorageClass::kNone, &mat3x2); mod->AddGlobalVariable(scalar); mod->AddGlobalVariable(matrix); @@ -1464,10 +1482,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Vector) { ast::type::Vector vec3(&f32, 2); ast::type::Matrix mat3x2(&f32, 3, 2); - auto* vector = - create("vector", ast::StorageClass::kNone, &vec3); - auto* matrix = - create("matrix", ast::StorageClass::kNone, &mat3x2); + auto* vector = create(Source{}, "vector", + ast::StorageClass::kNone, &vec3); + auto* matrix = create(Source{}, "matrix", + ast::StorageClass::kNone, &mat3x2); mod->AddGlobalVariable(vector); mod->AddGlobalVariable(matrix); @@ -1493,10 +1511,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Matrix) { ast::type::Vector vec3(&f32, 3); ast::type::Matrix mat3x2(&f32, 3, 2); - auto* vector = - create("vector", ast::StorageClass::kNone, &vec3); - auto* matrix = - create("matrix", ast::StorageClass::kNone, &mat3x2); + auto* vector = create(Source{}, "vector", + ast::StorageClass::kNone, &vec3); + auto* matrix = create(Source{}, "matrix", + ast::StorageClass::kNone, &mat3x2); mod->AddGlobalVariable(vector); mod->AddGlobalVariable(matrix); @@ -1522,10 +1540,10 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Matrix) { ast::type::Matrix mat4x3(&f32, 4, 3); ast::type::Matrix mat3x4(&f32, 3, 4); - auto* matrix1 = - create("mat4x3", ast::StorageClass::kNone, &mat4x3); - auto* matrix2 = - create("mat3x4", ast::StorageClass::kNone, &mat3x4); + auto* matrix1 = create(Source{}, "mat4x3", + ast::StorageClass::kNone, &mat4x3); + auto* matrix2 = create(Source{}, "mat3x4", + ast::StorageClass::kNone, &mat3x4); mod->AddGlobalVariable(matrix1); mod->AddGlobalVariable(matrix2); @@ -1552,7 +1570,8 @@ TEST_P(IntrinsicDerivativeTest, Scalar) { ast::type::F32 f32; - auto* var = create("ident", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "ident", ast::StorageClass::kNone, &f32); mod->AddGlobalVariable(var); // Register the global @@ -1575,7 +1594,8 @@ TEST_P(IntrinsicDerivativeTest, Vector) { ast::type::F32 f32; ast::type::Vector vec4(&f32, 4); - auto* var = create("ident", ast::StorageClass::kNone, &vec4); + auto* var = + create(Source{}, "ident", ast::StorageClass::kNone, &vec4); mod->AddGlobalVariable(var); // Register the global @@ -1619,8 +1639,10 @@ TEST_P(IntrinsicDerivativeTest, ToomManyParams) { ast::type::F32 f32; ast::type::Vector vec4(&f32, 4); - auto* var1 = create("ident1", ast::StorageClass::kNone, &vec4); - auto* var2 = create("ident2", ast::StorageClass::kNone, &vec4); + auto* var1 = create(Source{}, "ident1", + ast::StorageClass::kNone, &vec4); + auto* var2 = create(Source{}, "ident2", + ast::StorageClass::kNone, &vec4); mod->AddGlobalVariable(var1); mod->AddGlobalVariable(var2); @@ -1655,7 +1677,8 @@ TEST_P(Intrinsic, Test) { ast::type::Bool bool_type; ast::type::Vector vec3(&bool_type, 3); - auto* var = create("my_var", ast::StorageClass::kNone, &vec3); + auto* var = create(Source{}, "my_var", + ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); ast::ExpressionList call_params; @@ -1682,7 +1705,8 @@ TEST_P(Intrinsic_FloatMethod, Vector) { ast::type::F32 f32; ast::type::Vector vec3(&f32, 3); - auto* var = create("my_var", ast::StorageClass::kNone, &vec3); + auto* var = create(Source{}, "my_var", + ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); ast::ExpressionList call_params; @@ -1709,7 +1733,8 @@ TEST_P(Intrinsic_FloatMethod, Scalar) { ast::type::F32 f32; - auto* var = create("my_var", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "my_var", ast::StorageClass::kNone, &f32); mod->AddGlobalVariable(var); ast::ExpressionList call_params; @@ -1730,7 +1755,8 @@ TEST_P(Intrinsic_FloatMethod, MissingParam) { ast::type::F32 f32; - auto* var = create("my_var", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "my_var", ast::StorageClass::kNone, &f32); mod->AddGlobalVariable(var); ast::ExpressionList call_params; @@ -1748,7 +1774,8 @@ TEST_P(Intrinsic_FloatMethod, TooManyParams) { ast::type::F32 f32; - auto* var = create("my_var", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "my_var", ast::StorageClass::kNone, &f32); mod->AddGlobalVariable(var); ast::ExpressionList call_params; @@ -1817,7 +1844,8 @@ class Intrinsic_TextureOperation void add_call_param(std::string name, ast::type::Type* type, ast::ExpressionList* call_params) { - auto* var = create(name, ast::StorageClass::kNone, type); + auto* var = + create(Source{}, name, ast::StorageClass::kNone, type); mod->AddGlobalVariable(var); call_params->push_back(create(name)); } @@ -1969,7 +1997,8 @@ TEST_F(TypeDeterminerTest, Intrinsic_Dot) { ast::type::F32 f32; ast::type::Vector vec3(&f32, 3); - auto* var = create("my_var", ast::StorageClass::kNone, &vec3); + auto* var = create(Source{}, "my_var", + ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); ast::ExpressionList call_params; @@ -1992,9 +2021,10 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select) { ast::type::Vector vec3(&f32, 3); ast::type::Vector bool_vec3(&bool_type, 3); - auto* var = create("my_var", ast::StorageClass::kNone, &vec3); - auto* bool_var = - create("bool_var", ast::StorageClass::kNone, &bool_vec3); + auto* var = create(Source{}, "my_var", + ast::StorageClass::kNone, &vec3); + auto* bool_var = create(Source{}, "bool_var", + ast::StorageClass::kNone, &bool_vec3); mod->AddGlobalVariable(var); mod->AddGlobalVariable(bool_var); @@ -2022,7 +2052,8 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select_TooFewParams) { ast::type::F32 f32; ast::type::Vector vec3(&f32, 3); - auto* var = create("v", ast::StorageClass::kNone, &vec3); + auto* var = + create(Source{}, "v", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); ast::ExpressionList call_params; @@ -2042,7 +2073,8 @@ TEST_F(TypeDeterminerTest, Intrinsic_Select_TooManyParams) { ast::type::F32 f32; ast::type::Vector vec3(&f32, 3); - auto* var = create("v", ast::StorageClass::kNone, &vec3); + auto* var = + create(Source{}, "v", ast::StorageClass::kNone, &vec3); mod->AddGlobalVariable(var); ast::ExpressionList call_params; @@ -2066,8 +2098,10 @@ TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct) { ast::type::Vector vec3(&f32, 3); ast::type::Vector vec2(&f32, 2); - auto* var1 = create("v3", ast::StorageClass::kNone, &vec3); - auto* var2 = create("v2", ast::StorageClass::kNone, &vec2); + auto* var1 = + create(Source{}, "v3", ast::StorageClass::kNone, &vec3); + auto* var2 = + create(Source{}, "v2", ast::StorageClass::kNone, &vec2); mod->AddGlobalVariable(var1); mod->AddGlobalVariable(var2); @@ -2096,7 +2130,8 @@ TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct_TooFewParams) { ast::type::Vector vec3(&f32, 3); ast::type::Vector vec2(&f32, 2); - auto* var2 = create("v2", ast::StorageClass::kNone, &vec2); + auto* var2 = + create(Source{}, "v2", ast::StorageClass::kNone, &vec2); mod->AddGlobalVariable(var2); ast::ExpressionList call_params; @@ -2116,7 +2151,8 @@ TEST_F(TypeDeterminerTest, Intrinsic_OuterProduct_TooManyParams) { ast::type::Vector vec3(&f32, 3); ast::type::Vector vec2(&f32, 2); - auto* var2 = create("v2", ast::StorageClass::kNone, &vec2); + auto* var2 = + create(Source{}, "v2", ast::StorageClass::kNone, &vec2); mod->AddGlobalVariable(var2); ast::ExpressionList call_params; @@ -2141,7 +2177,8 @@ TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) { ast::type::Vector vec4(&f32, 4); - auto* var = create("ident", ast::StorageClass::kNone, &vec4); + auto* var = + create(Source{}, "ident", ast::StorageClass::kNone, &vec4); mod->AddGlobalVariable(var); // Register the global @@ -2163,7 +2200,8 @@ INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest, TEST_F(TypeDeterminerTest, StorageClass_SetsIfMissing) { ast::type::I32 i32; - auto* var = create("var", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "var", ast::StorageClass::kNone, &i32); auto* stmt = create(var); auto* body = create(); @@ -2180,7 +2218,8 @@ TEST_F(TypeDeterminerTest, StorageClass_SetsIfMissing) { TEST_F(TypeDeterminerTest, StorageClass_DoesNotSetOnConst) { ast::type::I32 i32; - auto* var = create("var", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "var", ast::StorageClass::kNone, &i32); var->set_is_const(true); auto* stmt = create(var); @@ -2198,7 +2237,8 @@ TEST_F(TypeDeterminerTest, StorageClass_DoesNotSetOnConst) { TEST_F(TypeDeterminerTest, StorageClass_NonFunctionClassError) { ast::type::I32 i32; - auto* var = create("var", ast::StorageClass::kWorkgroup, &i32); + auto* var = create(Source{}, "var", + ast::StorageClass::kWorkgroup, &i32); auto* stmt = create(var); auto* body = create(); @@ -4255,7 +4295,8 @@ TEST_F(TypeDeterminerTest, ImportData_GLSL_Determinant) { ast::type::F32 f32; ast::type::Matrix mat(&f32, 3, 3); - auto* var = create("var", ast::StorageClass::kFunction, &mat); + auto* var = create(Source{}, "var", + ast::StorageClass::kFunction, &mat); mod->AddGlobalVariable(var); // Register the global @@ -4280,7 +4321,8 @@ TEST_P(ImportData_Matrix_OneParam_Test, Error_Float) { ast::type::F32 f32; - auto* var = create("var", ast::StorageClass::kFunction, &f32); + auto* var = create(Source{}, "var", + ast::StorageClass::kFunction, &f32); mod->AddGlobalVariable(var); // Register the global @@ -4316,7 +4358,8 @@ TEST_P(ImportData_Matrix_OneParam_Test, TooManyParams) { ast::type::F32 f32; ast::type::Matrix mat(&f32, 3, 3); - auto* var = create("var", ast::StorageClass::kFunction, &mat); + auto* var = create(Source{}, "var", + ast::StorageClass::kFunction, &mat); mod->AddGlobalVariable(var); // Register the global @@ -4406,16 +4449,16 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) { mod->AddFunction(ep_1); mod->AddFunction(ep_2); - mod->AddGlobalVariable( - create("first", ast::StorageClass::kPrivate, &f32)); - mod->AddGlobalVariable( - create("second", ast::StorageClass::kPrivate, &f32)); - mod->AddGlobalVariable( - create("call_a", ast::StorageClass::kPrivate, &f32)); - mod->AddGlobalVariable( - create("call_b", ast::StorageClass::kPrivate, &f32)); - mod->AddGlobalVariable( - create("call_c", ast::StorageClass::kPrivate, &f32)); + mod->AddGlobalVariable(create( + Source{}, "first", ast::StorageClass::kPrivate, &f32)); + mod->AddGlobalVariable(create( + Source{}, "second", ast::StorageClass::kPrivate, &f32)); + mod->AddGlobalVariable(create( + Source{}, "call_a", ast::StorageClass::kPrivate, &f32)); + mod->AddGlobalVariable(create( + Source{}, "call_b", ast::StorageClass::kPrivate, &f32)); + mod->AddGlobalVariable(create( + Source{}, "call_c", ast::StorageClass::kPrivate, &f32)); // Register the functions and calculate the callers ASSERT_TRUE(td()->Determine()) << td()->error(); diff --git a/src/validator/validator_control_block_test.cc b/src/validator/validator_control_block_test.cc index 7e4fef27b8..08f59b94c2 100644 --- a/src/validator/validator_control_block_test.cc +++ b/src/validator/validator_control_block_test.cc @@ -43,7 +43,8 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) { // default: {} // } ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &f32); var->set_constructor(create( create(&f32, 3.14f))); @@ -71,7 +72,8 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_Fail) { // case 1: {} // } ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -102,7 +104,8 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) { // default: {} // } ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -145,7 +148,8 @@ TEST_F(ValidateControlBlockTest, // } ast::type::U32 u32; ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -181,7 +185,8 @@ TEST_F(ValidateControlBlockTest, // } ast::type::U32 u32; ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &u32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &u32); var->set_constructor(create( create(&u32, 2))); @@ -216,7 +221,8 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) { // default: {} // } ast::type::U32 u32; - auto* var = create("a", ast::StorageClass::kNone, &u32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &u32); var->set_constructor(create( create(&u32, 3))); @@ -257,7 +263,8 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) { // default: {} // } ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -298,7 +305,8 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) { // default: { fallthrough; } // } ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -328,7 +336,8 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) { // case 5: {} // } ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -361,7 +370,8 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) { ast::type::U32 u32; ast::type::Alias my_int{"MyInt", &u32}; - auto* var = create("a", ast::StorageClass::kNone, &my_int); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &my_int); var->set_constructor(create( create(&u32, 2))); diff --git a/src/validator/validator_function_test.cc b/src/validator/validator_function_test.cc index c767789cd7..4911941b56 100644 --- a/src/validator/validator_function_test.cc +++ b/src/validator/validator_function_test.cc @@ -39,7 +39,8 @@ TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) { // [[stage(vertex)]] // fn func -> void { var a:i32 = 2; } ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -80,7 +81,8 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) { // fn func -> int { var a:i32 = 2; } ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -237,7 +239,8 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) { TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) { // fn func() -> i32 {var a: i32 = func(); return 2; } ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); ast::ExpressionList call_params; auto* call_expr = create( Source{Source::Location{12, 34}}, @@ -288,7 +291,8 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_WithParams_Fail) { ast::type::I32 i32; ast::type::Void void_type; ast::VariableList params; - params.push_back(create("a", ast::StorageClass::kNone, &i32)); + params.push_back( + create(Source{}, "a", ast::StorageClass::kNone, &i32)); auto* body = create(); body->append(create()); auto* func = create( diff --git a/src/validator/validator_test.cc b/src/validator/validator_test.cc index 6c5871bb35..49a8d2fb44 100644 --- a/src/validator/validator_test.cc +++ b/src/validator/validator_test.cc @@ -115,7 +115,8 @@ TEST_F(ValidatorTest, AssignCompatibleTypes_Pass) { // var a :i32 = 2; // a = 2 ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -139,7 +140,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypes_Fail) { ast::type::F32 f32; ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); auto* lhs = create("a"); @@ -165,7 +167,8 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) { // a = 2 // } ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); @@ -193,7 +196,8 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) { ast::type::F32 f32; ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); auto* lhs = create("a"); @@ -274,8 +278,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) { // not_global_var = 3.14f; // } ast::type::F32 f32; - auto* global_var = - create("global_var", ast::StorageClass::kPrivate, &f32); + auto* global_var = create(Source{}, "global_var", + ast::StorageClass::kPrivate, &f32); global_var->set_constructor(create( create(&f32, 2.1))); mod()->AddGlobalVariable(global_var); @@ -307,8 +311,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) { ast::type::F32 f32; ast::type::Void void_type; - auto* global_var = - create("global_var", ast::StorageClass::kPrivate, &f32); + auto* global_var = create(Source{}, "global_var", + ast::StorageClass::kPrivate, &f32); global_var->set_constructor(create( create(&f32, 2.1))); mod()->AddGlobalVariable(global_var); @@ -340,7 +344,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) { // a = 3.14; // } ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &f32); var->set_constructor(create( create(&f32, 2.0))); @@ -374,7 +379,8 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) { // if (true) { a = 3.14; } // } ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &f32); var->set_constructor(create( create(&f32, 2.0))); @@ -405,8 +411,8 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) { // var global_var1 : i32 = 0; ast::type::F32 f32; ast::type::I32 i32; - auto* var0 = - create("global_var0", ast::StorageClass::kPrivate, &f32); + auto* var0 = create(Source{}, "global_var0", + ast::StorageClass::kPrivate, &f32); var0->set_constructor(create( create(&f32, 0.1))); mod()->AddGlobalVariable(var0); @@ -427,8 +433,8 @@ TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) { // var global_var : i32 = 0; ast::type::F32 f32; ast::type::I32 i32; - auto* var0 = - create("global_var", ast::StorageClass::kPrivate, &f32); + auto* var0 = create(Source{}, "global_var", + ast::StorageClass::kPrivate, &f32); var0->set_constructor(create( create(&f32, 0.1))); mod()->AddGlobalVariable(var0); @@ -451,7 +457,8 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) { // a = 2 // } ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); var->set_is_const(true); @@ -483,12 +490,13 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) { ast::type::Void void_type; ast::type::F32 f32; auto* global_var = - create("a", ast::StorageClass::kPrivate, &f32); + create(Source{}, "a", ast::StorageClass::kPrivate, &f32); global_var->set_constructor(create( create(&f32, 2.1))); mod()->AddGlobalVariable(global_var); - auto* var = create("a", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &f32); var->set_constructor(create( create(&f32, 2.0))); ast::VariableList params; @@ -514,12 +522,13 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) { ast::type::Void void_type; ast::type::I32 i32; ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); var->set_constructor(create( create(&i32, 2))); auto* var_a_float = - create("a", ast::StorageClass::kNone, &f32); + create(Source{}, "a", ast::StorageClass::kNone, &f32); var_a_float->set_constructor(create( create(&f32, 0.1))); @@ -545,7 +554,8 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) { // var a : f32 = 3.14; // } ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &f32); var->set_constructor(create( create(&f32, 2.0))); @@ -556,7 +566,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) { body->append(create(var)); auto* var_a_float = - create("a", ast::StorageClass::kNone, &f32); + create(Source{}, "a", ast::StorageClass::kNone, &f32); var_a_float->set_constructor(create( create(&f32, 3.14))); @@ -579,11 +589,12 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) { // } ast::type::F32 f32; auto* var_a_float = - create("a", ast::StorageClass::kNone, &f32); + create(Source{}, "a", ast::StorageClass::kNone, &f32); var_a_float->set_constructor(create( create(&f32, 3.14))); - auto* var = create("a", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &f32); var->set_constructor(create( create(&f32, 2.0))); @@ -609,11 +620,13 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) { // func1 { var a : f32 = 3.0; return; } ast::type::F32 f32; ast::type::Void void_type; - auto* var0 = create("a", ast::StorageClass::kNone, &f32); + auto* var0 = + create(Source{}, "a", ast::StorageClass::kNone, &f32); var0->set_constructor(create( create(&f32, 2.0))); - auto* var1 = create("a", ast::StorageClass::kNone, &void_type); + auto* var1 = create(Source{}, "a", ast::StorageClass::kNone, + &void_type); var1->set_constructor(create( create(&f32, 1.0))); @@ -649,7 +662,8 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) { // a = 2; // } ast::type::I32 i32; - auto* var = create("a", ast::StorageClass::kNone, &i32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &i32); td()->RegisterVariableForTesting(var); auto* lhs = create("a"); diff --git a/src/validator/validator_type_test.cc b/src/validator/validator_type_test.cc index 48bbc33b5d..fbec4900ad 100644 --- a/src/validator/validator_type_test.cc +++ b/src/validator/validator_type_test.cc @@ -193,7 +193,8 @@ TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) { ast::type::I32 i32; ast::type::Array array(&i32); - auto* var = create("a", ast::StorageClass::kNone, &array); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &array); ast::VariableList params; ast::type::Void void_type; auto* body = create(); diff --git a/src/writer/hlsl/generator_impl_binary_test.cc b/src/writer/hlsl/generator_impl_binary_test.cc index 37bc11ab82..4dd592ffb6 100644 --- a/src/writer/hlsl/generator_impl_binary_test.cc +++ b/src/writer/hlsl/generator_impl_binary_test.cc @@ -62,10 +62,10 @@ TEST_P(HlslBinaryTest, Emit_f32) { auto params = GetParam(); - auto* left_var = - create("left", ast::StorageClass::kFunction, &f32); - auto* right_var = - create("right", ast::StorageClass::kFunction, &f32); + auto* left_var = create(Source{}, "left", + ast::StorageClass::kFunction, &f32); + auto* right_var = create(Source{}, "right", + ast::StorageClass::kFunction, &f32); auto* left = create("left"); auto* right = create("right"); @@ -84,10 +84,10 @@ TEST_P(HlslBinaryTest, Emit_u32) { auto params = GetParam(); - auto* left_var = - create("left", ast::StorageClass::kFunction, &u32); - auto* right_var = - create("right", ast::StorageClass::kFunction, &u32); + auto* left_var = create(Source{}, "left", + ast::StorageClass::kFunction, &u32); + auto* right_var = create(Source{}, "right", + ast::StorageClass::kFunction, &u32); auto* left = create("left"); auto* right = create("right"); @@ -106,10 +106,10 @@ TEST_P(HlslBinaryTest, Emit_i32) { auto params = GetParam(); - auto* left_var = - create("left", ast::StorageClass::kFunction, &i32); - auto* right_var = - create("right", ast::StorageClass::kFunction, &i32); + auto* left_var = create(Source{}, "left", + ast::StorageClass::kFunction, &i32); + auto* right_var = create(Source{}, "right", + ast::StorageClass::kFunction, &i32); auto* left = create("left"); auto* right = create("right"); @@ -199,7 +199,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar) { ast::type::F32 f32; ast::type::Matrix mat3(&f32, 3, 3); - auto* var = create("mat", ast::StorageClass::kFunction, &mat3); + auto* var = create(Source{}, "mat", + ast::StorageClass::kFunction, &mat3); auto* lhs = create("mat"); auto* rhs = create( create(&f32, 1.f)); @@ -217,7 +218,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) { ast::type::F32 f32; ast::type::Matrix mat3(&f32, 3, 3); - auto* var = create("mat", ast::StorageClass::kFunction, &mat3); + auto* var = create(Source{}, "mat", + ast::StorageClass::kFunction, &mat3); auto* lhs = create( create(&f32, 1.f)); auto* rhs = create("mat"); @@ -236,7 +238,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector) { ast::type::Vector vec3(&f32, 3); ast::type::Matrix mat3(&f32, 3, 3); - auto* var = create("mat", ast::StorageClass::kFunction, &mat3); + auto* var = create(Source{}, "mat", + ast::StorageClass::kFunction, &mat3); auto* lhs = create("mat"); ast::ExpressionList vals; @@ -262,7 +265,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix) { ast::type::Vector vec3(&f32, 3); ast::type::Matrix mat3(&f32, 3, 3); - auto* var = create("mat", ast::StorageClass::kFunction, &mat3); + auto* var = create(Source{}, "mat", + ast::StorageClass::kFunction, &mat3); ast::ExpressionList vals; vals.push_back(create( @@ -289,7 +293,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixMatrix) { ast::type::Vector vec3(&f32, 3); ast::type::Matrix mat3(&f32, 3, 3); - auto* var = create("mat", ast::StorageClass::kFunction, &mat3); + auto* var = create(Source{}, "mat", + ast::StorageClass::kFunction, &mat3); auto* lhs = create("mat"); auto* rhs = create("mat"); @@ -482,8 +487,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Decl_WithLogical) { auto* c = create("c"); auto* d = create("d"); - auto* var = - create("a", ast::StorageClass::kFunction, &bool_type); + auto* var = create(Source{}, "a", ast::StorageClass::kFunction, + &bool_type); var->set_constructor(create( ast::BinaryOp::kLogicalOr, create(ast::BinaryOp::kLogicalAnd, b, c), d)); 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 38e5cfdbb7..96b90446d9 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 @@ -53,11 +53,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::type::I32 i32; auto* foo_var = create( - create("foo", ast::StorageClass::kInput, &f32)); + create(Source{}, "foo", ast::StorageClass::kInput, &f32)); foo_var->set_decorations({create(0, Source{})}); auto* bar_var = create( - create("bar", ast::StorageClass::kInput, &i32)); + create(Source{}, "bar", ast::StorageClass::kInput, &i32)); bar_var->set_decorations({create(1, Source{})}); td.RegisterVariableForTesting(foo_var); @@ -109,11 +109,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::type::I32 i32; auto* foo_var = create( - create("foo", ast::StorageClass::kOutput, &f32)); + create(Source{}, "foo", ast::StorageClass::kOutput, &f32)); foo_var->set_decorations({create(0, Source{})}); auto* bar_var = create( - create("bar", ast::StorageClass::kOutput, &i32)); + create(Source{}, "bar", ast::StorageClass::kOutput, &i32)); bar_var->set_decorations({create(1, Source{})}); td.RegisterVariableForTesting(foo_var); @@ -166,11 +166,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::type::I32 i32; auto* foo_var = create( - create("foo", ast::StorageClass::kInput, &f32)); + create(Source{}, "foo", ast::StorageClass::kInput, &f32)); foo_var->set_decorations({create(0, Source{})}); auto* bar_var = create( - create("bar", ast::StorageClass::kInput, &i32)); + create(Source{}, "bar", ast::StorageClass::kInput, &i32)); bar_var->set_decorations({create(1, Source{})}); td.RegisterVariableForTesting(foo_var); @@ -223,11 +223,11 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::type::I32 i32; auto* foo_var = create( - create("foo", ast::StorageClass::kOutput, &f32)); + create(Source{}, "foo", ast::StorageClass::kOutput, &f32)); foo_var->set_decorations({create(0, Source{})}); auto* bar_var = create( - create("bar", ast::StorageClass::kOutput, &i32)); + create(Source{}, "bar", ast::StorageClass::kOutput, &i32)); bar_var->set_decorations({create(1, Source{})}); td.RegisterVariableForTesting(foo_var); @@ -276,14 +276,14 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::type::I32 i32; auto* foo_var = create( - create("foo", ast::StorageClass::kInput, &f32)); + create(Source{}, "foo", ast::StorageClass::kInput, &f32)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); foo_var->set_decorations(decos); auto* bar_var = create( - create("bar", ast::StorageClass::kInput, &i32)); + create(Source{}, "bar", ast::StorageClass::kInput, &i32)); decos.push_back(create(1, Source{})); bar_var->set_decorations(decos); @@ -328,14 +328,14 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::type::I32 i32; auto* foo_var = create( - create("foo", ast::StorageClass::kOutput, &f32)); + create(Source{}, "foo", ast::StorageClass::kOutput, &f32)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); foo_var->set_decorations(decos); auto* bar_var = create( - create("bar", ast::StorageClass::kOutput, &i32)); + create(Source{}, "bar", ast::StorageClass::kOutput, &i32)); decos.push_back(create(1, Source{})); bar_var->set_decorations(decos); @@ -386,13 +386,13 @@ TEST_F(HlslGeneratorImplTest_EntryPoint, ast::type::Void void_type; ast::type::Vector vec4(&f32, 4); - auto* coord_var = create( - create("coord", ast::StorageClass::kInput, &vec4)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kInput, &vec4)); coord_var->set_decorations( {create(ast::Builtin::kFragCoord, Source{})}); - auto* depth_var = create( - create("depth", ast::StorageClass::kOutput, &f32)); + auto* depth_var = create(create( + Source{}, "depth", ast::StorageClass::kOutput, &f32)); depth_var->set_decorations( {create(ast::Builtin::kFragDepth, Source{})}); diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc index c8ac19fae0..2f107ef083 100644 --- a/src/writer/hlsl/generator_impl_function_test.cc +++ b/src/writer/hlsl/generator_impl_function_test.cc @@ -98,8 +98,10 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) { ast::type::I32 i32; ast::VariableList params; - params.push_back(create("a", ast::StorageClass::kNone, &f32)); - params.push_back(create("b", ast::StorageClass::kNone, &i32)); + params.push_back( + create(Source{}, "a", ast::StorageClass::kNone, &f32)); + params.push_back( + create(Source{}, "b", ast::StorageClass::kNone, &i32)); ast::type::Void void_type; @@ -125,11 +127,11 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::F32 f32; auto* foo_var = create( - create("foo", ast::StorageClass::kInput, &f32)); + create(Source{}, "foo", ast::StorageClass::kInput, &f32)); foo_var->set_decorations({create(0, Source{})}); auto* bar_var = create( - create("bar", ast::StorageClass::kOutput, &f32)); + create(Source{}, "bar", ast::StorageClass::kOutput, &f32)); bar_var->set_decorations({create(1, Source{})}); td.RegisterVariableForTesting(foo_var); @@ -177,14 +179,14 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::F32 f32; ast::type::Vector vec4(&f32, 4); - auto* coord_var = create( - create("coord", ast::StorageClass::kInput, &vec4)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kInput, &vec4)); coord_var->set_decorations( {create(ast::Builtin::kFragCoord, Source{})}); - auto* depth_var = create( - create("depth", ast::StorageClass::kOutput, &f32)); + auto* depth_var = create(create( + Source{}, "depth", ast::StorageClass::kOutput, &f32)); depth_var->set_decorations( {create(ast::Builtin::kFragDepth, Source{})}); @@ -235,8 +237,8 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::F32 f32; ast::type::Vector vec4(&f32, 4); - auto* coord_var = create( - create("coord", ast::StorageClass::kUniform, &vec4)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kUniform, &vec4)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -247,7 +249,8 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(coord_var); ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = + create(Source{}, "v", ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("coord"), create("x"))); @@ -291,8 +294,8 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::Struct s("Uniforms", str); - auto* coord_var = create( - create("uniforms", ast::StorageClass::kUniform, &s)); + auto* coord_var = create(create( + Source{}, "uniforms", ast::StorageClass::kUniform, &s)); mod.AddConstructedType(&s); @@ -305,7 +308,8 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(coord_var); ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = + create(Source{}, "v", ast::StorageClass::kFunction, &f32); var->set_constructor(create( create( create("uniforms"), @@ -359,8 +363,8 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); - auto* coord_var = create( - create("coord", ast::StorageClass::kStorageBuffer, &ac)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -371,7 +375,8 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(coord_var); ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = + create(Source{}, "v", ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("coord"), create("b"))); @@ -419,8 +424,8 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s); - auto* coord_var = create( - create("coord", ast::StorageClass::kStorageBuffer, &ac)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -431,7 +436,8 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(coord_var); ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = + create(Source{}, "v", ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("coord"), create("b"))); @@ -479,8 +485,8 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); - auto* coord_var = create( - create("coord", ast::StorageClass::kStorageBuffer, &ac)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -529,15 +535,15 @@ TEST_F( ast::type::F32 f32; auto* foo_var = create( - create("foo", ast::StorageClass::kInput, &f32)); + create(Source{}, "foo", ast::StorageClass::kInput, &f32)); foo_var->set_decorations({create(0, Source{})}); auto* bar_var = create( - create("bar", ast::StorageClass::kOutput, &f32)); + create(Source{}, "bar", ast::StorageClass::kOutput, &f32)); bar_var->set_decorations({create(1, Source{})}); auto* val_var = create( - create("val", ast::StorageClass::kOutput, &f32)); + create(Source{}, "val", ast::StorageClass::kOutput, &f32)); val_var->set_decorations({create(0, Source{})}); td.RegisterVariableForTesting(foo_var); @@ -549,8 +555,8 @@ TEST_F( mod.AddGlobalVariable(val_var); ast::VariableList params; - params.push_back( - create("param", ast::StorageClass::kFunction, &f32)); + params.push_back(create(Source{}, "param", + ast::StorageClass::kFunction, &f32)); auto* body = create(); body->append(create( @@ -616,8 +622,8 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::F32 f32; ast::type::Vector vec4(&f32, 4); - auto* depth_var = create( - create("depth", ast::StorageClass::kOutput, &f32)); + auto* depth_var = create(create( + Source{}, "depth", ast::StorageClass::kOutput, &f32)); ast::VariableDecorationList decos; decos.push_back( @@ -629,8 +635,8 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(depth_var); ast::VariableList params; - params.push_back( - create("param", ast::StorageClass::kFunction, &f32)); + params.push_back(create(Source{}, "param", + ast::StorageClass::kFunction, &f32)); auto* body = create(); body->append( @@ -684,13 +690,13 @@ TEST_F( ast::type::F32 f32; ast::type::Vector vec4(&f32, 4); - auto* coord_var = create( - create("coord", ast::StorageClass::kInput, &vec4)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kInput, &vec4)); coord_var->set_decorations( {create(ast::Builtin::kFragCoord, Source{})}); - auto* depth_var = create( - create("depth", ast::StorageClass::kOutput, &f32)); + auto* depth_var = create(create( + Source{}, "depth", ast::StorageClass::kOutput, &f32)); depth_var->set_decorations( {create(ast::Builtin::kFragDepth, Source{})}); @@ -701,8 +707,8 @@ TEST_F( mod.AddGlobalVariable(depth_var); ast::VariableList params; - params.push_back( - create("param", ast::StorageClass::kFunction, &f32)); + params.push_back(create(Source{}, "param", + ast::StorageClass::kFunction, &f32)); auto* body = create(); body->append(create( @@ -765,8 +771,8 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::F32 f32; ast::type::Vector vec4(&f32, 4); - auto* coord_var = create( - create("coord", ast::StorageClass::kUniform, &vec4)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kUniform, &vec4)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -778,8 +784,8 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(coord_var); ast::VariableList params; - params.push_back( - create("param", ast::StorageClass::kFunction, &f32)); + params.push_back(create(Source{}, "param", + ast::StorageClass::kFunction, &f32)); auto* body = create(); body->append( @@ -795,7 +801,8 @@ TEST_F(HlslGeneratorImplTest_Function, expr.push_back(create( create(&f32, 1.0f))); - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = + create(Source{}, "v", ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("sub_func"), expr)); @@ -834,8 +841,8 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::F32 f32; ast::type::Vector vec4(&f32, 4); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &vec4); - auto* coord_var = create( - create("coord", ast::StorageClass::kStorageBuffer, &ac)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -847,8 +854,8 @@ TEST_F(HlslGeneratorImplTest_Function, mod.AddGlobalVariable(coord_var); ast::VariableList params; - params.push_back( - create("param", ast::StorageClass::kFunction, &f32)); + params.push_back(create(Source{}, "param", + ast::StorageClass::kFunction, &f32)); auto* body = create(); body->append( @@ -864,7 +871,8 @@ TEST_F(HlslGeneratorImplTest_Function, expr.push_back(create( create(&f32, 1.0f))); - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = + create(Source{}, "v", ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("sub_func"), expr)); @@ -902,7 +910,7 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::I32 i32; auto* bar_var = create( - create("bar", ast::StorageClass::kOutput, &f32)); + create(Source{}, "bar", ast::StorageClass::kOutput, &f32)); ast::VariableDecorationList decos; decos.push_back(create(1, Source{})); bar_var->set_decorations(decos); @@ -1032,7 +1040,8 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) { ast::type::Array ary(&f32, 5); ast::VariableList params; - params.push_back(create("a", ast::StorageClass::kNone, &ary)); + params.push_back( + create(Source{}, "a", ast::StorageClass::kNone, &ary)); ast::type::Void void_type; @@ -1086,8 +1095,8 @@ TEST_F(HlslGeneratorImplTest_Function, ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); - auto* data_var = create( - create("data", ast::StorageClass::kStorageBuffer, &ac)); + auto* data_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -1100,7 +1109,8 @@ TEST_F(HlslGeneratorImplTest_Function, { ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = create(Source{}, "v", + ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("data"), create("d"))); @@ -1120,7 +1130,8 @@ TEST_F(HlslGeneratorImplTest_Function, { ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = create(Source{}, "v", + ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("data"), create("d"))); diff --git a/src/writer/hlsl/generator_impl_import_test.cc b/src/writer/hlsl/generator_impl_import_test.cc index 6cec975d72..fafcd69ea2 100644 --- a/src/writer/hlsl/generator_impl_import_test.cc +++ b/src/writer/hlsl/generator_impl_import_test.cc @@ -268,7 +268,8 @@ TEST_F(HlslGeneratorImplTest_Import, HlslImportData_Determinant) { ast::type::F32 f32; ast::type::Matrix mat(&f32, 3, 3); - auto* var = create("var", ast::StorageClass::kFunction, &mat); + auto* var = create(Source{}, "var", + ast::StorageClass::kFunction, &mat); ast::ExpressionList params; params.push_back(create("var")); diff --git a/src/writer/hlsl/generator_impl_intrinsic_test.cc b/src/writer/hlsl/generator_impl_intrinsic_test.cc index fb019f0b0f..9a00a3a113 100644 --- a/src/writer/hlsl/generator_impl_intrinsic_test.cc +++ b/src/writer/hlsl/generator_impl_intrinsic_test.cc @@ -75,8 +75,10 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, DISABLED_Intrinsic_OuterProduct) { ast::type::Vector vec2(&f32, 2); ast::type::Vector vec3(&f32, 3); - auto* a = create("a", ast::StorageClass::kNone, &vec2); - auto* b = create("b", ast::StorageClass::kNone, &vec3); + auto* a = + create(Source{}, "a", ast::StorageClass::kNone, &vec2); + auto* b = + create(Source{}, "b", ast::StorageClass::kNone, &vec3); ast::ExpressionList params; params.push_back(create("a")); @@ -113,8 +115,8 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Intrinsic_Call) { ast::CallExpression call(create("dot"), params); - ast::Variable v1("param1", ast::StorageClass::kFunction, &vec); - ast::Variable v2("param2", ast::StorageClass::kFunction, &vec); + ast::Variable v1(Source{}, "param1", ast::StorageClass::kFunction, &vec); + ast::Variable v2(Source{}, "param2", ast::StorageClass::kFunction, &vec); td.RegisterVariableForTesting(&v1); td.RegisterVariableForTesting(&v2); diff --git a/src/writer/hlsl/generator_impl_loop_test.cc b/src/writer/hlsl/generator_impl_loop_test.cc index e180180a60..00dec1fa29 100644 --- a/src/writer/hlsl/generator_impl_loop_test.cc +++ b/src/writer/hlsl/generator_impl_loop_test.cc @@ -144,14 +144,15 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) { ast::type::F32 f32; - auto* var = create("lhs", ast::StorageClass::kFunction, &f32); + auto* var = create(Source{}, "lhs", + ast::StorageClass::kFunction, &f32); var->set_constructor(create( create(&f32, 2.4))); auto* body = create(); body->append(create(var)); - body->append(create( - create("other", ast::StorageClass::kFunction, &f32))); + body->append(create(create( + Source{}, "other", ast::StorageClass::kFunction, &f32))); auto* lhs = create("lhs"); auto* rhs = create("rhs"); diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc index dab22e1316..648d38c3ea 100644 --- a/src/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc @@ -58,7 +58,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) { ast::type::Struct s("Str", strct); auto* str_var = create( - create("str", ast::StorageClass::kPrivate, &s)); + create(Source{}, "str", ast::StorageClass::kPrivate, &s)); auto* str = create("str"); auto* mem = create("mem"); @@ -100,8 +100,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct s("Data", str); - auto* coord_var = create( - create("data", ast::StorageClass::kStorageBuffer, &s)); + auto* coord_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s)); ast::MemberAccessorExpression expr(create("data"), create("b")); @@ -143,8 +143,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct s("Data", str); - auto* coord_var = create( - create("data", ast::StorageClass::kStorageBuffer, &s)); + auto* coord_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s)); ast::MemberAccessorExpression expr(create("data"), create("a")); @@ -189,10 +189,11 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct s("Data", str); - auto* b_var = create("b", ast::StorageClass::kPrivate, &mat); + auto* b_var = + create(Source{}, "b", ast::StorageClass::kPrivate, &mat); - auto* coord_var = - create("data", ast::StorageClass::kStorageBuffer, &s); + auto* coord_var = create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s); auto* lhs = create( create("data"), @@ -248,8 +249,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct s("Data", str); - auto* coord_var = create( - create("data", ast::StorageClass::kStorageBuffer, &s)); + auto* coord_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s)); auto* lhs = create( create("data"), @@ -303,8 +304,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct s("Data", str); - auto* coord_var = create( - create("data", ast::StorageClass::kStorageBuffer, &s)); + auto* coord_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s)); ast::MemberAccessorExpression expr(create("data"), create("a")); @@ -353,8 +354,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct s("Data", str); - auto* coord_var = create( - create("data", ast::StorageClass::kStorageBuffer, &s)); + auto* coord_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s)); ast::MemberAccessorExpression expr(create("data"), create("a")); @@ -395,8 +396,8 @@ TEST_F( ast::type::Struct s("Data", str); - auto* coord_var = create( - create("data", ast::StorageClass::kStorageBuffer, &s)); + auto* coord_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s)); ast::MemberAccessorExpression expr(create("data"), create("a")); @@ -441,8 +442,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct s("Data", str); - auto* coord_var = create( - create("data", ast::StorageClass::kStorageBuffer, &s)); + auto* coord_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s)); ast::ArrayAccessorExpression expr( create( @@ -488,8 +489,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct s("Data", str); - auto* coord_var = create( - create("data", ast::StorageClass::kStorageBuffer, &s)); + auto* coord_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s)); ast::ArrayAccessorExpression expr( create( @@ -532,8 +533,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct s("Data", str); - auto* coord_var = create( - create("data", ast::StorageClass::kStorageBuffer, &s)); + auto* coord_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s)); ast::ArrayAccessorExpression expr( create( @@ -588,8 +589,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct s("Data", str); - auto* coord_var = create( - create("data", ast::StorageClass::kStorageBuffer, &s)); + auto* coord_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s)); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -634,8 +635,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct s("Data", str); - auto* coord_var = create( - create("data", ast::StorageClass::kStorageBuffer, &s)); + auto* coord_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s)); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -686,8 +687,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct s("Data", str); - auto* coord_var = create( - create("data", ast::StorageClass::kStorageBuffer, &s)); + auto* coord_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s)); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -737,8 +738,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct s("Data", str); - auto* coord_var = create( - create("data", ast::StorageClass::kStorageBuffer, &s)); + auto* coord_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s)); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -783,8 +784,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct s("Data", str); - auto* coord_var = create( - create("data", ast::StorageClass::kStorageBuffer, &s)); + auto* coord_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &s)); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -860,7 +861,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct pre_struct("Pre", pre_str); auto* coord_var = create(create( - "data", ast::StorageClass::kStorageBuffer, &pre_struct)); + Source{}, "data", ast::StorageClass::kStorageBuffer, &pre_struct)); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -930,7 +931,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct pre_struct("Pre", pre_str); auto* coord_var = create(create( - "data", ast::StorageClass::kStorageBuffer, &pre_struct)); + Source{}, "data", ast::StorageClass::kStorageBuffer, &pre_struct)); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -1000,7 +1001,7 @@ TEST_F( ast::type::Struct pre_struct("Pre", pre_str); auto* coord_var = create(create( - "data", ast::StorageClass::kStorageBuffer, &pre_struct)); + Source{}, "data", ast::StorageClass::kStorageBuffer, &pre_struct)); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -1069,7 +1070,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct pre_struct("Pre", pre_str); auto* coord_var = create(create( - "data", ast::StorageClass::kStorageBuffer, &pre_struct)); + Source{}, "data", ast::StorageClass::kStorageBuffer, &pre_struct)); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -1139,7 +1140,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct pre_struct("Pre", pre_str); auto* coord_var = create(create( - "data", ast::StorageClass::kStorageBuffer, &pre_struct)); + Source{}, "data", ast::StorageClass::kStorageBuffer, &pre_struct)); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); @@ -1220,7 +1221,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Struct pre_struct("Pre", pre_str); auto* coord_var = create(create( - "data", ast::StorageClass::kStorageBuffer, &pre_struct)); + Source{}, "data", ast::StorageClass::kStorageBuffer, &pre_struct)); td.RegisterVariableForTesting(coord_var); gen.register_global(coord_var); diff --git a/src/writer/hlsl/generator_impl_module_constant_test.cc b/src/writer/hlsl/generator_impl_module_constant_test.cc index 2e9603441a..884b7546f1 100644 --- a/src/writer/hlsl/generator_impl_module_constant_test.cc +++ b/src/writer/hlsl/generator_impl_module_constant_test.cc @@ -45,7 +45,8 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) { exprs.push_back(create( create(&f32, 3.0f))); - auto* var = create("pos", ast::StorageClass::kNone, &ary); + auto* var = + create(Source{}, "pos", ast::StorageClass::kNone, &ary); var->set_is_const(true); var->set_constructor(create(&ary, exprs)); @@ -60,7 +61,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) { decos.push_back(create(23, Source{})); auto* var = create( - create("pos", ast::StorageClass::kNone, &f32)); + create(Source{}, "pos", ast::StorageClass::kNone, &f32)); var->set_decorations(decos); var->set_is_const(true); var->set_constructor(create( @@ -82,7 +83,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoConstructor) { decos.push_back(create(23, Source{})); auto* var = create( - create("pos", ast::StorageClass::kNone, &f32)); + create(Source{}, "pos", ast::StorageClass::kNone, &f32)); var->set_decorations(decos); var->set_is_const(true); 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 4638cf62e8..b4e389f3af 100644 --- a/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/hlsl/generator_impl_variable_decl_statement_test.cc @@ -34,7 +34,8 @@ using HlslGeneratorImplTest_VariableDecl = TestHelper; TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) { ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &f32); ast::VariableDeclStatement stmt(var); gen.increment_indent(); @@ -45,7 +46,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) { TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const) { ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &f32); var->set_is_const(true); ast::VariableDeclStatement stmt(var); @@ -59,7 +61,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) { ast::type::F32 f32; ast::type::Array ary(&f32, 5); - auto* var = create("a", ast::StorageClass::kNone, &ary); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &ary); ast::VariableDeclStatement stmt(var); gen.increment_indent(); @@ -71,7 +74,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) { TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Function) { ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kFunction, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kFunction, &f32); ast::VariableDeclStatement stmt(var); gen.increment_indent(); @@ -82,7 +86,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) { ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kPrivate, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kPrivate, &f32); ast::VariableDeclStatement stmt(var); gen.increment_indent(); @@ -96,7 +101,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, auto* ident = create("initializer"); ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &f32); var->set_constructor(ident); ast::VariableDeclStatement stmt(var); @@ -113,7 +119,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, ast::ExpressionList values; auto* zero_vec = create(&vec, values); - auto* var = create("a", ast::StorageClass::kNone, &vec); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &vec); var->set_constructor(zero_vec); ast::VariableDeclStatement stmt(var); @@ -130,7 +137,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, ast::ExpressionList values; auto* zero_mat = create(&mat, values); - auto* var = create("a", ast::StorageClass::kNone, &mat); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &mat); var->set_constructor(zero_mat); ast::VariableDeclStatement stmt(var); 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 62f62865fa..8614c9f1e8 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 @@ -52,11 +52,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Input) { ast::type::I32 i32; auto* foo_var = create( - create("foo", ast::StorageClass::kInput, &f32)); + create(Source{}, "foo", ast::StorageClass::kInput, &f32)); foo_var->set_decorations({create(0, Source{})}); auto* bar_var = create( - create("bar", ast::StorageClass::kInput, &i32)); + create(Source{}, "bar", ast::StorageClass::kInput, &i32)); bar_var->set_decorations({create(1, Source{})}); td.RegisterVariableForTesting(foo_var); @@ -106,11 +106,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Output) { ast::type::I32 i32; auto* foo_var = create( - create("foo", ast::StorageClass::kOutput, &f32)); + create(Source{}, "foo", ast::StorageClass::kOutput, &f32)); foo_var->set_decorations({create(0, Source{})}); auto* bar_var = create( - create("bar", ast::StorageClass::kOutput, &i32)); + create(Source{}, "bar", ast::StorageClass::kOutput, &i32)); bar_var->set_decorations({create(1, Source{})}); td.RegisterVariableForTesting(foo_var); @@ -160,11 +160,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Input) { ast::type::I32 i32; auto* foo_var = create( - create("foo", ast::StorageClass::kInput, &f32)); + create(Source{}, "foo", ast::StorageClass::kInput, &f32)); foo_var->set_decorations({create(0, Source{})}); auto* bar_var = create( - create("bar", ast::StorageClass::kInput, &i32)); + create(Source{}, "bar", ast::StorageClass::kInput, &i32)); bar_var->set_decorations({create(1, Source{})}); td.RegisterVariableForTesting(foo_var); @@ -213,11 +213,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Output) { ast::type::I32 i32; auto* foo_var = create( - create("foo", ast::StorageClass::kOutput, &f32)); + create(Source{}, "foo", ast::StorageClass::kOutput, &f32)); foo_var->set_decorations({create(0, Source{})}); auto* bar_var = create( - create("bar", ast::StorageClass::kOutput, &i32)); + create(Source{}, "bar", ast::StorageClass::kOutput, &i32)); bar_var->set_decorations({create(1, Source{})}); td.RegisterVariableForTesting(foo_var); @@ -264,14 +264,14 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Input) { ast::type::I32 i32; auto* foo_var = create( - create("foo", ast::StorageClass::kInput, &f32)); + create(Source{}, "foo", ast::StorageClass::kInput, &f32)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); foo_var->set_decorations(decos); auto* bar_var = create( - create("bar", ast::StorageClass::kInput, &i32)); + create(Source{}, "bar", ast::StorageClass::kInput, &i32)); decos.push_back(create(1, Source{})); bar_var->set_decorations(decos); @@ -314,14 +314,14 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Output) { ast::type::I32 i32; auto* foo_var = create( - create("foo", ast::StorageClass::kOutput, &f32)); + create(Source{}, "foo", ast::StorageClass::kOutput, &f32)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); foo_var->set_decorations(decos); auto* bar_var = create( - create("bar", ast::StorageClass::kOutput, &i32)); + create(Source{}, "bar", ast::StorageClass::kOutput, &i32)); decos.push_back(create(1, Source{})); bar_var->set_decorations(decos); @@ -369,13 +369,13 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Builtins) { ast::type::Void void_type; ast::type::Vector vec4(&f32, 4); - auto* coord_var = create( - create("coord", ast::StorageClass::kInput, &vec4)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kInput, &vec4)); coord_var->set_decorations( {create(ast::Builtin::kFragCoord, Source{})}); - auto* depth_var = create( - create("depth", ast::StorageClass::kOutput, &f32)); + auto* depth_var = create(create( + Source{}, "depth", ast::StorageClass::kOutput, &f32)); depth_var->set_decorations( {create(ast::Builtin::kFragDepth, Source{})}); diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc index 453aaa8ffb..22eb8899a3 100644 --- a/src/writer/msl/generator_impl_function_test.cc +++ b/src/writer/msl/generator_impl_function_test.cc @@ -105,8 +105,10 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithParams) { ast::type::I32 i32; ast::VariableList params; - params.push_back(create("a", ast::StorageClass::kNone, &f32)); - params.push_back(create("b", ast::StorageClass::kNone, &i32)); + params.push_back( + create(Source{}, "a", ast::StorageClass::kNone, &f32)); + params.push_back( + create(Source{}, "b", ast::StorageClass::kNone, &i32)); ast::type::Void void_type; @@ -133,11 +135,11 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithInOutVars) { ast::type::F32 f32; auto* foo_var = create( - create("foo", ast::StorageClass::kInput, &f32)); + create(Source{}, "foo", ast::StorageClass::kInput, &f32)); foo_var->set_decorations({create(0, Source{})}); auto* bar_var = create( - create("bar", ast::StorageClass::kOutput, &f32)); + create(Source{}, "bar", ast::StorageClass::kOutput, &f32)); bar_var->set_decorations({create(1, Source{})}); td.RegisterVariableForTesting(foo_var); @@ -188,13 +190,13 @@ TEST_F(MslGeneratorImplTest, ast::type::F32 f32; ast::type::Vector vec4(&f32, 4); - auto* coord_var = create( - create("coord", ast::StorageClass::kInput, &vec4)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kInput, &vec4)); coord_var->set_decorations( {create(ast::Builtin::kFragCoord, Source{})}); - auto* depth_var = create( - create("depth", ast::StorageClass::kOutput, &f32)); + auto* depth_var = create(create( + Source{}, "depth", ast::StorageClass::kOutput, &f32)); depth_var->set_decorations( {create(ast::Builtin::kFragDepth, Source{})}); @@ -244,8 +246,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) { ast::type::F32 f32; ast::type::Vector vec4(&f32, 4); - auto* coord_var = create( - create("coord", ast::StorageClass::kUniform, &vec4)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kUniform, &vec4)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -257,7 +259,8 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) { mod.AddGlobalVariable(coord_var); ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = + create(Source{}, "v", ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("coord"), create("x"))); @@ -309,8 +312,8 @@ TEST_F(MslGeneratorImplTest, mod.AddConstructedType(&s); - auto* coord_var = create( - create("coord", ast::StorageClass::kStorageBuffer, &ac)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -322,7 +325,8 @@ TEST_F(MslGeneratorImplTest, mod.AddGlobalVariable(coord_var); ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = + create(Source{}, "v", ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("coord"), create("b"))); @@ -378,8 +382,8 @@ TEST_F(MslGeneratorImplTest, mod.AddConstructedType(&s); - auto* coord_var = create( - create("coord", ast::StorageClass::kStorageBuffer, &ac)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -392,7 +396,8 @@ TEST_F(MslGeneratorImplTest, ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = + create(Source{}, "v", ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("coord"), create("b"))); @@ -434,15 +439,15 @@ TEST_F( ast::type::F32 f32; auto* foo_var = create( - create("foo", ast::StorageClass::kInput, &f32)); + create(Source{}, "foo", ast::StorageClass::kInput, &f32)); foo_var->set_decorations({create(0, Source{})}); auto* bar_var = create( - create("bar", ast::StorageClass::kOutput, &f32)); + create(Source{}, "bar", ast::StorageClass::kOutput, &f32)); bar_var->set_decorations({create(1, Source{})}); auto* val_var = create( - create("val", ast::StorageClass::kOutput, &f32)); + create(Source{}, "val", ast::StorageClass::kOutput, &f32)); val_var->set_decorations({create(0, Source{})}); td.RegisterVariableForTesting(foo_var); @@ -454,8 +459,8 @@ TEST_F( mod.AddGlobalVariable(val_var); ast::VariableList params; - params.push_back( - create("param", ast::StorageClass::kFunction, &f32)); + params.push_back(create(Source{}, "param", + ast::StorageClass::kFunction, &f32)); auto* body = create(); body->append(create( @@ -524,8 +529,8 @@ TEST_F(MslGeneratorImplTest, ast::type::F32 f32; ast::type::Vector vec4(&f32, 4); - auto* depth_var = create( - create("depth", ast::StorageClass::kOutput, &f32)); + auto* depth_var = create(create( + Source{}, "depth", ast::StorageClass::kOutput, &f32)); ast::VariableDecorationList decos; decos.push_back( @@ -537,8 +542,8 @@ TEST_F(MslGeneratorImplTest, mod.AddGlobalVariable(depth_var); ast::VariableList params; - params.push_back( - create("param", ast::StorageClass::kFunction, &f32)); + params.push_back(create(Source{}, "param", + ast::StorageClass::kFunction, &f32)); auto* body = create(); body->append( @@ -596,13 +601,13 @@ TEST_F( ast::type::F32 f32; ast::type::Vector vec4(&f32, 4); - auto* coord_var = create( - create("coord", ast::StorageClass::kInput, &vec4)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kInput, &vec4)); coord_var->set_decorations( {create(ast::Builtin::kFragCoord, Source{})}); - auto* depth_var = create( - create("depth", ast::StorageClass::kOutput, &f32)); + auto* depth_var = create(create( + Source{}, "depth", ast::StorageClass::kOutput, &f32)); depth_var->set_decorations( {create(ast::Builtin::kFragDepth, Source{})}); @@ -613,8 +618,8 @@ TEST_F( mod.AddGlobalVariable(depth_var); ast::VariableList params; - params.push_back( - create("param", ast::StorageClass::kFunction, &f32)); + params.push_back(create(Source{}, "param", + ast::StorageClass::kFunction, &f32)); auto* body = create(); body->append(create( @@ -675,8 +680,8 @@ TEST_F(MslGeneratorImplTest, ast::type::F32 f32; ast::type::Vector vec4(&f32, 4); - auto* coord_var = create( - create("coord", ast::StorageClass::kUniform, &vec4)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kUniform, &vec4)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -688,8 +693,8 @@ TEST_F(MslGeneratorImplTest, mod.AddGlobalVariable(coord_var); ast::VariableList params; - params.push_back( - create("param", ast::StorageClass::kFunction, &f32)); + params.push_back(create(Source{}, "param", + ast::StorageClass::kFunction, &f32)); auto* body = create(); body->append( @@ -705,7 +710,8 @@ TEST_F(MslGeneratorImplTest, expr.push_back(create( create(&f32, 1.0f))); - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = + create(Source{}, "v", ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("sub_func"), expr)); @@ -759,8 +765,8 @@ TEST_F(MslGeneratorImplTest, mod.AddConstructedType(&s); - auto* coord_var = create( - create("coord", ast::StorageClass::kStorageBuffer, &ac)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -771,8 +777,8 @@ TEST_F(MslGeneratorImplTest, mod.AddGlobalVariable(coord_var); ast::VariableList params; - params.push_back( - create("param", ast::StorageClass::kFunction, &f32)); + params.push_back(create(Source{}, "param", + ast::StorageClass::kFunction, &f32)); auto* body = create(); body->append( @@ -788,7 +794,8 @@ TEST_F(MslGeneratorImplTest, expr.push_back(create( create(&f32, 1.0f))); - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = + create(Source{}, "v", ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("sub_func"), expr)); @@ -848,8 +855,8 @@ TEST_F(MslGeneratorImplTest, mod.AddConstructedType(&s); - auto* coord_var = create( - create("coord", ast::StorageClass::kStorageBuffer, &ac)); + auto* coord_var = create(create( + Source{}, "coord", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -860,8 +867,8 @@ TEST_F(MslGeneratorImplTest, mod.AddGlobalVariable(coord_var); ast::VariableList params; - params.push_back( - create("param", ast::StorageClass::kFunction, &f32)); + params.push_back(create(Source{}, "param", + ast::StorageClass::kFunction, &f32)); auto* body = create(); body->append( @@ -877,7 +884,8 @@ TEST_F(MslGeneratorImplTest, expr.push_back(create( create(&f32, 1.0f))); - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = + create(Source{}, "v", ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("sub_func"), expr)); @@ -922,7 +930,7 @@ TEST_F(MslGeneratorImplTest, ast::type::I32 i32; auto* bar_var = create( - create("bar", ast::StorageClass::kOutput, &f32)); + create(Source{}, "bar", ast::StorageClass::kOutput, &f32)); ast::VariableDecorationList decos; decos.push_back(create(1, Source{})); bar_var->set_decorations(decos); @@ -1006,7 +1014,8 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayParams) { ast::type::Array ary(&f32, 5); ast::VariableList params; - params.push_back(create("a", ast::StorageClass::kNone, &ary)); + params.push_back( + create(Source{}, "a", ast::StorageClass::kNone, &ary)); ast::type::Void void_type; @@ -1063,8 +1072,8 @@ TEST_F(MslGeneratorImplTest, ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); - auto* data_var = create( - create("data", ast::StorageClass::kStorageBuffer, &ac)); + auto* data_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -1078,7 +1087,8 @@ TEST_F(MslGeneratorImplTest, { ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = create(Source{}, "v", + ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("data"), create("d"))); @@ -1099,7 +1109,8 @@ TEST_F(MslGeneratorImplTest, { ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = create(Source{}, "v", + ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("data"), create("d"))); diff --git a/src/writer/msl/generator_impl_import_test.cc b/src/writer/msl/generator_impl_import_test.cc index c36bf3cdb4..b25f6abb4f 100644 --- a/src/writer/msl/generator_impl_import_test.cc +++ b/src/writer/msl/generator_impl_import_test.cc @@ -267,7 +267,8 @@ TEST_F(MslGeneratorImplTest, MslImportData_Determinant) { ast::type::F32 f32; ast::type::Matrix mat(&f32, 3, 3); - auto* var = create("var", ast::StorageClass::kFunction, &mat); + auto* var = create(Source{}, "var", + ast::StorageClass::kFunction, &mat); ast::ExpressionList params; params.push_back(create("var")); diff --git a/src/writer/msl/generator_impl_intrinsic_test.cc b/src/writer/msl/generator_impl_intrinsic_test.cc index ca69fc09fc..164cee6976 100644 --- a/src/writer/msl/generator_impl_intrinsic_test.cc +++ b/src/writer/msl/generator_impl_intrinsic_test.cc @@ -70,8 +70,10 @@ TEST_F(MslGeneratorImplTest, DISABLED_Intrinsic_OuterProduct) { ast::type::Vector vec2(&f32, 2); ast::type::Vector vec3(&f32, 3); - auto* a = create("a", ast::StorageClass::kNone, &vec2); - auto* b = create("b", ast::StorageClass::kNone, &vec3); + auto* a = + create(Source{}, "a", ast::StorageClass::kNone, &vec2); + auto* b = + create(Source{}, "b", ast::StorageClass::kNone, &vec3); ast::ExpressionList params; params.push_back(create("a")); @@ -108,8 +110,8 @@ TEST_F(MslGeneratorImplTest, Intrinsic_Call) { ast::CallExpression call(create("dot"), params); - ast::Variable v1("param1", ast::StorageClass::kFunction, &vec); - ast::Variable v2("param2", ast::StorageClass::kFunction, &vec); + ast::Variable v1(Source{}, "param1", ast::StorageClass::kFunction, &vec); + ast::Variable v2(Source{}, "param2", ast::StorageClass::kFunction, &vec); td.RegisterVariableForTesting(&v1); td.RegisterVariableForTesting(&v2); diff --git a/src/writer/msl/generator_impl_loop_test.cc b/src/writer/msl/generator_impl_loop_test.cc index bd46e637b7..c4ef2581d0 100644 --- a/src/writer/msl/generator_impl_loop_test.cc +++ b/src/writer/msl/generator_impl_loop_test.cc @@ -149,14 +149,15 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) { ast::type::F32 f32; - auto* var = create("lhs", ast::StorageClass::kFunction, &f32); + auto* var = create(Source{}, "lhs", + ast::StorageClass::kFunction, &f32); var->set_constructor(create( create(&f32, 2.4))); auto* body = create(); body->append(create(var)); - body->append(create( - create("other", ast::StorageClass::kFunction, &f32))); + body->append(create(create( + Source{}, "other", ast::StorageClass::kFunction, &f32))); auto* lhs = create("lhs"); auto* rhs = create("rhs"); diff --git a/src/writer/msl/generator_impl_module_constant_test.cc b/src/writer/msl/generator_impl_module_constant_test.cc index ae03c77cea..97007b78ae 100644 --- a/src/writer/msl/generator_impl_module_constant_test.cc +++ b/src/writer/msl/generator_impl_module_constant_test.cc @@ -47,7 +47,8 @@ TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) { exprs.push_back(create( create(&f32, 3.0f))); - auto* var = create("pos", ast::StorageClass::kNone, &ary); + auto* var = + create(Source{}, "pos", ast::StorageClass::kNone, &ary); var->set_is_const(true); var->set_constructor(create(&ary, exprs)); @@ -62,7 +63,7 @@ TEST_F(MslGeneratorImplTest, Emit_SpecConstant) { decos.push_back(create(23, Source{})); auto* var = create( - create("pos", ast::StorageClass::kNone, &f32)); + create(Source{}, "pos", ast::StorageClass::kNone, &f32)); var->set_decorations(decos); var->set_is_const(true); var->set_constructor(create( 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 03a20b54bd..dcaf5429b0 100644 --- a/src/writer/msl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/msl/generator_impl_variable_decl_statement_test.cc @@ -42,7 +42,8 @@ using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement) { ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &f32); ast::VariableDeclStatement stmt(var); @@ -54,7 +55,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement) { TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const) { ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &f32); var->set_is_const(true); ast::VariableDeclStatement stmt(var); @@ -69,7 +71,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) { ast::type::F32 f32; ast::type::Array ary(&f32, 5); - auto* var = create("a", ast::StorageClass::kNone, &ary); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &ary); ast::VariableDeclStatement stmt(var); @@ -94,7 +97,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Struct) { ast::type::Struct s("S", str); - auto* var = create("a", ast::StorageClass::kNone, &s); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &s); ast::VariableDeclStatement stmt(var); @@ -109,7 +113,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Vector) { ast::type::F32 f32; ast::type::Vector vec(&f32, 2); - auto* var = create("a", ast::StorageClass::kFunction, &vec); + auto* var = + create(Source{}, "a", ast::StorageClass::kFunction, &vec); ast::VariableDeclStatement stmt(var); @@ -122,7 +127,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Vector) { TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Matrix) { ast::type::F32 f32; ast::type::Matrix mat(&f32, 2, 3); - auto* var = create("a", ast::StorageClass::kFunction, &mat); + auto* var = + create(Source{}, "a", ast::StorageClass::kFunction, &mat); ast::VariableDeclStatement stmt(var); @@ -134,7 +140,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Matrix) { TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) { ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kPrivate, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kPrivate, &f32); ast::VariableDeclStatement stmt(var); @@ -148,7 +155,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) { auto* ident = create("initializer"); ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &f32); var->set_constructor(ident); ast::VariableDeclStatement stmt(var); @@ -165,7 +173,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_ZeroVec) { ast::ExpressionList values; auto* zero_vec = create(&vec, values); - auto* var = create("a", ast::StorageClass::kNone, &vec); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &vec); var->set_constructor(zero_vec); ast::VariableDeclStatement stmt(var); diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc index a834a90888..65b66c4f27 100644 --- a/src/writer/spirv/builder_accessor_expression_test.cc +++ b/src/writer/spirv/builder_accessor_expression_test.cc @@ -53,7 +53,7 @@ TEST_F(BuilderTest, ArrayAccessor) { // vec3 ary; // ary[1] -> ptr - ast::Variable var("ary", ast::StorageClass::kFunction, &vec3); + ast::Variable var(Source{}, "ary", ast::StorageClass::kFunction, &vec3); auto* ary = create("ary"); auto* idx_expr = create( @@ -94,8 +94,8 @@ TEST_F(BuilderTest, Accessor_Array_LoadIndex) { // idx : i32; // ary[idx] -> ptr - ast::Variable var("ary", ast::StorageClass::kFunction, &vec3); - ast::Variable idx("idx", ast::StorageClass::kFunction, &i32); + ast::Variable var(Source{}, "ary", ast::StorageClass::kFunction, &vec3); + ast::Variable idx(Source{}, "idx", ast::StorageClass::kFunction, &i32); auto* ary = create("ary"); auto* idx_expr = create("idx"); @@ -139,7 +139,7 @@ TEST_F(BuilderTest, ArrayAccessor_Dynamic) { // vec3 ary; // ary[1 + 2] -> ptr - ast::Variable var("ary", ast::StorageClass::kFunction, &vec3); + ast::Variable var(Source{}, "ary", ast::StorageClass::kFunction, &vec3); auto* ary = create("ary"); @@ -186,7 +186,7 @@ TEST_F(BuilderTest, ArrayAccessor_MultiLevel) { // ary = array, 4> // ary[3][2]; - ast::Variable var("ary", ast::StorageClass::kFunction, &ary4); + ast::Variable var(Source{}, "ary", ast::StorageClass::kFunction, &ary4); ast::ArrayAccessorExpression expr( create( @@ -233,7 +233,7 @@ TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) { // var a : array, 4>; // a[2].xy; - ast::Variable var("ary", ast::StorageClass::kFunction, &ary4); + ast::Variable var(Source{}, "ary", ast::StorageClass::kFunction, &ary4); ast::MemberAccessorExpression expr( create( @@ -289,7 +289,7 @@ TEST_F(BuilderTest, MemberAccessor) { auto* s = create(members); ast::type::Struct s_type("my_struct", s); - ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); + ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type); ast::MemberAccessorExpression expr(create("ident"), create("b")); @@ -343,7 +343,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested) { ast::type::Struct s_type("my_struct", create(outer_members)); - ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); + ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type); ast::MemberAccessorExpression expr( create( @@ -403,7 +403,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) { ast::type::Struct s_type("Outer", create(outer_members)); - ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); + ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type); ast::MemberAccessorExpression expr( create( @@ -462,7 +462,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) { ast::type::Struct s_type("my_struct", create(outer_members)); - ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); + ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type); auto* lhs = create( create( @@ -528,8 +528,8 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) { ast::type::Struct s_type("my_struct", create(outer_members)); - ast::Variable var("ident", ast::StorageClass::kFunction, &s_type); - ast::Variable store("store", ast::StorageClass::kFunction, &f32); + ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type); + ast::Variable store(Source{}, "store", ast::StorageClass::kFunction, &f32); auto* lhs = create("store"); @@ -578,7 +578,7 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_Single) { // ident.y - ast::Variable var("ident", ast::StorageClass::kFunction, &vec3); + ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &vec3); ast::MemberAccessorExpression expr(create("ident"), create("y")); @@ -613,7 +613,7 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_MultipleNames) { // ident.yx - ast::Variable var("ident", ast::StorageClass::kFunction, &vec3); + ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &vec3); ast::MemberAccessorExpression expr(create("ident"), create("yx")); @@ -647,7 +647,7 @@ TEST_F(BuilderTest, MemberAccessor_Swizzle_of_Swizzle) { // ident.yxz.xz - ast::Variable var("ident", ast::StorageClass::kFunction, &vec3); + ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &vec3); ast::MemberAccessorExpression expr( create( @@ -685,7 +685,7 @@ TEST_F(BuilderTest, MemberAccessor_Member_of_Swizzle) { // ident.yxz.x - ast::Variable var("ident", ast::StorageClass::kFunction, &vec3); + ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &vec3); ast::MemberAccessorExpression expr( create( @@ -723,7 +723,7 @@ TEST_F(BuilderTest, MemberAccessor_Array_of_Swizzle) { // index.yxz[1] - ast::Variable var("ident", ast::StorageClass::kFunction, &vec3); + ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &vec3); ast::ArrayAccessorExpression expr( create( @@ -792,7 +792,8 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) { ast::type::Array a_ary_type(&a_type, 2); - ast::Variable var("index", ast::StorageClass::kFunction, &a_ary_type); + ast::Variable var(Source{}, "index", ast::StorageClass::kFunction, + &a_ary_type); ast::MemberAccessorExpression expr( create( @@ -884,7 +885,7 @@ TEST_F(BuilderTest, Accessor_Array_Of_Vec) { create(&f32, -0.5)), })); - ast::Variable var("pos", ast::StorageClass::kPrivate, &arr); + ast::Variable var(Source{}, "pos", ast::StorageClass::kPrivate, &arr); var.set_is_const(true); var.set_constructor(create(&arr, ary_params)); @@ -940,7 +941,7 @@ TEST_F(BuilderTest, Accessor_Const_Vec) { vec_params.push_back(create( create(&f32, 0.5))); - ast::Variable var("pos", ast::StorageClass::kPrivate, &vec); + ast::Variable var(Source{}, "pos", ast::StorageClass::kPrivate, &vec); var.set_is_const(true); var.set_constructor( create(&vec, std::move(vec_params))); diff --git a/src/writer/spirv/builder_assign_test.cc b/src/writer/spirv/builder_assign_test.cc index c8ee307e68..5a6d44cf06 100644 --- a/src/writer/spirv/builder_assign_test.cc +++ b/src/writer/spirv/builder_assign_test.cc @@ -44,7 +44,7 @@ using BuilderTest = TestHelper; TEST_F(BuilderTest, Assign_Var) { ast::type::F32 f32; - ast::Variable v("var", ast::StorageClass::kOutput, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32); auto* ident = create("var"); auto* val = create( @@ -78,7 +78,7 @@ TEST_F(BuilderTest, Assign_Var_ZeroConstructor) { ast::type::F32 f32; ast::type::Vector vec(&f32, 3); - ast::Variable v("var", ast::StorageClass::kOutput, &vec); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec); auto* ident = create("var"); ast::ExpressionList vals; @@ -128,7 +128,7 @@ TEST_F(BuilderTest, Assign_Var_Complex_ConstructorWithExtract) { create(&f32, 3.0f)), }); - ast::Variable v("var", ast::StorageClass::kOutput, &vec3); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3); ast::AssignmentStatement assign(create("var"), init); @@ -176,7 +176,7 @@ TEST_F(BuilderTest, Assign_Var_Complex_Constructor) { auto* init = create(&vec3, vals); - ast::Variable v("var", ast::StorageClass::kOutput, &vec3); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3); ast::AssignmentStatement assign(create("var"), init); @@ -223,7 +223,7 @@ TEST_F(BuilderTest, Assign_StructMember) { auto* s = create(members); ast::type::Struct s_type("my_struct", s); - ast::Variable v("ident", ast::StorageClass::kFunction, &s_type); + ast::Variable v(Source{}, "ident", ast::StorageClass::kFunction, &s_type); auto* ident = create( create("ident"), @@ -265,7 +265,7 @@ TEST_F(BuilderTest, Assign_Vector) { ast::type::F32 f32; ast::type::Vector vec3(&f32, 3); - ast::Variable v("var", ast::StorageClass::kOutput, &vec3); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3); auto* ident = create("var"); @@ -312,7 +312,7 @@ TEST_F(BuilderTest, Assign_Vector_MemberByName) { // var.y = 1 - ast::Variable v("var", ast::StorageClass::kOutput, &vec3); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3); auto* ident = create( create("var"), @@ -357,7 +357,7 @@ TEST_F(BuilderTest, Assign_Vector_MemberByIndex) { // var[1] = 1 - ast::Variable v("var", ast::StorageClass::kOutput, &vec3); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &vec3); auto* ident = create( create("var"), diff --git a/src/writer/spirv/builder_binary_expression_test.cc b/src/writer/spirv/builder_binary_expression_test.cc index 89e9af8d5a..8920a66a51 100644 --- a/src/writer/spirv/builder_binary_expression_test.cc +++ b/src/writer/spirv/builder_binary_expression_test.cc @@ -121,7 +121,7 @@ TEST_P(BinaryArithSignedIntegerTest, Scalar_Loads) { ast::type::I32 i32; - ast::Variable var("param", ast::StorageClass::kFunction, &i32); + ast::Variable var(Source{}, "param", ast::StorageClass::kFunction, &i32); auto* lhs = create("param"); auto* rhs = create("param"); @@ -633,7 +633,8 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixScalar) { ast::type::F32 f32; ast::type::Matrix mat3(&f32, 3, 3); - auto* var = create("mat", ast::StorageClass::kFunction, &mat3); + auto* var = create(Source{}, "mat", + ast::StorageClass::kFunction, &mat3); auto* lhs = create("mat"); auto* rhs = create( create(&f32, 1.f)); @@ -665,7 +666,8 @@ TEST_F(BuilderTest, Binary_Multiply_ScalarMatrix) { ast::type::F32 f32; ast::type::Matrix mat3(&f32, 3, 3); - auto* var = create("mat", ast::StorageClass::kFunction, &mat3); + auto* var = create(Source{}, "mat", + ast::StorageClass::kFunction, &mat3); auto* lhs = create( create(&f32, 1.f)); auto* rhs = create("mat"); @@ -698,7 +700,8 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixVector) { ast::type::Vector vec3(&f32, 3); ast::type::Matrix mat3(&f32, 3, 3); - auto* var = create("mat", ast::StorageClass::kFunction, &mat3); + auto* var = create(Source{}, "mat", + ast::StorageClass::kFunction, &mat3); auto* lhs = create("mat"); ast::ExpressionList vals; @@ -739,7 +742,8 @@ TEST_F(BuilderTest, Binary_Multiply_VectorMatrix) { ast::type::Vector vec3(&f32, 3); ast::type::Matrix mat3(&f32, 3, 3); - auto* var = create("mat", ast::StorageClass::kFunction, &mat3); + auto* var = create(Source{}, "mat", + ast::StorageClass::kFunction, &mat3); ast::ExpressionList vals; vals.push_back(create( @@ -781,7 +785,8 @@ TEST_F(BuilderTest, Binary_Multiply_MatrixMatrix) { ast::type::Vector vec3(&f32, 3); ast::type::Matrix mat3(&f32, 3, 3); - auto* var = create("mat", ast::StorageClass::kFunction, &mat3); + auto* var = create(Source{}, "mat", + ast::StorageClass::kFunction, &mat3); auto* lhs = create("mat"); auto* rhs = create("mat"); @@ -856,12 +861,12 @@ OpBranch %7 TEST_F(BuilderTest, Binary_LogicalAnd_WithLoads) { ast::type::Bool bool_type; - auto* a_var = - create("a", ast::StorageClass::kFunction, &bool_type); + auto* a_var = create(Source{}, "a", + ast::StorageClass::kFunction, &bool_type); a_var->set_constructor(create( create(&bool_type, true))); - auto* b_var = - create("b", ast::StorageClass::kFunction, &bool_type); + auto* b_var = create(Source{}, "b", + ast::StorageClass::kFunction, &bool_type); b_var->set_constructor(create( create(&bool_type, false))); @@ -1042,12 +1047,12 @@ OpBranch %7 TEST_F(BuilderTest, Binary_LogicalOr_WithLoads) { ast::type::Bool bool_type; - auto* a_var = - create("a", ast::StorageClass::kFunction, &bool_type); + auto* a_var = create(Source{}, "a", + ast::StorageClass::kFunction, &bool_type); a_var->set_constructor(create( create(&bool_type, true))); - auto* b_var = - create("b", ast::StorageClass::kFunction, &bool_type); + auto* b_var = create(Source{}, "b", + ast::StorageClass::kFunction, &bool_type); b_var->set_constructor(create( create(&bool_type, false))); diff --git a/src/writer/spirv/builder_block_test.cc b/src/writer/spirv/builder_block_test.cc index 192a0d2ca1..8be8d5e95c 100644 --- a/src/writer/spirv/builder_block_test.cc +++ b/src/writer/spirv/builder_block_test.cc @@ -41,16 +41,16 @@ TEST_F(BuilderTest, Block) { // serves to prove the block code is pushing new scopes as needed. ast::BlockStatement outer; - outer.append(create( - create("var", ast::StorageClass::kFunction, &f32))); + outer.append(create(create( + Source{}, "var", ast::StorageClass::kFunction, &f32))); outer.append(create( create("var"), create( create(&f32, 1.0f)))); auto* inner = create(); - inner->append(create( - create("var", ast::StorageClass::kFunction, &f32))); + inner->append(create(create( + Source{}, "var", ast::StorageClass::kFunction, &f32))); inner->append(create( create("var"), create( diff --git a/src/writer/spirv/builder_call_test.cc b/src/writer/spirv/builder_call_test.cc index b0c3b82303..fff29bfc88 100644 --- a/src/writer/spirv/builder_call_test.cc +++ b/src/writer/spirv/builder_call_test.cc @@ -44,9 +44,9 @@ TEST_F(BuilderTest, Expression_Call) { ast::VariableList func_params; func_params.push_back( - create("a", ast::StorageClass::kFunction, &f32)); + create(Source{}, "a", ast::StorageClass::kFunction, &f32)); func_params.push_back( - create("b", ast::StorageClass::kFunction, &f32)); + create(Source{}, "b", ast::StorageClass::kFunction, &f32)); auto* body = create(); body->append(create(create( @@ -108,9 +108,9 @@ TEST_F(BuilderTest, Statement_Call) { ast::VariableList func_params; func_params.push_back( - create("a", ast::StorageClass::kFunction, &f32)); + create(Source{}, "a", ast::StorageClass::kFunction, &f32)); func_params.push_back( - create("b", ast::StorageClass::kFunction, &f32)); + create(Source{}, "b", ast::StorageClass::kFunction, &f32)); auto* body = create(); body->append(create(create( diff --git a/src/writer/spirv/builder_function_decoration_test.cc b/src/writer/spirv/builder_function_decoration_test.cc index 2aa4cc58fe..cb5da8ae50 100644 --- a/src/writer/spirv/builder_function_decoration_test.cc +++ b/src/writer/spirv/builder_function_decoration_test.cc @@ -102,11 +102,12 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUnusedInterfaceIds) { create(ast::PipelineStage::kVertex, Source{}), }); - auto* v_in = create("my_in", ast::StorageClass::kInput, &f32); - auto* v_out = - create("my_out", ast::StorageClass::kOutput, &f32); - auto* v_wg = - create("my_wg", ast::StorageClass::kWorkgroup, &f32); + auto* v_in = + create(Source{}, "my_in", ast::StorageClass::kInput, &f32); + auto* v_out = create(Source{}, "my_out", + ast::StorageClass::kOutput, &f32); + auto* v_wg = create(Source{}, "my_wg", + ast::StorageClass::kWorkgroup, &f32); EXPECT_TRUE(b.GenerateGlobalVariable(v_in)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(v_out)) << b.error(); @@ -161,11 +162,12 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUsedInterfaceIds) { create("my_in"))); func.set_body(body); - auto* v_in = create("my_in", ast::StorageClass::kInput, &f32); - auto* v_out = - create("my_out", ast::StorageClass::kOutput, &f32); - auto* v_wg = - create("my_wg", ast::StorageClass::kWorkgroup, &f32); + auto* v_in = + create(Source{}, "my_in", ast::StorageClass::kInput, &f32); + auto* v_out = create(Source{}, "my_out", + ast::StorageClass::kOutput, &f32); + auto* v_wg = create(Source{}, "my_wg", + ast::StorageClass::kWorkgroup, &f32); td.RegisterVariableForTesting(v_in); td.RegisterVariableForTesting(v_out); diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc index 6121675063..82de2affaf 100644 --- a/src/writer/spirv/builder_function_test.cc +++ b/src/writer/spirv/builder_function_test.cc @@ -87,7 +87,8 @@ TEST_F(BuilderTest, Function_Terminator_ReturnValue) { ast::type::Void void_type; ast::type::F32 f32; - auto* var_a = create("a", ast::StorageClass::kPrivate, &f32); + auto* var_a = + create(Source{}, "a", ast::StorageClass::kPrivate, &f32); td.RegisterVariableForTesting(var_a); auto* body = create(); @@ -142,10 +143,12 @@ TEST_F(BuilderTest, Function_WithParams) { ast::type::I32 i32; ast::VariableList params; - auto* var_a = create("a", ast::StorageClass::kFunction, &f32); + auto* var_a = + create(Source{}, "a", ast::StorageClass::kFunction, &f32); var_a->set_is_const(true); params.push_back(var_a); - auto* var_b = create("b", ast::StorageClass::kFunction, &i32); + auto* var_b = + create(Source{}, "b", ast::StorageClass::kFunction, &i32); var_b->set_is_const(true); params.push_back(var_b); @@ -256,8 +259,8 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); - auto* data_var = create( - create("data", ast::StorageClass::kStorageBuffer, &ac)); + auto* data_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -271,7 +274,8 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { { ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = create(Source{}, "v", + ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("data"), create("d"))); @@ -292,7 +296,8 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { { ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = create(Source{}, "v", + ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("data"), create("d"))); diff --git a/src/writer/spirv/builder_function_variable_test.cc b/src/writer/spirv/builder_function_variable_test.cc index 163f66e744..2ff1a2378c 100644 --- a/src/writer/spirv/builder_function_variable_test.cc +++ b/src/writer/spirv/builder_function_variable_test.cc @@ -47,7 +47,7 @@ using BuilderTest = TestHelper; TEST_F(BuilderTest, FunctionVar_NoStorageClass) { ast::type::F32 f32; - ast::Variable v("var", ast::StorageClass::kNone, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kNone, &f32); b.push_function(Function{}); EXPECT_TRUE(b.GenerateFunctionVariable(&v)) << b.error(); @@ -80,7 +80,7 @@ TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) { EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); - ast::Variable v("var", ast::StorageClass::kOutput, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32); v.set_constructor(init); td.RegisterVariableForTesting(&v); @@ -126,7 +126,7 @@ TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructor) { EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); - ast::Variable v("var", ast::StorageClass::kFunction, &vec); + ast::Variable v(Source{}, "var", ast::StorageClass::kFunction, &vec); v.set_constructor(init); td.RegisterVariableForTesting(&v); @@ -164,11 +164,11 @@ TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructorLoadedFromVar) { ASSERT_TRUE(td.DetermineResultType(init)) << td.error(); - ast::Variable v("v", ast::StorageClass::kFunction, &f32); + ast::Variable v(Source{}, "v", ast::StorageClass::kFunction, &f32); v.set_constructor(init); td.RegisterVariableForTesting(&v); - ast::Variable v2("v2", ast::StorageClass::kFunction, &f32); + ast::Variable v2(Source{}, "v2", ast::StorageClass::kFunction, &f32); v2.set_constructor(create("v")); td.RegisterVariableForTesting(&v2); @@ -209,11 +209,11 @@ TEST_F(BuilderTest, FunctionVar_ConstWithVarInitializer) { EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); - ast::Variable v("v", ast::StorageClass::kFunction, &f32); + ast::Variable v(Source{}, "v", ast::StorageClass::kFunction, &f32); v.set_constructor(init); td.RegisterVariableForTesting(&v); - ast::Variable v2("v2", ast::StorageClass::kFunction, &f32); + ast::Variable v2(Source{}, "v2", ast::StorageClass::kFunction, &f32); v2.set_is_const(true); v2.set_constructor(create("v")); td.RegisterVariableForTesting(&v2); @@ -257,7 +257,7 @@ TEST_F(BuilderTest, FunctionVar_Const) { EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); - ast::Variable v("var", ast::StorageClass::kOutput, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32); v.set_constructor(init); v.set_is_const(true); diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc index 5a3bd8cf15..71408bb363 100644 --- a/src/writer/spirv/builder_global_variable_test.cc +++ b/src/writer/spirv/builder_global_variable_test.cc @@ -52,7 +52,7 @@ using BuilderTest = TestHelper; TEST_F(BuilderTest, GlobalVar_NoStorageClass) { ast::type::F32 f32; - ast::Variable v("var", ast::StorageClass::kNone, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kNone, &f32); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" @@ -66,7 +66,7 @@ TEST_F(BuilderTest, GlobalVar_NoStorageClass) { TEST_F(BuilderTest, GlobalVar_WithStorageClass) { ast::type::F32 f32; - ast::Variable v("var", ast::StorageClass::kOutput, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" @@ -80,7 +80,7 @@ TEST_F(BuilderTest, GlobalVar_WithStorageClass) { TEST_F(BuilderTest, GlobalVar_WithStorageClass_Input) { ast::type::F32 f32; - ast::Variable v("var", ast::StorageClass::kInput, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kInput, &f32); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "var" @@ -107,7 +107,7 @@ TEST_F(BuilderTest, GlobalVar_WithConstructor) { EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); - ast::Variable v("var", ast::StorageClass::kOutput, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32); v.set_constructor(init); td.RegisterVariableForTesting(&v); @@ -142,7 +142,7 @@ TEST_F(BuilderTest, GlobalVar_Const) { EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); - ast::Variable v("var", ast::StorageClass::kOutput, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32); v.set_constructor(init); v.set_is_const(true); td.RegisterVariableForTesting(&v); @@ -175,7 +175,7 @@ TEST_F(BuilderTest, GlobalVar_Complex_Constructor) { EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); - ast::Variable v("var", ast::StorageClass::kOutput, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32); v.set_constructor(init); v.set_is_const(true); td.RegisterVariableForTesting(&v); @@ -214,7 +214,7 @@ TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) { EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); - ast::Variable v("var", ast::StorageClass::kOutput, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32); v.set_constructor(init); v.set_is_const(true); td.RegisterVariableForTesting(&v); @@ -240,7 +240,8 @@ TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) { TEST_F(BuilderTest, GlobalVar_WithLocation) { ast::type::F32 f32; - auto* v = create("var", ast::StorageClass::kOutput, &f32); + auto* v = + create(Source{}, "var", ast::StorageClass::kOutput, &f32); ast::VariableDecorationList decos; decos.push_back(create(5, Source{})); @@ -261,7 +262,8 @@ TEST_F(BuilderTest, GlobalVar_WithLocation) { TEST_F(BuilderTest, GlobalVar_WithBindingAndSet) { ast::type::F32 f32; - auto* v = create("var", ast::StorageClass::kOutput, &f32); + auto* v = + create(Source{}, "var", ast::StorageClass::kOutput, &f32); ast::VariableDecorationList decos; decos.push_back(create(2, Source{})); decos.push_back(create(3, Source{})); @@ -284,7 +286,8 @@ OpDecorate %1 DescriptorSet 3 TEST_F(BuilderTest, GlobalVar_WithBuiltin) { ast::type::F32 f32; - auto* v = create("var", ast::StorageClass::kOutput, &f32); + auto* v = + create(Source{}, "var", ast::StorageClass::kOutput, &f32); ast::VariableDecorationList decos; decos.push_back( create(ast::Builtin::kPosition, Source{})); @@ -310,8 +313,8 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) { ast::VariableDecorationList decos; decos.push_back(create(1200, Source{})); - ast::DecoratedVariable v( - create("var", ast::StorageClass::kNone, &bool_type)); + ast::DecoratedVariable v(create( + Source{}, "var", ast::StorageClass::kNone, &bool_type)); v.set_decorations(decos); v.set_constructor(create( create(&bool_type, true))); @@ -334,8 +337,8 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool_NoConstructor) { ast::VariableDecorationList decos; decos.push_back(create(1200, Source{})); - ast::DecoratedVariable v( - create("var", ast::StorageClass::kNone, &bool_type)); + ast::DecoratedVariable v(create( + Source{}, "var", ast::StorageClass::kNone, &bool_type)); v.set_decorations(decos); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); @@ -357,7 +360,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) { decos.push_back(create(0, Source{})); ast::DecoratedVariable v( - create("var", ast::StorageClass::kNone, &f32)); + create(Source{}, "var", ast::StorageClass::kNone, &f32)); v.set_decorations(decos); v.set_constructor(create( create(&f32, 2.0))); @@ -381,7 +384,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_F32_NoConstructor) { decos.push_back(create(0, Source{})); ast::DecoratedVariable v( - create("var", ast::StorageClass::kNone, &f32)); + create(Source{}, "var", ast::StorageClass::kNone, &f32)); v.set_decorations(decos); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); @@ -403,7 +406,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_I32_NoConstructor) { decos.push_back(create(0, Source{})); ast::DecoratedVariable v( - create("var", ast::StorageClass::kNone, &i32)); + create(Source{}, "var", ast::StorageClass::kNone, &i32)); v.set_decorations(decos); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); @@ -425,7 +428,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_U32_NoConstructor) { decos.push_back(create(0, Source{})); ast::DecoratedVariable v( - create("var", ast::StorageClass::kNone, &u32)); + create(Source{}, "var", ast::StorageClass::kNone, &u32)); v.set_decorations(decos); EXPECT_TRUE(b.GenerateGlobalVariable(&v)) << b.error(); @@ -490,7 +493,7 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { ast::type::Struct A("A", create(members)); ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A}; - ast::Variable var("b", ast::StorageClass::kStorageBuffer, &ac); + ast::Variable var(Source{}, "b", ast::StorageClass::kStorageBuffer, &ac); EXPECT_TRUE(b.GenerateGlobalVariable(&var)) << b.error(); @@ -526,7 +529,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) { ast::type::Alias B("B", &A); ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &B}; - ast::Variable var("b", ast::StorageClass::kStorageBuffer, &ac); + ast::Variable var(Source{}, "b", ast::StorageClass::kStorageBuffer, &ac); EXPECT_TRUE(b.GenerateGlobalVariable(&var)) << b.error(); @@ -560,7 +563,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) { ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A}; ast::type::Alias B("B", &ac); - ast::Variable var("b", ast::StorageClass::kStorageBuffer, &B); + ast::Variable var(Source{}, "b", ast::StorageClass::kStorageBuffer, &B); EXPECT_TRUE(b.GenerateGlobalVariable(&var)) << b.error(); @@ -594,8 +597,8 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) { ast::type::AccessControl read{ast::AccessControl::kReadOnly, &A}; ast::type::AccessControl rw{ast::AccessControl::kReadWrite, &A}; - ast::Variable var_b("b", ast::StorageClass::kStorageBuffer, &read); - ast::Variable var_c("c", ast::StorageClass::kStorageBuffer, &rw); + ast::Variable var_b(Source{}, "b", ast::StorageClass::kStorageBuffer, &read); + ast::Variable var_c(Source{}, "c", ast::StorageClass::kStorageBuffer, &rw); EXPECT_TRUE(b.GenerateGlobalVariable(&var_b)) << b.error(); EXPECT_TRUE(b.GenerateGlobalVariable(&var_c)) << b.error(); @@ -626,7 +629,8 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageReadOnly) { ast::type::ImageFormat::kR32Uint); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&type)) << td.error(); - ast::Variable var_a("a", ast::StorageClass::kUniformConstant, &type); + ast::Variable var_a(Source{}, "a", ast::StorageClass::kUniformConstant, + &type); EXPECT_TRUE(b.GenerateGlobalVariable(&var_a)) << b.error(); @@ -646,7 +650,8 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) { ast::type::ImageFormat::kR32Uint); ASSERT_TRUE(td.DetermineStorageTextureSubtype(&type)) << td.error(); - ast::Variable var_a("a", ast::StorageClass::kUniformConstant, &type); + ast::Variable var_a(Source{}, "a", ast::StorageClass::kUniformConstant, + &type); EXPECT_TRUE(b.GenerateGlobalVariable(&var_a)) << b.error(); diff --git a/src/writer/spirv/builder_ident_expression_test.cc b/src/writer/spirv/builder_ident_expression_test.cc index 661082b28f..2a48e53826 100644 --- a/src/writer/spirv/builder_ident_expression_test.cc +++ b/src/writer/spirv/builder_ident_expression_test.cc @@ -53,7 +53,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalConst) { EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); - ast::Variable v("var", ast::StorageClass::kOutput, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32); v.set_constructor(init); v.set_is_const(true); @@ -77,7 +77,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalConst) { TEST_F(BuilderTest, IdentifierExpression_GlobalVar) { ast::type::F32 f32; - ast::Variable v("var", ast::StorageClass::kOutput, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32); td.RegisterVariableForTesting(&v); @@ -112,7 +112,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionConst) { EXPECT_TRUE(td.DetermineResultType(init)) << td.error(); - ast::Variable v("var", ast::StorageClass::kOutput, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kOutput, &f32); v.set_constructor(init); v.set_is_const(true); td.RegisterVariableForTesting(&v); @@ -134,7 +134,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionConst) { TEST_F(BuilderTest, IdentifierExpression_FunctionVar) { ast::type::F32 f32; - ast::Variable v("var", ast::StorageClass::kNone, &f32); + ast::Variable v(Source{}, "var", ast::StorageClass::kNone, &f32); td.RegisterVariableForTesting(&v); @@ -160,7 +160,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionVar) { TEST_F(BuilderTest, IdentifierExpression_Load) { ast::type::I32 i32; - ast::Variable var("var", ast::StorageClass::kPrivate, &i32); + ast::Variable var(Source{}, "var", ast::StorageClass::kPrivate, &i32); td.RegisterVariableForTesting(&var); @@ -190,7 +190,7 @@ TEST_F(BuilderTest, IdentifierExpression_Load) { TEST_F(BuilderTest, IdentifierExpression_NoLoadConst) { ast::type::I32 i32; - ast::Variable var("var", ast::StorageClass::kNone, &i32); + ast::Variable var(Source{}, "var", ast::StorageClass::kNone, &i32); var.set_constructor(create( create(&i32, 2))); var.set_is_const(true); diff --git a/src/writer/spirv/builder_if_test.cc b/src/writer/spirv/builder_if_test.cc index 768604abd4..4ad6d014ac 100644 --- a/src/writer/spirv/builder_if_test.cc +++ b/src/writer/spirv/builder_if_test.cc @@ -75,7 +75,8 @@ TEST_F(BuilderTest, If_WithStatements) { // if (true) { // v = 2; // } - auto* var = create("v", ast::StorageClass::kPrivate, &i32); + auto* var = + create(Source{}, "v", ast::StorageClass::kPrivate, &i32); auto* body = create(); body->append( @@ -122,7 +123,8 @@ TEST_F(BuilderTest, If_WithElse) { // } else { // v = 3; // } - auto* var = create("v", ast::StorageClass::kPrivate, &i32); + auto* var = + create(Source{}, "v", ast::StorageClass::kPrivate, &i32); auto* body = create(); body->append( @@ -181,7 +183,8 @@ TEST_F(BuilderTest, If_WithElseIf) { // } elseif (true) { // v = 3; // } - auto* var = create("v", ast::StorageClass::kPrivate, &i32); + auto* var = + create(Source{}, "v", ast::StorageClass::kPrivate, &i32); auto* body = create(); body->append( @@ -252,7 +255,8 @@ TEST_F(BuilderTest, If_WithMultiple) { // } else { // v = 5; // } - auto* var = create("v", ast::StorageClass::kPrivate, &i32); + auto* var = + create(Source{}, "v", ast::StorageClass::kPrivate, &i32); auto* body = create(); body->append( @@ -605,8 +609,8 @@ TEST_F(BuilderTest, If_WithLoad_Bug327) { // } ast::type::Bool bool_type; - auto* var = - create("a", ast::StorageClass::kFunction, &bool_type); + auto* var = create(Source{}, "a", ast::StorageClass::kFunction, + &bool_type); td.RegisterVariableForTesting(var); ast::IfStatement expr(Source{}, create("a"), diff --git a/src/writer/spirv/builder_loop_test.cc b/src/writer/spirv/builder_loop_test.cc index 66ced5003e..dbaa6bce60 100644 --- a/src/writer/spirv/builder_loop_test.cc +++ b/src/writer/spirv/builder_loop_test.cc @@ -65,7 +65,8 @@ TEST_F(BuilderTest, Loop_WithoutContinuing) { // loop { // v = 2; // } - auto* var = create("v", ast::StorageClass::kPrivate, &i32); + auto* var = + create(Source{}, "v", ast::StorageClass::kPrivate, &i32); auto* body = create(); body->append( @@ -111,7 +112,8 @@ TEST_F(BuilderTest, Loop_WithContinuing) { // } // } - auto* var = create("v", ast::StorageClass::kPrivate, &i32); + auto* var = + create(Source{}, "v", ast::StorageClass::kPrivate, &i32); auto* body = create(); body->append( diff --git a/src/writer/spirv/builder_return_test.cc b/src/writer/spirv/builder_return_test.cc index b7912bb1a5..db18f852da 100644 --- a/src/writer/spirv/builder_return_test.cc +++ b/src/writer/spirv/builder_return_test.cc @@ -81,7 +81,7 @@ TEST_F(BuilderTest, Return_WithValue) { TEST_F(BuilderTest, Return_WithValue_GeneratesLoad) { ast::type::F32 f32; - ast::Variable var("param", ast::StorageClass::kFunction, &f32); + ast::Variable var(Source{}, "param", ast::StorageClass::kFunction, &f32); ast::ReturnStatement ret(create("param")); diff --git a/src/writer/spirv/builder_switch_test.cc b/src/writer/spirv/builder_switch_test.cc index e95cd6cbc3..54975117b2 100644 --- a/src/writer/spirv/builder_switch_test.cc +++ b/src/writer/spirv/builder_switch_test.cc @@ -76,8 +76,10 @@ TEST_F(BuilderTest, Switch_WithCase) { // v = 2; // } - auto* v = create("v", ast::StorageClass::kPrivate, &i32); - auto* a = create("a", ast::StorageClass::kPrivate, &i32); + auto* v = + create(Source{}, "v", ast::StorageClass::kPrivate, &i32); + auto* a = + create(Source{}, "a", ast::StorageClass::kPrivate, &i32); auto* case_1_body = create(); case_1_body->append( @@ -155,8 +157,10 @@ TEST_F(BuilderTest, Switch_WithDefault) { // v = 1; // } - auto* v = create("v", ast::StorageClass::kPrivate, &i32); - auto* a = create("a", ast::StorageClass::kPrivate, &i32); + auto* v = + create(Source{}, "v", ast::StorageClass::kPrivate, &i32); + auto* a = + create(Source{}, "a", ast::StorageClass::kPrivate, &i32); auto* default_body = create(); default_body->append( @@ -219,8 +223,10 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) { // v = 3; // } - auto* v = create("v", ast::StorageClass::kPrivate, &i32); - auto* a = create("a", ast::StorageClass::kPrivate, &i32); + auto* v = + create(Source{}, "v", ast::StorageClass::kPrivate, &i32); + auto* a = + create(Source{}, "a", ast::StorageClass::kPrivate, &i32); auto* case_1_body = create(); case_1_body->append( @@ -313,8 +319,10 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) { // v = 3; // } - auto* v = create("v", ast::StorageClass::kPrivate, &i32); - auto* a = create("a", ast::StorageClass::kPrivate, &i32); + auto* v = + create(Source{}, "v", ast::StorageClass::kPrivate, &i32); + auto* a = + create(Source{}, "a", ast::StorageClass::kPrivate, &i32); auto* case_1_body = create(); case_1_body->append( @@ -403,8 +411,10 @@ TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) { // fallthrough; // } - auto* v = create("v", ast::StorageClass::kPrivate, &i32); - auto* a = create("a", ast::StorageClass::kPrivate, &i32); + auto* v = + create(Source{}, "v", ast::StorageClass::kPrivate, &i32); + auto* a = + create(Source{}, "a", ast::StorageClass::kPrivate, &i32); auto* case_1_body = create(); case_1_body->append( @@ -449,8 +459,10 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) { // v = 1; // } - auto* v = create("v", ast::StorageClass::kPrivate, &i32); - auto* a = create("a", ast::StorageClass::kPrivate, &i32); + auto* v = + create(Source{}, "v", ast::StorageClass::kPrivate, &i32); + auto* a = + create(Source{}, "a", ast::StorageClass::kPrivate, &i32); auto* if_body = create(); if_body->append(create()); diff --git a/src/writer/spirv/builder_unary_op_expression_test.cc b/src/writer/spirv/builder_unary_op_expression_test.cc index 7fabad829f..ef8da21acd 100644 --- a/src/writer/spirv/builder_unary_op_expression_test.cc +++ b/src/writer/spirv/builder_unary_op_expression_test.cc @@ -98,7 +98,7 @@ TEST_F(BuilderTest, UnaryOp_LoadRequired) { ast::type::F32 f32; ast::type::Vector vec(&f32, 3); - ast::Variable var("param", ast::StorageClass::kFunction, &vec); + ast::Variable var(Source{}, "param", ast::StorageClass::kFunction, &vec); ast::UnaryOpExpression expr(ast::UnaryOp::kNegation, create("param")); diff --git a/src/writer/wgsl/generator_impl_function_test.cc b/src/writer/wgsl/generator_impl_function_test.cc index bb443c9d04..f93836ded5 100644 --- a/src/writer/wgsl/generator_impl_function_test.cc +++ b/src/writer/wgsl/generator_impl_function_test.cc @@ -68,8 +68,10 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithParams) { ast::type::F32 f32; ast::type::I32 i32; ast::VariableList params; - params.push_back(create("a", ast::StorageClass::kNone, &f32)); - params.push_back(create("b", ast::StorageClass::kNone, &i32)); + params.push_back( + create(Source{}, "a", ast::StorageClass::kNone, &f32)); + params.push_back( + create(Source{}, "b", ast::StorageClass::kNone, &i32)); ast::type::Void void_type; ast::Function func(Source{}, "my_func", params, &void_type, body, @@ -189,8 +191,8 @@ TEST_F(WgslGeneratorImplTest, ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); - auto* data_var = create( - create("data", ast::StorageClass::kStorageBuffer, &ac)); + auto* data_var = create(create( + Source{}, "data", ast::StorageClass::kStorageBuffer, &ac)); ast::VariableDecorationList decos; decos.push_back(create(0, Source{})); @@ -204,7 +206,8 @@ TEST_F(WgslGeneratorImplTest, { ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = create(Source{}, "v", + ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("data"), create("d"))); @@ -225,7 +228,8 @@ TEST_F(WgslGeneratorImplTest, { ast::VariableList params; - auto* var = create("v", ast::StorageClass::kFunction, &f32); + auto* var = create(Source{}, "v", + ast::StorageClass::kFunction, &f32); var->set_constructor(create( create("data"), create("d"))); diff --git a/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc b/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc index 375e2381e7..cd25fb69e4 100644 --- a/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/wgsl/generator_impl_variable_decl_statement_test.cc @@ -32,7 +32,8 @@ using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement) { ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kNone, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kNone, &f32); ast::VariableDeclStatement stmt(var); @@ -47,7 +48,8 @@ TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Function) { // storage class. Rely on defaulting. // https://github.com/gpuweb/gpuweb/issues/654 ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kFunction, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kFunction, &f32); ast::VariableDeclStatement stmt(var); @@ -59,7 +61,8 @@ TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Function) { TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Private) { ast::type::F32 f32; - auto* var = create("a", ast::StorageClass::kPrivate, &f32); + auto* var = + create(Source{}, "a", ast::StorageClass::kPrivate, &f32); ast::VariableDeclStatement stmt(var); diff --git a/src/writer/wgsl/generator_impl_variable_test.cc b/src/writer/wgsl/generator_impl_variable_test.cc index d342ba4add..05b3dde527 100644 --- a/src/writer/wgsl/generator_impl_variable_test.cc +++ b/src/writer/wgsl/generator_impl_variable_test.cc @@ -35,7 +35,7 @@ using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitVariable) { ast::type::F32 f32; - ast::Variable v("a", ast::StorageClass::kNone, &f32); + ast::Variable v(Source{}, "a", ast::StorageClass::kNone, &f32); ASSERT_TRUE(gen.EmitVariable(&v)) << gen.error(); EXPECT_EQ(gen.result(), R"(var a : f32; @@ -44,7 +44,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable) { TEST_F(WgslGeneratorImplTest, EmitVariable_StorageClass) { ast::type::F32 f32; - ast::Variable v("a", ast::StorageClass::kInput, &f32); + ast::Variable v(Source{}, "a", ast::StorageClass::kInput, &f32); ASSERT_TRUE(gen.EmitVariable(&v)) << gen.error(); EXPECT_EQ(gen.result(), R"(var a : f32; @@ -94,7 +94,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) { auto* ident = create("initializer"); ast::type::F32 f32; - ast::Variable v("a", ast::StorageClass::kNone, &f32); + ast::Variable v(Source{}, "a", ast::StorageClass::kNone, &f32); v.set_constructor(ident); ASSERT_TRUE(gen.EmitVariable(&v)) << gen.error(); @@ -106,7 +106,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Const) { auto* ident = create("initializer"); ast::type::F32 f32; - ast::Variable v("a", ast::StorageClass::kNone, &f32); + ast::Variable v(Source{}, "a", ast::StorageClass::kNone, &f32); v.set_constructor(ident); v.set_is_const(true);