From bcf37549c86b7545ec4f823171e64755cf1688cc Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Sat, 12 Dec 2020 12:52:44 +0000 Subject: [PATCH] ast: Remove Struct constructors that don't take a Source And swap the `decorations` and `members` parameters, as decorations come last for other constructors. Parsers need fixing up. Bug: tint:396 Bug: tint:390 Change-Id: Ie9b814c1de24b6c987f0fbb9e6f92da7c352caa2 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35163 Commit-Queue: Ben Clayton Reviewed-by: dan sinclair --- src/ast/struct.cc | 23 +- src/ast/struct.h | 17 +- src/ast/struct_test.cc | 14 +- src/ast/type/access_control_type_test.cc | 4 +- src/ast/type/alias_type_test.cc | 4 +- src/ast/type/struct_type_test.cc | 33 ++- src/inspector/inspector_test.cc | 4 +- src/reader/spirv/parser_impl.cc | 4 +- src/reader/wgsl/parser_impl.cc | 4 +- .../parser_impl_variable_ident_decl_test.cc | 10 +- src/transform/first_index_offset.cc | 2 +- src/transform/vertex_pulling.cc | 2 +- src/type_determiner_test.cc | 12 +- src/validator/validator_type_test.cc | 10 +- .../hlsl/generator_impl_alias_type_test.cc | 19 +- .../hlsl/generator_impl_function_test.cc | 14 +- .../generator_impl_member_accessor_test.cc | 261 +++++++++++------- src/writer/hlsl/generator_impl_type_test.cc | 14 +- .../msl/generator_impl_alias_type_test.cc | 6 +- .../msl/generator_impl_function_test.cc | 14 +- src/writer/msl/generator_impl_test.cc | 9 +- src/writer/msl/generator_impl_type_test.cc | 42 +-- ...rator_impl_variable_decl_statement_test.cc | 3 +- .../spirv/builder_accessor_expression_test.cc | 52 +++- src/writer/spirv/builder_assign_test.cc | 2 +- .../builder_constructor_expression_test.cc | 42 ++- src/writer/spirv/builder_function_test.cc | 2 +- .../spirv/builder_global_variable_test.cc | 12 +- src/writer/spirv/builder_intrinsic_test.cc | 6 +- src/writer/spirv/builder_type_test.cc | 15 +- .../wgsl/generator_impl_alias_type_test.cc | 6 +- .../wgsl/generator_impl_function_test.cc | 2 +- src/writer/wgsl/generator_impl_type_test.cc | 12 +- 33 files changed, 390 insertions(+), 286 deletions(-) diff --git a/src/ast/struct.cc b/src/ast/struct.cc index a214209302..452a93c611 100644 --- a/src/ast/struct.cc +++ b/src/ast/struct.cc @@ -23,23 +23,12 @@ TINT_INSTANTIATE_CLASS_ID(tint::ast::Struct); namespace tint { namespace ast { -Struct::Struct(StructMemberList members) - : Base(), members_(std::move(members)) {} - -Struct::Struct(StructDecorationList decorations, StructMemberList members) - : Base(), - decorations_(std::move(decorations)), - members_(std::move(members)) {} - -Struct::Struct(const Source& source, StructMemberList members) - : Base(source), members_(std::move(members)) {} - Struct::Struct(const Source& source, - StructDecorationList decorations, - StructMemberList members) + StructMemberList members, + StructDecorationList decorations) : Base(source), - decorations_(std::move(decorations)), - members_(std::move(members)) {} + members_(std::move(members)), + decorations_(std::move(decorations)) {} Struct::Struct(Struct&&) = default; @@ -64,8 +53,8 @@ bool Struct::IsBlockDecorated() const { } Struct* Struct::Clone(CloneContext* ctx) const { - return ctx->mod->create( - ctx->Clone(source()), ctx->Clone(decorations_), ctx->Clone(members_)); + return ctx->mod->create(ctx->Clone(source()), ctx->Clone(members_), + ctx->Clone(decorations_)); } bool Struct::IsValid() const { diff --git a/src/ast/struct.h b/src/ast/struct.h index f9f29ab28e..36e78ba5fb 100644 --- a/src/ast/struct.h +++ b/src/ast/struct.h @@ -29,24 +29,13 @@ namespace ast { /// A struct statement. class Struct : public Castable { public: - /// Create a new struct statement - /// @param members The struct members - explicit Struct(StructMemberList members); - /// Create a new struct statement - /// @param decorations The struct decorations - /// @param members The struct members - Struct(StructDecorationList decorations, StructMemberList members); /// Create a new struct statement /// @param source The input source for the import statement /// @param members The struct members - Struct(const Source& source, StructMemberList members); - /// Create a new struct statement - /// @param source The input source for the import statement /// @param decorations The struct decorations - /// @param members The struct members Struct(const Source& source, - StructDecorationList decorations, - StructMemberList members); + StructMemberList members, + StructDecorationList decorations); /// Move constructor Struct(Struct&&); @@ -85,8 +74,8 @@ class Struct : public Castable { private: Struct(const Struct&) = delete; - StructDecorationList decorations_; StructMemberList members_; + StructDecorationList decorations_; }; } // namespace ast diff --git a/src/ast/struct_test.cc b/src/ast/struct_test.cc index b8f7234266..5f0f1f0659 100644 --- a/src/ast/struct_test.cc +++ b/src/ast/struct_test.cc @@ -35,7 +35,7 @@ TEST_F(StructTest, Creation) { members.push_back( create(Source{}, "a", &i32, StructMemberDecorationList())); - Struct s{members}; + Struct s{Source{}, members, ast::StructDecorationList{}}; EXPECT_EQ(s.members().size(), 1u); EXPECT_TRUE(s.decorations().empty()); EXPECT_EQ(s.source().range.begin.line, 0u); @@ -54,7 +54,7 @@ TEST_F(StructTest, Creation_WithDecorations) { StructDecorationList decos; decos.push_back(create(Source{})); - Struct s{decos, members}; + Struct s{Source{}, members, decos}; EXPECT_EQ(s.members().size(), 1u); ASSERT_EQ(s.decorations().size(), 1u); EXPECT_TRUE(s.decorations()[0]->Is()); @@ -76,7 +76,7 @@ TEST_F(StructTest, CreationWithSourceAndDecorations) { Struct s{ Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 8}}}, - decos, members}; + members, decos}; EXPECT_EQ(s.members().size(), 1u); ASSERT_EQ(s.decorations().size(), 1u); EXPECT_TRUE(s.decorations()[0]->Is()); @@ -87,7 +87,7 @@ TEST_F(StructTest, CreationWithSourceAndDecorations) { } TEST_F(StructTest, IsValid) { - Struct s({}); + Struct s(Source{}, StructMemberList{}, StructDecorationList{}); EXPECT_TRUE(s.IsValid()); } @@ -99,7 +99,7 @@ TEST_F(StructTest, IsValid_Null_StructMember) { create(Source{}, "a", &i32, StructMemberDecorationList())); members.push_back(nullptr); - Struct s{members}; + Struct s{Source{}, members, ast::StructDecorationList{}}; EXPECT_FALSE(s.IsValid()); } @@ -110,7 +110,7 @@ TEST_F(StructTest, IsValid_Invalid_StructMember) { members.push_back( create(Source{}, "", &i32, StructMemberDecorationList())); - Struct s{members}; + Struct s{Source{}, members, ast::StructDecorationList{}}; EXPECT_FALSE(s.IsValid()); } @@ -124,7 +124,7 @@ TEST_F(StructTest, ToStr) { StructDecorationList decos; decos.push_back(create(Source{})); - Struct s{decos, members}; + Struct s{Source{}, members, decos}; std::ostringstream out; s.to_str(out, 2); diff --git a/src/ast/type/access_control_type_test.cc b/src/ast/type/access_control_type_test.cc index a7bc2aab01..04ba748515 100644 --- a/src/ast/type/access_control_type_test.cc +++ b/src/ast/type/access_control_type_test.cc @@ -134,7 +134,7 @@ TEST_F(AccessControlTest, MinBufferBindingSizeStruct) { StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); AccessControl at{ast::AccessControl::kReadOnly, &struct_type}; EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); @@ -179,7 +179,7 @@ TEST_F(AccessControlTest, BaseAlignmentStruct) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); AccessControl at{ast::AccessControl::kReadOnly, &struct_type}; EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer)); diff --git a/src/ast/type/alias_type_test.cc b/src/ast/type/alias_type_test.cc index c54fea79ae..638716bf48 100644 --- a/src/ast/type/alias_type_test.cc +++ b/src/ast/type/alias_type_test.cc @@ -207,7 +207,7 @@ TEST_F(AliasTest, MinBufferBindingSizeStruct) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); Alias alias{mod.RegisterSymbol("alias"), "alias", &struct_type}; EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); @@ -256,7 +256,7 @@ TEST_F(AliasTest, BaseAlignmentStruct) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); Alias alias{mod.RegisterSymbol("alias"), "alias", &struct_type}; EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer)); diff --git a/src/ast/type/struct_type_test.cc b/src/ast/type/struct_type_test.cc index 37e1e975b7..b90d0ac6b7 100644 --- a/src/ast/type/struct_type_test.cc +++ b/src/ast/type/struct_type_test.cc @@ -41,7 +41,8 @@ using StructTest = TestHelper; TEST_F(StructTest, Creation) { StructMemberList members; - auto* impl = create(members); + auto* impl = + create(Source{}, members, ast::StructDecorationList{}); auto* ptr = impl; Struct s{"S", impl}; EXPECT_EQ(s.impl(), ptr); @@ -49,7 +50,8 @@ TEST_F(StructTest, Creation) { TEST_F(StructTest, Is) { StructMemberList members; - auto* impl = create(members); + auto* impl = + create(Source{}, members, ast::StructDecorationList{}); Struct s{"S", impl}; Type* ty = &s; EXPECT_FALSE(ty->Is()); @@ -69,7 +71,8 @@ TEST_F(StructTest, Is) { TEST_F(StructTest, TypeName) { StructMemberList members; - auto* impl = create(members); + auto* impl = + create(Source{}, members, ast::StructDecorationList{}); Struct s{"my_struct", impl}; EXPECT_EQ(s.type_name(), "__struct_my_struct"); } @@ -90,7 +93,7 @@ TEST_F(StructTest, MinBufferBindingSize) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); @@ -120,7 +123,7 @@ TEST_F(StructTest, MinBufferBindingSizeArray) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); EXPECT_EQ(32u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); @@ -151,7 +154,7 @@ TEST_F(StructTest, MinBufferBindingSizeRuntimeArray) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); EXPECT_EQ(12u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); @@ -169,7 +172,7 @@ TEST_F(StructTest, MinBufferBindingSizeVec2) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); @@ -188,7 +191,7 @@ TEST_F(StructTest, MinBufferBindingSizeVec3) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); @@ -208,7 +211,7 @@ TEST_F(StructTest, MinBufferBindingSizeVec4) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); @@ -232,7 +235,7 @@ TEST_F(StructTest, BaseAlignment) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); @@ -261,7 +264,7 @@ TEST_F(StructTest, BaseAlignmentArray) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); @@ -290,7 +293,7 @@ TEST_F(StructTest, BaseAlignmentRuntimeArray) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); } @@ -307,7 +310,7 @@ TEST_F(StructTest, BaseAlignmentVec2) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(8u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); @@ -325,7 +328,7 @@ TEST_F(StructTest, BaseAlignmentVec3) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); @@ -343,7 +346,7 @@ TEST_F(StructTest, BaseAlignmentVec4) { } StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); Struct struct_type("struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index d638381947..99250af269 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -308,7 +308,7 @@ class InspectorHelper { decos.push_back(create(Source{})); } - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); return std::make_unique(name, str); } @@ -1454,7 +1454,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingBlockDeco) { ast::StructDecorationList decos; - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); auto foo_type = std::make_unique("foo_type", str); AddUniformBuffer("foo_ub", foo_type.get(), 0, 0); diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc index 723f8d34ae..9cabd3e753 100644 --- a/src/reader/spirv/parser_impl.cc +++ b/src/reader/spirv/parser_impl.cc @@ -947,8 +947,8 @@ ast::type::Type* ParserImpl::ConvertType( } // Now make the struct. - auto* ast_struct = create(std::move(ast_struct_decorations), - std::move(ast_members)); + auto* ast_struct = create(Source{}, std::move(ast_members), + std::move(ast_struct_decorations)); namer_.SuggestSanitizedName(type_id, "S"); diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index 65fb63a063..d6270cc71b 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -1192,8 +1192,8 @@ Maybe> ParserImpl::struct_decl( return Failure::kErrored; return std::make_unique( - name.value, create(source, std::move(struct_decos.value), - std::move(body.value))); + name.value, create(source, std::move(body.value), + std::move(struct_decos.value))); } // struct_body_decl diff --git a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc index 9fcabfc6c6..e971c60a7a 100644 --- a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc +++ b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc @@ -93,7 +93,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) { ast::StructDecorationList decos; decos.push_back(&block_deco); - ast::Struct str(decos, members); + ast::Struct str(Source{}, members, decos); ast::type::Struct s("S", &str); auto p = parser("my_var : [[access(read)]] S"); @@ -119,7 +119,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) { ast::StructDecorationList decos; decos.push_back(&block_deco); - ast::Struct str(decos, members); + ast::Struct str(Source{}, members, decos); ast::type::Struct s("S", &str); auto p = parser("my_var : [[access(read_write)]] S"); @@ -145,7 +145,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) { ast::StructDecorationList decos; decos.push_back(&block_deco); - ast::Struct str(decos, members); + ast::Struct str(Source{}, members, decos); ast::type::Struct s("S", &str); auto p = parser("my_var : [[access(read), access(read_write)]] S"); @@ -168,7 +168,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) { ast::StructDecorationList decos; decos.push_back(&block_deco); - ast::Struct str(decos, members); + ast::Struct str(Source{}, members, decos); ast::type::Struct s("S", &str); auto p = parser("my_var : [[access(read)]][[access(read_write)]] S"); @@ -207,7 +207,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) { ast::StructDecorationList decos; decos.push_back(&block_deco); - ast::Struct str(decos, members); + ast::Struct str(Source{}, members, decos); ast::type::Struct s("S", &str); auto p = parser("my_var : [[stride(1)]] S"); diff --git a/src/transform/first_index_offset.cc b/src/transform/first_index_offset.cc index 2dbaf93fa7..45273b085a 100644 --- a/src/transform/first_index_offset.cc +++ b/src/transform/first_index_offset.cc @@ -225,7 +225,7 @@ ast::Variable* FirstIndexOffset::AddUniformBuffer(ast::Module* mod) { auto* struct_type = mod->create( kStructName, - mod->create(std::move(decos), std::move(members))); + mod->create(Source{}, std::move(members), std::move(decos))); auto* idx_var = mod->create( Source{}, // source diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc index 0c9d1a0c4c..cf4ec6f9f1 100644 --- a/src/transform/vertex_pulling.cc +++ b/src/transform/vertex_pulling.cc @@ -265,7 +265,7 @@ void VertexPulling::State::AddVertexStorageBuffers() { auto* struct_type = mod->create( kStructName, - mod->create(std::move(decos), std::move(members))); + mod->create(Source{}, std::move(members), std::move(decos))); for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) { // The decorated variable with struct type diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index ed65b87d19..5f317dc9a6 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -1215,7 +1215,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct) { members.push_back( create(Source{}, "second_member", &f32, decos)); - auto* strct = create(members); + auto* strct = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct st("S", strct); @@ -1258,7 +1259,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) { members.push_back( create(Source{}, "second_member", &f32, decos)); - auto* strct = create(members); + auto* strct = + create(Source{}, members, ast::StructDecorationList{}); auto st = std::make_unique("alias", strct); ast::type::Alias alias(mod->RegisterSymbol("alias"), "alias", st.get()); @@ -1387,7 +1389,8 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) { ast::StructMemberList b_members; b_members.push_back(create(Source{}, "foo", &vec4, decos)); - auto* strctB = create(b_members); + auto* strctB = + create(Source{}, b_members, ast::StructDecorationList{}); ast::type::Struct stB("B", strctB); ast::type::Vector vecB(&stB, 3); @@ -1395,7 +1398,8 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) { ast::StructMemberList a_members; a_members.push_back(create(Source{}, "mem", &vecB, decos)); - auto* strctA = create(a_members); + auto* strctA = + create(Source{}, a_members, ast::StructDecorationList{}); ast::type::Struct stA("A", strctA); diff --git a/src/validator/validator_type_test.cc b/src/validator/validator_type_test.cc index 96eb8e83f0..aec9695604 100644 --- a/src/validator/validator_type_test.cc +++ b/src/validator/validator_type_test.cc @@ -56,7 +56,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLast_Pass) { } ast::StructDecorationList decos; decos.push_back(create(Source{})); - auto* st = create(decos, members); + auto* st = create(Source{}, members, decos); ast::type::Struct struct_type("Foo", st); mod()->AddConstructedType(&struct_type); @@ -82,7 +82,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) { Source{Source::Location{12, 34}}, "rt", &arr, deco)); } ast::StructDecorationList decos; - auto* st = create(decos, members); + auto* st = create(Source{}, members, decos); ast::type::Struct struct_type("Foo", st); mod()->AddConstructedType(&struct_type); @@ -113,7 +113,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsNotLast_Fail) { } ast::StructDecorationList decos; decos.push_back(create(Source{})); - auto* st = create(decos, members); + auto* st = create(Source{}, members, decos); ast::type::Struct struct_type("Foo", st); mod()->AddConstructedType(&struct_type); @@ -148,7 +148,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsNotLast_Fail) { ast::StructDecorationList decos; decos.push_back(create(Source{})); - auto* st = create(decos, members); + auto* st = create(Source{}, members, decos); ast::type::Struct struct_type("s", st); mod()->AddConstructedType(&struct_type); EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types())); @@ -181,7 +181,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) { } ast::StructDecorationList decos; decos.push_back(create(Source{})); - auto* st = create(decos, members); + auto* st = create(Source{}, members, decos); ast::type::Struct struct_type("s", st); mod()->AddConstructedType(&struct_type); EXPECT_TRUE(v()->ValidateConstructedTypes(mod()->constructed_types())); diff --git a/src/writer/hlsl/generator_impl_alias_type_test.cc b/src/writer/hlsl/generator_impl_alias_type_test.cc index 57b9611315..4b01f06116 100644 --- a/src/writer/hlsl/generator_impl_alias_type_test.cc +++ b/src/writer/hlsl/generator_impl_alias_type_test.cc @@ -50,14 +50,17 @@ TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_Struct) { ast::type::I32 i32; ast::type::F32 f32; - auto* str = create(ast::StructMemberList{ - create(Source{}, "a", &f32, - ast::StructMemberDecorationList{}), - create( - Source{}, "b", &i32, - ast::StructMemberDecorationList{ - create(4, Source{})}), - }); + auto* str = create( + Source{}, + ast::StructMemberList{ + create(Source{}, "a", &f32, + ast::StructMemberDecorationList{}), + create( + Source{}, "b", &i32, + ast::StructMemberDecorationList{ + create(4, Source{})}), + }, + ast::StructDecorationList{}); ast::type::Struct s("A", str); ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s); diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc index 29541f04bc..68069fbdcf 100644 --- a/src/writer/hlsl/generator_impl_function_test.cc +++ b/src/writer/hlsl/generator_impl_function_test.cc @@ -355,7 +355,8 @@ TEST_F(HlslGeneratorImplTest_Function, members.push_back(create( Source{}, "coord", &vec4, ast::StructMemberDecorationList{})); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Uniforms", str); @@ -439,7 +440,8 @@ TEST_F(HlslGeneratorImplTest_Function, b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); @@ -514,7 +516,8 @@ TEST_F(HlslGeneratorImplTest_Function, b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s); @@ -589,7 +592,8 @@ TEST_F(HlslGeneratorImplTest_Function, b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); @@ -1365,7 +1369,7 @@ TEST_F(HlslGeneratorImplTest_Function, ast::StructDecorationList s_decos; s_decos.push_back(create(Source{})); - auto* str = create(s_decos, members); + auto* str = create(Source{}, members, s_decos); ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc index 47ac922159..3f3cfcb7a2 100644 --- a/src/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc @@ -53,7 +53,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) { deco.push_back(create(0, Source{})); members.push_back(create(Source{}, "mem", &f32, deco)); - auto* strct = create(members); + auto* strct = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Str", strct); @@ -104,7 +105,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -157,7 +159,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -204,16 +207,19 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::I32 i32; ast::type::Matrix mat(&f32, 3, 2); - auto* str = create(ast::StructMemberList{ - create( - Source{}, "z", &i32, - ast::StructMemberDecorationList{ - create(0, Source{})}), - create( - Source{}, "a", &mat, - ast::StructMemberDecorationList{ - create(4, Source{})}), - }); + auto* str = create( + Source{}, + ast::StructMemberList{ + create( + Source{}, "z", &i32, + ast::StructMemberDecorationList{ + create(0, Source{})}), + create( + Source{}, "a", &mat, + ast::StructMemberDecorationList{ + create(4, Source{})}), + }, + ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -289,7 +295,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "a", &mat, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -353,7 +360,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "a", &mat, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -413,7 +421,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "a", &mat, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -465,7 +474,8 @@ TEST_F( deco.push_back(create(0, Source{})); members.push_back(create(Source{}, "a", &mat, deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -521,7 +531,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, b_deco.push_back(create(16, Source{})); members.push_back(create(Source{}, "a", &mat, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -581,7 +592,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, a_deco.push_back(create(0, Source{})); members.push_back(create(Source{}, "a", &ary, a_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -637,7 +649,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, a_deco.push_back(create(0, Source{})); members.push_back(create(Source{}, "a", &ary, a_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -703,7 +716,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -760,7 +774,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, a_deco.push_back(create(0, Source{})); members.push_back(create(Source{}, "a", &ary, a_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -822,7 +837,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -882,7 +898,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, b_deco.push_back(create(16, Source{})); members.push_back(create(Source{}, "b", &fvec3, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -938,7 +955,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, b_deco.push_back(create(16, Source{})); members.push_back(create(Source{}, "b", &fvec3, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); @@ -1002,16 +1020,19 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Vector ivec3(&i32, 3); ast::type::Vector fvec3(&f32, 3); - auto* data_str = create(ast::StructMemberList{ - create( - Source{}, "a", &ivec3, - ast::StructMemberDecorationList{ - create(0, Source{})}), - create( - Source{}, "b", &fvec3, - ast::StructMemberDecorationList{ - create(16, Source{})}), - }); + auto* data_str = create( + Source{}, + ast::StructMemberList{ + create( + Source{}, "a", &ivec3, + ast::StructMemberDecorationList{ + create(0, Source{})}), + create( + Source{}, "b", &fvec3, + ast::StructMemberDecorationList{ + create(16, Source{})}), + }, + ast::StructDecorationList{}); ast::type::Struct data("Data", data_str); @@ -1020,12 +1041,15 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(32, Source{}), }); - auto* pre_str = create(ast::StructMemberList{ - create( - Source{}, "c", &ary, - ast::StructMemberDecorationList{ - create(0, Source{})}), - }); + auto* pre_str = create( + Source{}, + ast::StructMemberList{ + create( + Source{}, "c", &ary, + ast::StructMemberDecorationList{ + create(0, Source{})}), + }, + ast::StructDecorationList{}); ast::type::Struct pre_struct("Pre", pre_str); @@ -1087,16 +1111,19 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::StructMemberList members; ast::StructMemberDecorationList deco; - auto* data_str = create(ast::StructMemberList{ - create( - Source{}, "a", &ivec3, - ast::StructMemberDecorationList{ - create(0, Source{})}), - create( - Source{}, "b", &fvec3, - ast::StructMemberDecorationList{ - create(16, Source{})}), - }); + auto* data_str = create( + Source{}, + ast::StructMemberList{ + create( + Source{}, "a", &ivec3, + ast::StructMemberDecorationList{ + create(0, Source{})}), + create( + Source{}, "b", &fvec3, + ast::StructMemberDecorationList{ + create(16, Source{})}), + }, + ast::StructDecorationList{}); ast::type::Struct data("Data", data_str); @@ -1104,11 +1131,13 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, &data, 4, ast::ArrayDecorationList{create(32, Source{})}); - auto* pre_str = - create(ast::StructMemberList{create( + auto* pre_str = create( + Source{}, + ast::StructMemberList{create( Source{}, "c", &ary, ast::StructMemberDecorationList{ - create(0, Source{})})}); + create(0, Source{})})}, + ast::StructDecorationList{}); ast::type::Struct pre_struct("Pre", pre_str); @@ -1172,16 +1201,19 @@ TEST_F( ast::type::Vector ivec3(&i32, 3); ast::type::Vector fvec3(&f32, 3); - auto* data_str = create(ast::StructMemberList{ - create( - Source{}, "a", &ivec3, - ast::StructMemberDecorationList{ - create(0, Source{})}), - create( - Source{}, "b", &fvec3, - ast::StructMemberDecorationList{ - create(16, Source{})}), - }); + auto* data_str = create( + Source{}, + ast::StructMemberList{ + create( + Source{}, "a", &ivec3, + ast::StructMemberDecorationList{ + create(0, Source{})}), + create( + Source{}, "b", &fvec3, + ast::StructMemberDecorationList{ + create(16, Source{})}), + }, + ast::StructDecorationList{}); ast::type::Struct data("Data", data_str); @@ -1190,11 +1222,13 @@ TEST_F( create(32, Source{}), }); - auto* pre_str = - create(ast::StructMemberList{create( + auto* pre_str = create( + Source{}, + ast::StructMemberList{create( Source{}, "c", &ary, ast::StructMemberDecorationList{ - create(0, Source{})})}); + create(0, Source{})})}, + ast::StructDecorationList{}); ast::type::Struct pre_struct("Pre", pre_str); @@ -1257,16 +1291,19 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Vector ivec3(&i32, 3); ast::type::Vector fvec3(&f32, 3); - auto* data_str = create(ast::StructMemberList{ - create( - Source{}, "a", &ivec3, - ast::StructMemberDecorationList{ - create(0, Source{})}), - create( - Source{}, "b", &fvec3, - ast::StructMemberDecorationList{ - create(16, Source{})}), - }); + auto* data_str = create( + Source{}, + ast::StructMemberList{ + create( + Source{}, "a", &ivec3, + ast::StructMemberDecorationList{ + create(0, Source{})}), + create( + Source{}, "b", &fvec3, + ast::StructMemberDecorationList{ + create(16, Source{})}), + }, + ast::StructDecorationList{}); ast::type::Struct data("Data", data_str); @@ -1275,11 +1312,13 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(32, Source{}), }); - auto* pre_str = - create(ast::StructMemberList{create( + auto* pre_str = create( + Source{}, + ast::StructMemberList{create( Source{}, "c", &ary, ast::StructMemberDecorationList{ - create(0, Source{})})}); + create(0, Source{})})}, + ast::StructDecorationList{}); ast::type::Struct pre_struct("Pre", pre_str); @@ -1342,16 +1381,19 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Vector ivec3(&i32, 3); ast::type::Vector fvec3(&f32, 3); - auto* data_str = create(ast::StructMemberList{ - create( - Source{}, "a", &ivec3, - ast::StructMemberDecorationList{ - create(0, Source{})}), - create( - Source{}, "b", &fvec3, - ast::StructMemberDecorationList{ - create(16, Source{})}), - }); + auto* data_str = create( + Source{}, + ast::StructMemberList{ + create( + Source{}, "a", &ivec3, + ast::StructMemberDecorationList{ + create(0, Source{})}), + create( + Source{}, "b", &fvec3, + ast::StructMemberDecorationList{ + create(16, Source{})}), + }, + ast::StructDecorationList{}); ast::type::Struct data("Data", data_str); @@ -1360,11 +1402,13 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(32, Source{}), }); - auto* pre_str = - create(ast::StructMemberList{create( + auto* pre_str = create( + Source{}, + ast::StructMemberList{create( Source{}, "c", &ary, ast::StructMemberDecorationList{ - create(0, Source{})})}); + create(0, Source{})})}, + ast::StructDecorationList{}); ast::type::Struct pre_struct("Pre", pre_str); @@ -1437,16 +1481,19 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, ast::type::Vector ivec3(&i32, 3); ast::type::Vector fvec3(&f32, 3); - auto* data_str = create(ast::StructMemberList{ - create( - Source{}, "a", &ivec3, - ast::StructMemberDecorationList{ - create(0, Source{})}), - create( - Source{}, "b", &fvec3, - ast::StructMemberDecorationList{ - create(16, Source{})}), - }); + auto* data_str = create( + Source{}, + ast::StructMemberList{ + create( + Source{}, "a", &ivec3, + ast::StructMemberDecorationList{ + create(0, Source{})}), + create( + Source{}, "b", &fvec3, + ast::StructMemberDecorationList{ + create(16, Source{})}), + }, + ast::StructDecorationList{}); ast::type::Struct data("Data", data_str); @@ -1455,11 +1502,13 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(32, Source{}), }); - auto* pre_str = - create(ast::StructMemberList{create( + auto* pre_str = create( + Source{}, + ast::StructMemberList{create( Source{}, "c", &ary, ast::StructMemberDecorationList{ - create(0, Source{})})}); + create(0, Source{})})}, + ast::StructDecorationList{}); ast::type::Struct pre_struct("Pre", pre_str); diff --git a/src/writer/hlsl/generator_impl_type_test.cc b/src/writer/hlsl/generator_impl_type_test.cc index d65611e624..9e3765d609 100644 --- a/src/writer/hlsl/generator_impl_type_test.cc +++ b/src/writer/hlsl/generator_impl_type_test.cc @@ -181,7 +181,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) { b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("S", str); @@ -205,7 +206,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) { b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("S", str); @@ -229,7 +231,8 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_InjectPadding) { decos.push_back(create(128, Source{})); members.push_back(create(Source{}, "c", &f32, decos)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("S", str); @@ -255,7 +258,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) { ast::StructMemberDecorationList b_deco; members.push_back(create(Source{}, "float", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("S", str); @@ -283,7 +287,7 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_WithDecoration) { ast::StructDecorationList decos; decos.push_back(create(Source{})); - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); ast::type::Struct s("S", str); diff --git a/src/writer/msl/generator_impl_alias_type_test.cc b/src/writer/msl/generator_impl_alias_type_test.cc index 99e54270dd..581260c9db 100644 --- a/src/writer/msl/generator_impl_alias_type_test.cc +++ b/src/writer/msl/generator_impl_alias_type_test.cc @@ -61,7 +61,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_Struct) { b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &i32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("a", str); @@ -85,7 +86,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_AliasStructIdent) { b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &i32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("b", str); ast::type::Alias alias(mod.RegisterSymbol("a"), "a", &s); diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc index 2bca59245d..581247e02d 100644 --- a/src/writer/msl/generator_impl_function_test.cc +++ b/src/writer/msl/generator_impl_function_test.cc @@ -371,7 +371,8 @@ TEST_F(MslGeneratorImplTest, b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); @@ -455,7 +456,8 @@ TEST_F(MslGeneratorImplTest, b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s); @@ -968,7 +970,8 @@ TEST_F(MslGeneratorImplTest, b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); @@ -1082,7 +1085,8 @@ TEST_F(MslGeneratorImplTest, b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s); @@ -1341,7 +1345,7 @@ TEST_F(MslGeneratorImplTest, ast::StructDecorationList s_decos; s_decos.push_back(create(Source{})); - auto* str = create(s_decos, members); + auto* str = create(Source{}, members, s_decos); ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); diff --git a/src/writer/msl/generator_impl_test.cc b/src/writer/msl/generator_impl_test.cc index 068f847430..1f289203c8 100644 --- a/src/writer/msl/generator_impl_test.cc +++ b/src/writer/msl/generator_impl_test.cc @@ -171,7 +171,8 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct) { decos.push_back(create(128, Source{})); members.push_back(create(Source{}, "c", &f32, decos)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("S", str); @@ -195,7 +196,8 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) { decos.push_back(create(32, Source{})); members.push_back(create(Source{}, "c", &f32, decos)); - auto* inner_str = create(members); + auto* inner_str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct inner_s("Inner", inner_str); @@ -208,7 +210,8 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) { decos.push_back(create(64, Source{})); members.push_back(create(Source{}, "f", &f32, decos)); - auto* outer_str = create(members); + auto* outer_str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct outer_s("Outer", outer_str); diff --git a/src/writer/msl/generator_impl_type_test.cc b/src/writer/msl/generator_impl_type_test.cc index fb3352193d..c779de64b8 100644 --- a/src/writer/msl/generator_impl_type_test.cc +++ b/src/writer/msl/generator_impl_type_test.cc @@ -182,7 +182,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct) { b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("S", str); @@ -202,7 +203,8 @@ TEST_F(MslGeneratorImplTest, EmitType_StructDecl) { b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("S", str); @@ -218,20 +220,23 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_InjectPadding) { ast::type::I32 i32; ast::type::F32 f32; - auto* str = create(ast::StructMemberList{ - create( - Source{}, "a", &i32, - ast::StructMemberDecorationList{ - create(4, Source{})}), - create( - Source{}, "b", &f32, - ast::StructMemberDecorationList{ - create(32, Source{})}), - create( - Source{}, "c", &f32, - ast::StructMemberDecorationList{ - create(128, Source{})}), - }); + auto* str = create( + Source{}, + ast::StructMemberList{ + create( + Source{}, "a", &i32, + ast::StructMemberDecorationList{ + create(4, Source{})}), + create( + Source{}, "b", &f32, + ast::StructMemberDecorationList{ + create(32, Source{})}), + create( + Source{}, "c", &f32, + ast::StructMemberDecorationList{ + create(128, Source{})}), + }, + ast::StructDecorationList{}); ast::type::Struct s("S", str); @@ -258,7 +263,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_NameCollision) { ast::StructMemberDecorationList b_deco; members.push_back(create(Source{}, "float", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("S", str); @@ -285,7 +291,7 @@ TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Struct_WithDecoration) { ast::StructDecorationList decos; decos.push_back(create(Source{})); - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); ast::type::Struct s("S", str); 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 b2d03ddb9f..791ad6ad09 100644 --- a/src/writer/msl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/msl/generator_impl_variable_decl_statement_test.cc @@ -110,7 +110,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Struct) { b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("S", str); diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc index 802cd79108..43ebfc8e06 100644 --- a/src/writer/spirv/builder_accessor_expression_test.cc +++ b/src/writer/spirv/builder_accessor_expression_test.cc @@ -304,7 +304,7 @@ TEST_F(BuilderTest, MemberAccessor) { members.push_back(create(Source{}, "a", &f32, decos)); members.push_back(create(Source{}, "b", &f32, decos)); - auto* s = create(members); + auto* s = create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s_type("my_struct", s); ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type, @@ -360,13 +360,17 @@ TEST_F(BuilderTest, MemberAccessor_Nested) { inner_members.push_back( create(Source{}, "b", &f32, decos)); - ast::type::Struct inner_struct("Inner", create(inner_members)); + ast::type::Struct inner_struct( + "Inner", create(Source{}, inner_members, + ast::StructDecorationList{})); ast::StructMemberList outer_members; outer_members.push_back( create(Source{}, "inner", &inner_struct, decos)); - ast::type::Struct s_type("my_struct", create(outer_members)); + ast::type::Struct s_type("my_struct", + create(Source{}, outer_members, + ast::StructDecorationList{})); ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type, false, nullptr, ast::VariableDecorationList{}); @@ -427,7 +431,9 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) { inner_members.push_back( create(Source{}, "b", &f32, decos)); - ast::type::Struct inner_struct("Inner", create(inner_members)); + ast::type::Struct inner_struct( + "Inner", create(Source{}, inner_members, + ast::StructDecorationList{})); ast::type::Alias alias(mod->RegisterSymbol("Inner"), "Inner", &inner_struct); @@ -435,7 +441,9 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) { outer_members.push_back( create(Source{}, "inner", &alias, decos)); - ast::type::Struct s_type("Outer", create(outer_members)); + ast::type::Struct s_type("Outer", + create(Source{}, outer_members, + ast::StructDecorationList{})); ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type, false, nullptr, ast::VariableDecorationList{}); @@ -496,13 +504,17 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) { inner_members.push_back( create(Source{}, "b", &f32, decos)); - ast::type::Struct inner_struct("Inner", create(inner_members)); + ast::type::Struct inner_struct( + "Inner", create(Source{}, inner_members, + ast::StructDecorationList{})); ast::StructMemberList outer_members; outer_members.push_back( create(Source{}, "inner", &inner_struct, decos)); - ast::type::Struct s_type("my_struct", create(outer_members)); + ast::type::Struct s_type("my_struct", + create(Source{}, outer_members, + ast::StructDecorationList{})); ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type, false, nullptr, ast::VariableDecorationList{}); @@ -570,13 +582,17 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) { inner_members.push_back( create(Source{}, "b", &f32, decos)); - ast::type::Struct inner_struct("Inner", create(inner_members)); + ast::type::Struct inner_struct( + "Inner", create(Source{}, inner_members, + ast::StructDecorationList{})); ast::StructMemberList outer_members; outer_members.push_back( create(Source{}, "inner", &inner_struct, decos)); - ast::type::Struct s_type("my_struct", create(outer_members)); + ast::type::Struct s_type("my_struct", + create(Source{}, outer_members, + ast::StructDecorationList{})); ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type, false, nullptr, ast::VariableDecorationList{}); @@ -861,18 +877,24 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) { ast::StructMemberDecorationList decos; - auto* s = create(ast::StructMemberList{ - create(Source{}, "baz", &vec3, decos)}); + auto* s = create(Source{}, + ast::StructMemberList{create( + Source{}, "baz", &vec3, decos)}, + ast::StructDecorationList{}); ast::type::Struct c_type("C", s); - s = create(ast::StructMemberList{ - create(Source{}, "bar", &c_type, decos)}); + s = create(Source{}, + ast::StructMemberList{create( + Source{}, "bar", &c_type, decos)}, + ast::StructDecorationList{}); ast::type::Struct b_type("B", s); ast::type::Array b_ary_type(&b_type, 3, ast::ArrayDecorationList{}); - s = create(ast::StructMemberList{ - create(Source{}, "foo", &b_ary_type, decos)}); + s = create(Source{}, + ast::StructMemberList{create( + Source{}, "foo", &b_ary_type, decos)}, + ast::StructDecorationList{}); ast::type::Struct a_type("A", s); ast::type::Array a_ary_type(&a_type, 2, ast::ArrayDecorationList{}); diff --git a/src/writer/spirv/builder_assign_test.cc b/src/writer/spirv/builder_assign_test.cc index c13f530c6f..79bb488ad8 100644 --- a/src/writer/spirv/builder_assign_test.cc +++ b/src/writer/spirv/builder_assign_test.cc @@ -234,7 +234,7 @@ TEST_F(BuilderTest, Assign_StructMember) { members.push_back(create(Source{}, "a", &f32, decos)); members.push_back(create(Source{}, "b", &f32, decos)); - auto* s = create(members); + auto* s = create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s_type("my_struct", s); ast::Variable v(Source{}, "ident", ast::StorageClass::kFunction, &s_type, diff --git a/src/writer/spirv/builder_constructor_expression_test.cc b/src/writer/spirv/builder_constructor_expression_test.cc index 778d84279b..ac33690253 100644 --- a/src/writer/spirv/builder_constructor_expression_test.cc +++ b/src/writer/spirv/builder_constructor_expression_test.cc @@ -942,10 +942,13 @@ TEST_F(SpvBuilderConstructorTest, Type_Array_2_Vec3) { TEST_F(SpvBuilderConstructorTest, Type_Struct) { ast::StructMemberDecorationList decos; - auto* s = create(ast::StructMemberList{ - create(Source{}, "a", ty.f32, decos), - create(Source{}, "b", ty.vec3(), decos), - }); + auto* s = create( + Source{}, + ast::StructMemberList{ + create(Source{}, "a", ty.f32, decos), + create(Source{}, "b", ty.vec3(), decos), + }, + ast::StructDecorationList{}); ast::type::Struct s_type("my_struct", s); auto* t = Construct(&s_type, 2.0f, vec3(2.0f, 2.0f, 2.0f)); @@ -1079,9 +1082,12 @@ TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Array) { TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Struct) { ast::StructMemberDecorationList decos; - auto* s = create(ast::StructMemberList{ - create(Source{}, "a", ty.f32, decos), - }); + auto* s = create( + Source{}, + ast::StructMemberList{ + create(Source{}, "a", ty.f32, decos), + }, + ast::StructDecorationList{}); ast::type::Struct s_type("my_struct", s); auto* t = Construct(&s_type); @@ -1491,10 +1497,13 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_BitCastScalars) { TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct) { ast::StructMemberDecorationList decos; - auto* s = create(ast::StructMemberList{ - create(Source{}, "a", ty.f32, decos), - create(Source{}, "b", ty.vec3(), decos), - }); + auto* s = create( + Source{}, + ast::StructMemberList{ + create(Source{}, "a", ty.f32, decos), + create(Source{}, "b", ty.vec3(), decos), + }, + ast::StructDecorationList{}); ast::type::Struct s_type("my_struct", s); auto* t = Construct(&s_type, 2.f, vec3(2.f, 2.f, 2.f)); @@ -1508,10 +1517,13 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct) { TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct_WithIdentSubExpression) { ast::StructMemberDecorationList decos; - auto* s = create(ast::StructMemberList{ - create(Source{}, "a", ty.f32, decos), - create(Source{}, "b", ty.vec3(), decos), - }); + auto* s = create( + Source{}, + ast::StructMemberList{ + create(Source{}, "a", ty.f32, decos), + create(Source{}, "b", ty.vec3(), decos), + }, + ast::StructDecorationList{}); ast::type::Struct s_type("my_struct", s); diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc index dd6024ccae..7953a43713 100644 --- a/src/writer/spirv/builder_function_test.cc +++ b/src/writer/spirv/builder_function_test.cc @@ -269,7 +269,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { ast::StructDecorationList s_decos; s_decos.push_back(create(Source{})); - auto* str = create(s_decos, members); + auto* str = create(Source{}, members, s_decos); ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc index 1ca89f9a8a..da47bb0df2 100644 --- a/src/writer/spirv/builder_global_variable_test.cc +++ b/src/writer/spirv/builder_global_variable_test.cc @@ -533,7 +533,8 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { members.push_back(create(Source{}, "a", &i32, decos)); members.push_back(create(Source{}, "b", &i32, decos)); - ast::type::Struct A("A", create(members)); + ast::type::Struct A( + "A", create(Source{}, members, ast::StructDecorationList{})); ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A}; ast::Variable var(Source{}, "b", ast::StorageClass::kStorageBuffer, &ac, @@ -569,7 +570,8 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) { ast::StructMemberList members; members.push_back(create(Source{}, "a", &i32, decos)); - ast::type::Struct A("A", create(members)); + ast::type::Struct A( + "A", create(Source{}, members, ast::StructDecorationList{})); ast::type::Alias B(mod->RegisterSymbol("B"), "B", &A); ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &B}; @@ -604,7 +606,8 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) { ast::StructMemberList members; members.push_back(create(Source{}, "a", &i32, decos)); - ast::type::Struct A("A", create(members)); + ast::type::Struct A( + "A", create(Source{}, members, ast::StructDecorationList{})); ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A}; ast::type::Alias B(mod->RegisterSymbol("B"), "B", &ac); @@ -639,7 +642,8 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) { ast::StructMemberList members; members.push_back(create(Source{}, "a", &i32, decos)); - ast::type::Struct A("A", create(members)); + ast::type::Struct A( + "A", create(Source{}, members, ast::StructDecorationList{})); ast::type::AccessControl read{ast::AccessControl::kReadOnly, &A}; ast::type::AccessControl rw{ast::AccessControl::kReadWrite, &A}; diff --git a/src/writer/spirv/builder_intrinsic_test.cc b/src/writer/spirv/builder_intrinsic_test.cc index e353ffc86b..9c7ec94948 100644 --- a/src/writer/spirv/builder_intrinsic_test.cc +++ b/src/writer/spirv/builder_intrinsic_test.cc @@ -1311,7 +1311,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) { members.push_back( create(Source{}, "a", ty.array(), decos)); - auto* s = create(members); + auto* s = create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s_type("my_struct", s); auto* var = Var("b", ast::StorageClass::kPrivate, &s_type); @@ -1353,7 +1353,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) { members.push_back( create(Source{}, "a", ty.array(), decos)); - auto* s = create(members); + auto* s = create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s_type("my_struct", s); auto* var = Var("b", ast::StorageClass::kPrivate, &s_type); @@ -1397,7 +1397,7 @@ TEST_F(IntrinsicBuilderTest, DISABLED_Call_ArrayLength_Ptr) { members.push_back( create(Source{}, "a", ty.array(), decos)); - auto* s = create(members); + auto* s = create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s_type("my_struct", s); auto* var = Var("b", ast::StorageClass::kPrivate, &s_type); diff --git a/src/writer/spirv/builder_type_test.cc b/src/writer/spirv/builder_type_test.cc index 77457b69ab..638dc462bd 100644 --- a/src/writer/spirv/builder_type_test.cc +++ b/src/writer/spirv/builder_type_test.cc @@ -278,7 +278,8 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) { } TEST_F(BuilderTest_Type, GenerateStruct_Empty) { - auto* s = create(ast::StructMemberList{}); + auto* s = create(Source{}, ast::StructMemberList{}, + ast::StructDecorationList{}); ast::type::Struct s_type("S", s); auto id = b.GenerateTypeIfNeeded(&s_type); @@ -299,7 +300,7 @@ TEST_F(BuilderTest_Type, GenerateStruct) { ast::StructMemberList members; members.push_back(create(Source{}, "a", &f32, decos)); - auto* s = create(members); + auto* s = create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s_type("my_struct", s); auto id = b.GenerateTypeIfNeeded(&s_type); @@ -324,7 +325,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_Decorated) { ast::StructDecorationList struct_decos; struct_decos.push_back(create(Source{})); - auto* s = create(struct_decos, members); + auto* s = create(Source{}, members, struct_decos); ast::type::Struct s_type("my_struct", s); auto id = b.GenerateTypeIfNeeded(&s_type); @@ -353,7 +354,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers) { members.push_back(create(Source{}, "a", &f32, a_decos)); members.push_back(create(Source{}, "b", &f32, b_decos)); - auto* s = create(members); + auto* s = create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s_type("S", s); auto id = b.GenerateTypeIfNeeded(&s_type); @@ -390,7 +391,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_NonLayout_Matrix) { members.push_back( create(Source{}, "c", &glsl_mat4x4, empty_c)); - auto* s = create(members); + auto* s = create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s_type("S", s); auto id = b.GenerateTypeIfNeeded(&s_type); @@ -436,7 +437,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutMatrix) { members.push_back( create(Source{}, "c", &glsl_mat4x4, c_decos)); - auto* s = create(members); + auto* s = create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s_type("S", s); auto id = b.GenerateTypeIfNeeded(&s_type); @@ -503,7 +504,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutArraysOfMatrix) { members.push_back( create(Source{}, "c", &glsl_mat4x4, c_decos)); - auto* s = create(members); + auto* s = create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s_type("S", s); auto id = b.GenerateTypeIfNeeded(&s_type); diff --git a/src/writer/wgsl/generator_impl_alias_type_test.cc b/src/writer/wgsl/generator_impl_alias_type_test.cc index 4602ac9993..6d7fdab6c9 100644 --- a/src/writer/wgsl/generator_impl_alias_type_test.cc +++ b/src/writer/wgsl/generator_impl_alias_type_test.cc @@ -51,7 +51,8 @@ TEST_F(WgslGeneratorImplTest, EmitConstructedType_Struct) { b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &i32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("A", str); ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s); @@ -79,7 +80,8 @@ TEST_F(WgslGeneratorImplTest, EmitAlias_ToStruct) { b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &i32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("A", str); ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s); diff --git a/src/writer/wgsl/generator_impl_function_test.cc b/src/writer/wgsl/generator_impl_function_test.cc index 65d5a8f71b..05ef50760f 100644 --- a/src/writer/wgsl/generator_impl_function_test.cc +++ b/src/writer/wgsl/generator_impl_function_test.cc @@ -198,7 +198,7 @@ TEST_F(WgslGeneratorImplTest, ast::StructDecorationList s_decos; s_decos.push_back(create(Source{})); - auto* str = create(s_decos, members); + auto* str = create(Source{}, members, s_decos); ast::type::Struct s("Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); diff --git a/src/writer/wgsl/generator_impl_type_test.cc b/src/writer/wgsl/generator_impl_type_test.cc index aa70ad8874..2377569164 100644 --- a/src/writer/wgsl/generator_impl_type_test.cc +++ b/src/writer/wgsl/generator_impl_type_test.cc @@ -74,7 +74,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_Read) { ast::StructDecorationList decos; decos.push_back(&block_deco); - ast::Struct str(decos, members); + ast::Struct str(Source{}, members, decos); ast::type::Struct s("S", &str); ast::type::AccessControl a(ast::AccessControl::kReadOnly, &s); @@ -94,7 +94,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_ReadWrite) { ast::StructDecorationList decos; decos.push_back(&block_deco); - ast::Struct str(decos, members); + ast::Struct str(Source{}, members, decos); ast::type::Struct s("S", &str); ast::type::AccessControl a(ast::AccessControl::kReadWrite, &s); @@ -183,7 +183,8 @@ TEST_F(WgslGeneratorImplTest, EmitType_Struct) { b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("S", str); @@ -203,7 +204,8 @@ TEST_F(WgslGeneratorImplTest, EmitType_StructDecl) { b_deco.push_back(create(4, Source{})); members.push_back(create(Source{}, "b", &f32, b_deco)); - auto* str = create(members); + auto* str = + create(Source{}, members, ast::StructDecorationList{}); ast::type::Struct s("S", str); @@ -231,7 +233,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Struct_WithDecoration) { ast::StructDecorationList decos; decos.push_back(create(Source{})); - auto* str = create(decos, members); + auto* str = create(Source{}, members, decos); ast::type::Struct s("S", str);