From 24bbbbb25f7dfdbe4709a43faf07c627cd9ee1bf Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 14 Dec 2020 16:01:37 +0000 Subject: [PATCH] Add Symbol to struct type. This CL adds a Symbol to the struct type along side the name. The name will be removed in a future CL when the symbol is used everywhere. Change-Id: I6c355908651ba0a155a1e0c9ed1192313a405568 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35620 Commit-Queue: dan sinclair Commit-Queue: Ben Clayton Auto-Submit: dan sinclair Reviewed-by: Ben Clayton --- src/ast/module_test.cc | 4 +- src/ast/type/access_control_type_test.cc | 4 +- src/ast/type/alias_type_test.cc | 4 +- src/ast/type/struct_type.cc | 8 +-- src/ast/type/struct_type.h | 7 ++- src/ast/type/struct_type_test.cc | 32 +++++------ src/inspector/inspector_test.cc | 6 +- src/reader/spirv/parser_impl.cc | 5 +- .../spirv/parser_impl_module_var_test.cc | 33 +++++++---- src/reader/wgsl/parser_impl.cc | 5 +- .../wgsl/parser_impl_type_alias_test.cc | 5 +- .../parser_impl_variable_ident_decl_test.cc | 25 +++++---- src/transform/first_index_offset.cc | 2 +- src/transform/vertex_pulling.cc | 2 +- src/type_determiner_test.cc | 9 +-- src/validator/validator_type_test.cc | 10 ++-- .../hlsl/generator_impl_alias_type_test.cc | 2 +- .../hlsl/generator_impl_function_test.cc | 10 ++-- .../generator_impl_member_accessor_test.cc | 56 +++++++++---------- src/writer/hlsl/generator_impl_type_test.cc | 10 ++-- .../msl/generator_impl_alias_type_test.cc | 4 +- .../msl/generator_impl_function_test.cc | 10 ++-- src/writer/msl/generator_impl_test.cc | 6 +- src/writer/msl/generator_impl_type_test.cc | 10 ++-- ...rator_impl_variable_decl_statement_test.cc | 2 +- .../spirv/builder_accessor_expression_test.cc | 36 ++++++------ src/writer/spirv/builder_assign_test.cc | 2 +- .../builder_constructor_expression_test.cc | 8 +-- 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 | 14 ++--- .../wgsl/generator_impl_alias_type_test.cc | 4 +- .../wgsl/generator_impl_function_test.cc | 2 +- src/writer/wgsl/generator_impl_type_test.cc | 10 ++-- 35 files changed, 201 insertions(+), 166 deletions(-) diff --git a/src/ast/module_test.cc b/src/ast/module_test.cc index cab119bcbc..75a4d3c548 100644 --- a/src/ast/module_test.cc +++ b/src/ast/module_test.cc @@ -108,7 +108,7 @@ TEST_F(ModuleTest, IsValid_Null_Alias) { TEST_F(ModuleTest, IsValid_Struct) { type::F32 f32; - type::Struct st("name", {}); + type::Struct st(mod.RegisterSymbol("name"), "name", {}); type::Alias alias(mod.RegisterSymbol("name"), "name", &st); Module m; @@ -118,7 +118,7 @@ TEST_F(ModuleTest, IsValid_Struct) { TEST_F(ModuleTest, IsValid_Struct_EmptyName) { type::F32 f32; - type::Struct st("", {}); + type::Struct st(mod.RegisterSymbol(""), "", {}); type::Alias alias(mod.RegisterSymbol("name"), "name", &st); Module m; diff --git a/src/ast/type/access_control_type_test.cc b/src/ast/type/access_control_type_test.cc index 04ba748515..2927685ad3 100644 --- a/src/ast/type/access_control_type_test.cc +++ b/src/ast/type/access_control_type_test.cc @@ -135,7 +135,7 @@ TEST_F(AccessControlTest, MinBufferBindingSizeStruct) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); AccessControl at{ast::AccessControl::kReadOnly, &struct_type}; EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(8u, at.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); @@ -180,7 +180,7 @@ TEST_F(AccessControlTest, BaseAlignmentStruct) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); AccessControl at{ast::AccessControl::kReadOnly, &struct_type}; EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(4u, at.BaseAlignment(MemoryLayout::kStorageBuffer)); diff --git a/src/ast/type/alias_type_test.cc b/src/ast/type/alias_type_test.cc index 638716bf48..55bc94cfb1 100644 --- a/src/ast/type/alias_type_test.cc +++ b/src/ast/type/alias_type_test.cc @@ -208,7 +208,7 @@ TEST_F(AliasTest, MinBufferBindingSizeStruct) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); Alias alias{mod.RegisterSymbol("alias"), "alias", &struct_type}; EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(8u, alias.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); @@ -257,7 +257,7 @@ TEST_F(AliasTest, BaseAlignmentStruct) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); Alias alias{mod.RegisterSymbol("alias"), "alias", &struct_type}; EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(4u, alias.BaseAlignment(MemoryLayout::kStorageBuffer)); diff --git a/src/ast/type/struct_type.cc b/src/ast/type/struct_type.cc index 7ce4b14ed1..ddf163bc65 100644 --- a/src/ast/type/struct_type.cc +++ b/src/ast/type/struct_type.cc @@ -30,15 +30,15 @@ namespace tint { namespace ast { namespace type { -Struct::Struct(const std::string& name, ast::Struct* impl) - : name_(name), struct_(impl) {} +Struct::Struct(const Symbol& sym, const std::string& name, ast::Struct* impl) + : symbol_(sym), name_(name), struct_(impl) {} Struct::Struct(Struct&&) = default; Struct::~Struct() = default; std::string Struct::type_name() const { - return "__struct_" + name_; + return "__struct_" + symbol_.to_str(); } uint64_t Struct::MinBufferBindingSize(MemoryLayout mem_layout) const { @@ -84,7 +84,7 @@ uint64_t Struct::BaseAlignment(MemoryLayout mem_layout) const { } Struct* Struct::Clone(CloneContext* ctx) const { - return ctx->mod->create(name_, ctx->Clone(struct_)); + return ctx->mod->create(symbol_, name_, ctx->Clone(struct_)); } } // namespace type diff --git a/src/ast/type/struct_type.h b/src/ast/type/struct_type.h index 91b60c9b08..d372c1c129 100644 --- a/src/ast/type/struct_type.h +++ b/src/ast/type/struct_type.h @@ -20,6 +20,7 @@ #include "src/ast/struct.h" #include "src/ast/type/type.h" +#include "src/symbol.h" namespace tint { namespace ast { @@ -29,13 +30,16 @@ namespace type { class Struct : public Castable { public: /// Constructor + /// @param sym the symbol representing the struct /// @param name the name of the struct /// @param impl the struct data - Struct(const std::string& name, ast::Struct* impl); + Struct(const Symbol& sym, const std::string& name, ast::Struct* impl); /// Move constructor Struct(Struct&&); ~Struct() override; + /// @returns the struct symbol + const Symbol& symbol() const { return symbol_; } /// @returns the struct name const std::string& name() const { return name_; } @@ -64,6 +68,7 @@ class Struct : public Castable { Struct* Clone(CloneContext* ctx) const override; private: + Symbol symbol_; std::string name_; ast::Struct* struct_ = nullptr; diff --git a/src/ast/type/struct_type_test.cc b/src/ast/type/struct_type_test.cc index b90d0ac6b7..0a7b2d16f9 100644 --- a/src/ast/type/struct_type_test.cc +++ b/src/ast/type/struct_type_test.cc @@ -44,7 +44,7 @@ TEST_F(StructTest, Creation) { auto* impl = create(Source{}, members, ast::StructDecorationList{}); auto* ptr = impl; - Struct s{"S", impl}; + Struct s{mod.RegisterSymbol("S"), "S", impl}; EXPECT_EQ(s.impl(), ptr); } @@ -52,7 +52,7 @@ TEST_F(StructTest, Is) { StructMemberList members; auto* impl = create(Source{}, members, ast::StructDecorationList{}); - Struct s{"S", impl}; + Struct s{mod.RegisterSymbol("S"), "S", impl}; Type* ty = &s; EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); @@ -73,8 +73,8 @@ TEST_F(StructTest, TypeName) { StructMemberList members; auto* impl = create(Source{}, members, ast::StructDecorationList{}); - Struct s{"my_struct", impl}; - EXPECT_EQ(s.type_name(), "__struct_my_struct"); + Struct s{mod.RegisterSymbol("my_struct"), "my_struct", impl}; + EXPECT_EQ(s.type_name(), "__struct_tint_symbol_1"); } TEST_F(StructTest, MinBufferBindingSize) { @@ -94,7 +94,7 @@ TEST_F(StructTest, MinBufferBindingSize) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); EXPECT_EQ(16u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(8u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); @@ -124,7 +124,7 @@ TEST_F(StructTest, MinBufferBindingSizeArray) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); EXPECT_EQ(32u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(24u, @@ -155,7 +155,7 @@ TEST_F(StructTest, MinBufferBindingSizeRuntimeArray) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); EXPECT_EQ(12u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); } @@ -173,7 +173,7 @@ TEST_F(StructTest, MinBufferBindingSizeVec2) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); EXPECT_EQ(16u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(8u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer)); @@ -192,7 +192,7 @@ TEST_F(StructTest, MinBufferBindingSizeVec3) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); EXPECT_EQ(16u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, @@ -212,7 +212,7 @@ TEST_F(StructTest, MinBufferBindingSizeVec4) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); EXPECT_EQ(16u, struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, @@ -236,7 +236,7 @@ TEST_F(StructTest, BaseAlignment) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); } @@ -265,7 +265,7 @@ TEST_F(StructTest, BaseAlignmentArray) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); } @@ -294,7 +294,7 @@ TEST_F(StructTest, BaseAlignmentRuntimeArray) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); } @@ -311,7 +311,7 @@ TEST_F(StructTest, BaseAlignmentVec2) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(8u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); } @@ -329,7 +329,7 @@ TEST_F(StructTest, BaseAlignmentVec3) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer)); EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer)); } @@ -347,7 +347,7 @@ TEST_F(StructTest, BaseAlignmentVec4) { StructDecorationList decos; auto* str = create(Source{}, members, decos); - Struct struct_type("struct_type", str); + Struct struct_type(mod.RegisterSymbol("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 99250af269..2341b84b08 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -310,7 +310,8 @@ class InspectorHelper { auto* str = create(Source{}, members, decos); - return std::make_unique(name, str); + return std::make_unique(mod()->RegisterSymbol(name), + name, str); } /// Generates types appropriate for using in an uniform buffer @@ -1455,7 +1456,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingBlockDeco) { ast::StructDecorationList decos; auto* str = create(Source{}, members, decos); - auto foo_type = std::make_unique("foo_type", str); + auto foo_type = std::make_unique( + mod()->RegisterSymbol("foo_type"), "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 9cabd3e753..122ce2f28d 100644 --- a/src/reader/spirv/parser_impl.cc +++ b/src/reader/spirv/parser_impl.cc @@ -952,8 +952,9 @@ ast::type::Type* ParserImpl::ConvertType( namer_.SuggestSanitizedName(type_id, "S"); - auto* result = ast_module_.create(namer_.GetName(type_id), - ast_struct); + auto name = namer_.GetName(type_id); + auto* result = ast_module_.create( + ast_module_.RegisterSymbol(name), name, ast_struct); id_to_type_[type_id] = result; if (num_non_writable_members == members.size()) { read_only_struct_types_.insert(result); diff --git a/src/reader/spirv/parser_impl_module_var_test.cc b/src/reader/spirv/parser_impl_module_var_test.cc index 15549611d9..7ab05d1d83 100644 --- a/src/reader/spirv/parser_impl_module_var_test.cc +++ b/src/reader/spirv/parser_impl_module_var_test.cc @@ -1059,7 +1059,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StructInitializer) { )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); EXPECT_TRUE(p->error().empty()); - const auto module_str = p->module().to_str(); + const auto module_str = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_str, HasSubstr(R"(Variable{ x_200 private @@ -1088,7 +1089,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StructNullInitializer) { )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); EXPECT_TRUE(p->error().empty()); - const auto module_str = p->module().to_str(); + const auto module_str = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_str, HasSubstr(R"(Variable{ x_200 private @@ -1117,7 +1119,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StructUndefInitializer) { )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); EXPECT_TRUE(p->error().empty()); - const auto module_str = p->module().to_str(); + const auto module_str = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_str, HasSubstr(R"(Variable{ x_200 private @@ -1200,7 +1203,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_DescriptorSetDecoration_Valid) { )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); EXPECT_TRUE(p->error().empty()); - const auto module_str = p->module().to_str(); + const auto module_str = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_str, HasSubstr(R"( Variable{ Decorations{ @@ -1254,7 +1258,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_BindingDecoration_Valid) { )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); EXPECT_TRUE(p->error().empty()); - const auto module_str = p->module().to_str(); + const auto module_str = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_str, HasSubstr(R"( Variable{ Decorations{ @@ -1309,7 +1314,8 @@ TEST_F(SpvParserTest, )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()); EXPECT_TRUE(p->error().empty()); - const auto module_str = p->module().to_str(); + const auto module_str = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_str, HasSubstr(R"( S Struct{ [[block]] @@ -1340,7 +1346,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_ColMajorDecoration_Dropped) { )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); EXPECT_TRUE(p->error().empty()); - const auto module_str = p->module().to_str(); + const auto module_str = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_str, HasSubstr(R"( S Struct{ [[block]] @@ -1369,7 +1376,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_MatrixStrideDecoration_Dropped) { )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); EXPECT_TRUE(p->error().empty()); - const auto module_str = p->module().to_str(); + const auto module_str = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_str, HasSubstr(R"( S Struct{ [[block]] @@ -1418,7 +1426,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StorageBuffer_NonWritable_AllMembers) { )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); EXPECT_TRUE(p->error().empty()); - const auto module_str = p->module().to_str(); + const auto module_str = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_str, HasSubstr(R"( S Struct{ [[block]] @@ -1447,7 +1456,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StorageBuffer_NonWritable_NotAllMembers) { )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); EXPECT_TRUE(p->error().empty()); - const auto module_str = p->module().to_str(); + const auto module_str = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_str, HasSubstr(R"( S Struct{ [[block]] @@ -1479,7 +1489,8 @@ TEST_F( )")); ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error(); EXPECT_TRUE(p->error().empty()); - const auto module_str = p->module().to_str(); + const auto module_str = + Demangler().Demangle(p->get_module(), p->get_module().to_str()); EXPECT_THAT(module_str, HasSubstr(R"( S Struct{ [[block]] diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index d6270cc71b..637ab83f41 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -1192,8 +1192,9 @@ Maybe> ParserImpl::struct_decl( return Failure::kErrored; return std::make_unique( - name.value, create(source, std::move(body.value), - std::move(struct_decos.value))); + module_.RegisterSymbol(name.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_type_alias_test.cc b/src/reader/wgsl/parser_impl_type_alias_test.cc index aeae59c5e3..fc9e0d1ca8 100644 --- a/src/reader/wgsl/parser_impl_type_alias_test.cc +++ b/src/reader/wgsl/parser_impl_type_alias_test.cc @@ -43,9 +43,9 @@ TEST_F(ParserImplTest, TypeDecl_ParsesType) { } TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) { - ast::type::Struct str("B", {}); - auto p = parser("type a = B"); + + ast::type::Struct str(p->get_module().RegisterSymbol("B"), "B", {}); p->register_constructed("B", &str); auto t = p->type_alias(); @@ -59,6 +59,7 @@ TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) { ASSERT_TRUE(alias->type()->Is()); auto* s = alias->type()->As(); + EXPECT_EQ(s->symbol(), p->get_module().RegisterSymbol("B")); EXPECT_EQ(s->name(), "B"); } 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 e971c60a7a..90619ce3ee 100644 --- a/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc +++ b/src/reader/wgsl/parser_impl_variable_ident_decl_test.cc @@ -85,6 +85,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_InvalidType) { TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) { ast::type::I32 i32; + auto p = parser("my_var : [[access(read)]] S"); + ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{}); ast::StructMemberList members; members.push_back(&mem); @@ -94,9 +96,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) { decos.push_back(&block_deco); ast::Struct str(Source{}, members, decos); - ast::type::Struct s("S", &str); + ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str); - auto p = parser("my_var : [[access(read)]] S"); p->register_constructed("S", &s); auto decl = p->expect_variable_ident_decl("test"); @@ -111,6 +112,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) { TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) { ast::type::I32 i32; + auto p = parser("my_var : [[access(read_write)]] S"); + ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{}); ast::StructMemberList members; members.push_back(&mem); @@ -120,9 +123,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) { decos.push_back(&block_deco); ast::Struct str(Source{}, members, decos); - ast::type::Struct s("S", &str); + ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str); - auto p = parser("my_var : [[access(read_write)]] S"); p->register_constructed("S", &s); auto decl = p->expect_variable_ident_decl("test"); @@ -137,6 +139,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) { TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) { ast::type::I32 i32; + auto p = parser("my_var : [[access(read), access(read_write)]] S"); + ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{}); ast::StructMemberList members; members.push_back(&mem); @@ -146,9 +150,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) { decos.push_back(&block_deco); ast::Struct str(Source{}, members, decos); - ast::type::Struct s("S", &str); + ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str); - auto p = parser("my_var : [[access(read), access(read_write)]] S"); p->register_constructed("S", &s); auto decl = p->expect_variable_ident_decl("test"); @@ -160,6 +163,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) { TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) { ast::type::I32 i32; + auto p = parser("my_var : [[access(read)]][[access(read_write)]] S"); + ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{}); ast::StructMemberList members; members.push_back(&mem); @@ -169,9 +174,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) { decos.push_back(&block_deco); ast::Struct str(Source{}, members, decos); - ast::type::Struct s("S", &str); + ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str); - auto p = parser("my_var : [[access(read)]][[access(read_write)]] S"); p->register_constructed("S", &s); auto decl = p->expect_variable_ident_decl("test"); @@ -199,6 +203,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_AccessDecoIllegalValue) { TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) { ast::type::I32 i32; + auto p = parser("my_var : [[stride(1)]] S"); + ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{}); ast::StructMemberList members; members.push_back(&mem); @@ -208,9 +214,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) { decos.push_back(&block_deco); ast::Struct str(Source{}, members, decos); - ast::type::Struct s("S", &str); + ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str); - auto p = parser("my_var : [[stride(1)]] S"); p->register_constructed("S", &s); auto decl = p->expect_variable_ident_decl("test"); diff --git a/src/transform/first_index_offset.cc b/src/transform/first_index_offset.cc index 45273b085a..5168e6588a 100644 --- a/src/transform/first_index_offset.cc +++ b/src/transform/first_index_offset.cc @@ -224,7 +224,7 @@ ast::Variable* FirstIndexOffset::AddUniformBuffer(ast::Module* mod) { decos.push_back(mod->create(Source{})); auto* struct_type = mod->create( - kStructName, + mod->RegisterSymbol(kStructName), kStructName, mod->create(Source{}, std::move(members), std::move(decos))); auto* idx_var = mod->create( diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc index cf4ec6f9f1..23b9763d08 100644 --- a/src/transform/vertex_pulling.cc +++ b/src/transform/vertex_pulling.cc @@ -264,7 +264,7 @@ void VertexPulling::State::AddVertexStorageBuffers() { decos.push_back(mod->create(Source{})); auto* struct_type = mod->create( - kStructName, + mod->RegisterSymbol(kStructName), kStructName, mod->create(Source{}, std::move(members), std::move(decos))); for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) { diff --git a/src/type_determiner_test.cc b/src/type_determiner_test.cc index 5f317dc9a6..db04d8f92a 100644 --- a/src/type_determiner_test.cc +++ b/src/type_determiner_test.cc @@ -1218,7 +1218,7 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct) { auto* strct = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct st("S", strct); + ast::type::Struct st(mod->RegisterSymbol("S"), "S", strct); auto* var = create(Source{}, // source @@ -1262,7 +1262,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) { auto* strct = create(Source{}, members, ast::StructDecorationList{}); - auto st = std::make_unique("alias", strct); + auto st = std::make_unique(mod->RegisterSymbol("alias"), + "alias", strct); ast::type::Alias alias(mod->RegisterSymbol("alias"), "alias", st.get()); auto* var = @@ -1391,7 +1392,7 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) { auto* strctB = create(Source{}, b_members, ast::StructDecorationList{}); - ast::type::Struct stB("B", strctB); + ast::type::Struct stB(mod->RegisterSymbol("B"), "B", strctB); ast::type::Vector vecB(&stB, 3); @@ -1401,7 +1402,7 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) { auto* strctA = create(Source{}, a_members, ast::StructDecorationList{}); - ast::type::Struct stA("A", strctA); + ast::type::Struct stA(mod->RegisterSymbol("A"), "A", strctA); auto* var = create(Source{}, // source diff --git a/src/validator/validator_type_test.cc b/src/validator/validator_type_test.cc index aec9695604..a7f84ae8a3 100644 --- a/src/validator/validator_type_test.cc +++ b/src/validator/validator_type_test.cc @@ -57,7 +57,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLast_Pass) { ast::StructDecorationList decos; decos.push_back(create(Source{})); auto* st = create(Source{}, members, decos); - ast::type::Struct struct_type("Foo", st); + ast::type::Struct struct_type(mod()->RegisterSymbol("Foo"), "Foo", st); mod()->AddConstructedType(&struct_type); EXPECT_TRUE(v()->ValidateConstructedTypes(mod()->constructed_types())); @@ -83,7 +83,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) { } ast::StructDecorationList decos; auto* st = create(Source{}, members, decos); - ast::type::Struct struct_type("Foo", st); + ast::type::Struct struct_type(mod()->RegisterSymbol("Foo"), "Foo", st); mod()->AddConstructedType(&struct_type); EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types())); @@ -114,7 +114,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsNotLast_Fail) { ast::StructDecorationList decos; decos.push_back(create(Source{})); auto* st = create(Source{}, members, decos); - ast::type::Struct struct_type("Foo", st); + ast::type::Struct struct_type(mod()->RegisterSymbol("Foo"), "Foo", st); mod()->AddConstructedType(&struct_type); EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types())); @@ -149,7 +149,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsNotLast_Fail) { ast::StructDecorationList decos; decos.push_back(create(Source{})); auto* st = create(Source{}, members, decos); - ast::type::Struct struct_type("s", st); + ast::type::Struct struct_type(mod()->RegisterSymbol("s"), "s", st); mod()->AddConstructedType(&struct_type); EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types())); EXPECT_EQ(v()->error(), @@ -182,7 +182,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) { ast::StructDecorationList decos; decos.push_back(create(Source{})); auto* st = create(Source{}, members, decos); - ast::type::Struct struct_type("s", st); + ast::type::Struct struct_type(mod()->RegisterSymbol("s"), "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 4b01f06116..9842bedf69 100644 --- a/src/writer/hlsl/generator_impl_alias_type_test.cc +++ b/src/writer/hlsl/generator_impl_alias_type_test.cc @@ -62,7 +62,7 @@ TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_Struct) { }, ast::StructDecorationList{}); - ast::type::Struct s("A", str); + ast::type::Struct s(mod.RegisterSymbol("A"), "A", str); ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s); ASSERT_TRUE(gen.EmitConstructedType(out, &alias)) << gen.error(); diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc index 68069fbdcf..d1dee24d78 100644 --- a/src/writer/hlsl/generator_impl_function_test.cc +++ b/src/writer/hlsl/generator_impl_function_test.cc @@ -358,7 +358,7 @@ TEST_F(HlslGeneratorImplTest_Function, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Uniforms", str); + ast::type::Struct s(mod.RegisterSymbol("Uniforms"), "Uniforms", str); auto* coord_var = create(Source{}, // source @@ -443,7 +443,7 @@ TEST_F(HlslGeneratorImplTest_Function, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); auto* coord_var = @@ -519,7 +519,7 @@ TEST_F(HlslGeneratorImplTest_Function, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s); auto* coord_var = @@ -595,7 +595,7 @@ TEST_F(HlslGeneratorImplTest_Function, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); auto* coord_var = @@ -1371,7 +1371,7 @@ TEST_F(HlslGeneratorImplTest_Function, auto* str = create(Source{}, members, s_decos); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); auto* data_var = diff --git a/src/writer/hlsl/generator_impl_member_accessor_test.cc b/src/writer/hlsl/generator_impl_member_accessor_test.cc index 3f3cfcb7a2..1f9d76d3fd 100644 --- a/src/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/writer/hlsl/generator_impl_member_accessor_test.cc @@ -56,7 +56,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) { auto* strct = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Str", strct); + ast::type::Struct s(mod.RegisterSymbol("Str"), "Str", strct); auto* str_var = create(Source{}, // source @@ -108,7 +108,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* coord_var = create(Source{}, // source @@ -162,7 +162,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* coord_var = create(Source{}, // source @@ -221,7 +221,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, }, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* b_var = create(Source{}, // source @@ -298,7 +298,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* coord_var = create(Source{}, // source @@ -363,7 +363,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* coord_var = create(Source{}, // source @@ -424,7 +424,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* coord_var = create(Source{}, // source @@ -477,7 +477,7 @@ TEST_F( auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* coord_var = create(Source{}, // source @@ -534,7 +534,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* coord_var = create(Source{}, // source @@ -595,7 +595,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* coord_var = create(Source{}, // source @@ -652,7 +652,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* coord_var = create(Source{}, // source @@ -719,7 +719,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* coord_var = create(Source{}, // source @@ -777,7 +777,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* coord_var = create(Source{}, // source @@ -840,7 +840,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* coord_var = create(Source{}, // source @@ -901,7 +901,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* coord_var = create(Source{}, // source @@ -958,7 +958,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); auto* coord_var = create(Source{}, // source @@ -1034,7 +1034,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, }, ast::StructDecorationList{}); - ast::type::Struct data("Data", data_str); + ast::type::Struct data(mod.RegisterSymbol("Data"), "Data", data_str); ast::type::Array ary(&data, 4, ast::ArrayDecorationList{ @@ -1051,7 +1051,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, }, ast::StructDecorationList{}); - ast::type::Struct pre_struct("Pre", pre_str); + ast::type::Struct pre_struct(mod.RegisterSymbol("Pre"), "Pre", pre_str); auto* coord_var = create(Source{}, // source @@ -1125,7 +1125,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, }, ast::StructDecorationList{}); - ast::type::Struct data("Data", data_str); + ast::type::Struct data(mod.RegisterSymbol("Data"), "Data", data_str); ast::type::Array ary( &data, 4, @@ -1139,7 +1139,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(0, Source{})})}, ast::StructDecorationList{}); - ast::type::Struct pre_struct("Pre", pre_str); + ast::type::Struct pre_struct(mod.RegisterSymbol("Pre"), "Pre", pre_str); auto* coord_var = create(Source{}, // source @@ -1215,7 +1215,7 @@ TEST_F( }, ast::StructDecorationList{}); - ast::type::Struct data("Data", data_str); + ast::type::Struct data(mod.RegisterSymbol("Data"), "Data", data_str); ast::type::Array ary(&data, 4, ast::ArrayDecorationList{ @@ -1230,7 +1230,7 @@ TEST_F( create(0, Source{})})}, ast::StructDecorationList{}); - ast::type::Struct pre_struct("Pre", pre_str); + ast::type::Struct pre_struct(mod.RegisterSymbol("Pre"), "Pre", pre_str); auto* coord_var = create(Source{}, // source @@ -1305,7 +1305,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, }, ast::StructDecorationList{}); - ast::type::Struct data("Data", data_str); + ast::type::Struct data(mod.RegisterSymbol("Data"), "Data", data_str); ast::type::Array ary(&data, 4, ast::ArrayDecorationList{ @@ -1320,7 +1320,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(0, Source{})})}, ast::StructDecorationList{}); - ast::type::Struct pre_struct("Pre", pre_str); + ast::type::Struct pre_struct(mod.RegisterSymbol("Pre"), "Pre", pre_str); auto* coord_var = create(Source{}, // source @@ -1395,7 +1395,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, }, ast::StructDecorationList{}); - ast::type::Struct data("Data", data_str); + ast::type::Struct data(mod.RegisterSymbol("Data"), "Data", data_str); ast::type::Array ary(&data, 4, ast::ArrayDecorationList{ @@ -1410,7 +1410,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(0, Source{})})}, ast::StructDecorationList{}); - ast::type::Struct pre_struct("Pre", pre_str); + ast::type::Struct pre_struct(mod.RegisterSymbol("Pre"), "Pre", pre_str); auto* coord_var = create(Source{}, // source @@ -1495,7 +1495,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, }, ast::StructDecorationList{}); - ast::type::Struct data("Data", data_str); + ast::type::Struct data(mod.RegisterSymbol("Data"), "Data", data_str); ast::type::Array ary(&data, 4, ast::ArrayDecorationList{ @@ -1510,7 +1510,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, create(0, Source{})})}, ast::StructDecorationList{}); - ast::type::Struct pre_struct("Pre", pre_str); + ast::type::Struct pre_struct(mod.RegisterSymbol("Pre"), "Pre", pre_str); auto* coord_var = create(Source{}, // source diff --git a/src/writer/hlsl/generator_impl_type_test.cc b/src/writer/hlsl/generator_impl_type_test.cc index 9e3765d609..9ad6beb2bf 100644 --- a/src/writer/hlsl/generator_impl_type_test.cc +++ b/src/writer/hlsl/generator_impl_type_test.cc @@ -184,7 +184,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); ASSERT_TRUE(gen.EmitStructType(out, &s, "S")) << gen.error(); EXPECT_EQ(result(), R"(struct S { @@ -209,7 +209,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error(); EXPECT_EQ(result(), "S"); @@ -234,7 +234,7 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_InjectPadding) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error(); EXPECT_EQ(result(), R"(struct { @@ -261,7 +261,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); ASSERT_TRUE(gen.EmitStructType(out, &s, "S")) << gen.error(); EXPECT_EQ(result(), R"(struct S { @@ -289,7 +289,7 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_WithDecoration) { auto* str = create(Source{}, members, decos); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); ASSERT_TRUE(gen.EmitStructType(out, &s, "B")) << gen.error(); EXPECT_EQ(result(), R"(struct B { diff --git a/src/writer/msl/generator_impl_alias_type_test.cc b/src/writer/msl/generator_impl_alias_type_test.cc index 581260c9db..1e886172ab 100644 --- a/src/writer/msl/generator_impl_alias_type_test.cc +++ b/src/writer/msl/generator_impl_alias_type_test.cc @@ -64,7 +64,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_Struct) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("a", str); + ast::type::Struct s(mod.RegisterSymbol("a"), "a", str); ASSERT_TRUE(gen.EmitConstructedType(&s)) << gen.error(); EXPECT_EQ(gen.result(), R"(struct a { @@ -89,7 +89,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_AliasStructIdent) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("b", str); + ast::type::Struct s(mod.RegisterSymbol("b"), "b", str); ast::type::Alias alias(mod.RegisterSymbol("a"), "a", &s); ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error(); diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc index 581247e02d..e4bf9dc1b0 100644 --- a/src/writer/msl/generator_impl_function_test.cc +++ b/src/writer/msl/generator_impl_function_test.cc @@ -374,7 +374,7 @@ TEST_F(MslGeneratorImplTest, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); mod.AddConstructedType(&s); @@ -459,7 +459,7 @@ TEST_F(MslGeneratorImplTest, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s); mod.AddConstructedType(&s); @@ -973,7 +973,7 @@ TEST_F(MslGeneratorImplTest, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); mod.AddConstructedType(&s); @@ -1088,7 +1088,7 @@ TEST_F(MslGeneratorImplTest, auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s); mod.AddConstructedType(&s); @@ -1347,7 +1347,7 @@ TEST_F(MslGeneratorImplTest, auto* str = create(Source{}, members, s_decos); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); auto* data_var = diff --git a/src/writer/msl/generator_impl_test.cc b/src/writer/msl/generator_impl_test.cc index 1f289203c8..10cd631aa2 100644 --- a/src/writer/msl/generator_impl_test.cc +++ b/src/writer/msl/generator_impl_test.cc @@ -174,7 +174,7 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); EXPECT_EQ(132u, gen.calculate_alignment_size(&s)); } @@ -199,7 +199,7 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) { auto* inner_str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct inner_s("Inner", inner_str); + ast::type::Struct inner_s(mod.RegisterSymbol("Inner"), "Inner", inner_str); decos.push_back(create(0, Source{})); members.push_back(create(Source{}, "d", &f32, decos)); @@ -213,7 +213,7 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) { auto* outer_str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct outer_s("Outer", outer_str); + ast::type::Struct outer_s(mod.RegisterSymbol("Outer"), "Outer", outer_str); EXPECT_EQ(80u, gen.calculate_alignment_size(&outer_s)); } diff --git a/src/writer/msl/generator_impl_type_test.cc b/src/writer/msl/generator_impl_type_test.cc index c779de64b8..b3725188ac 100644 --- a/src/writer/msl/generator_impl_type_test.cc +++ b/src/writer/msl/generator_impl_type_test.cc @@ -185,7 +185,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error(); EXPECT_EQ(gen.result(), "S"); @@ -206,7 +206,7 @@ TEST_F(MslGeneratorImplTest, EmitType_StructDecl) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error(); EXPECT_EQ(gen.result(), R"(struct S { @@ -238,7 +238,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_InjectPadding) { }, ast::StructDecorationList{}); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error(); EXPECT_EQ(gen.result(), R"(struct S { @@ -266,7 +266,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_NameCollision) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error(); EXPECT_EQ(gen.result(), R"(struct S { @@ -293,7 +293,7 @@ TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Struct_WithDecoration) { decos.push_back(create(Source{})); auto* str = create(Source{}, members, decos); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error(); EXPECT_EQ(gen.result(), R"(struct { 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 791ad6ad09..c575744a8d 100644 --- a/src/writer/msl/generator_impl_variable_decl_statement_test.cc +++ b/src/writer/msl/generator_impl_variable_decl_statement_test.cc @@ -113,7 +113,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Struct) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); auto* var = create(Source{}, // source diff --git a/src/writer/spirv/builder_accessor_expression_test.cc b/src/writer/spirv/builder_accessor_expression_test.cc index 43ebfc8e06..c820bb85e2 100644 --- a/src/writer/spirv/builder_accessor_expression_test.cc +++ b/src/writer/spirv/builder_accessor_expression_test.cc @@ -305,7 +305,7 @@ TEST_F(BuilderTest, MemberAccessor) { members.push_back(create(Source{}, "b", &f32, decos)); auto* s = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s_type("my_struct", s); + ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s); ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type, false, nullptr, ast::VariableDecorationList{}); @@ -361,14 +361,15 @@ TEST_F(BuilderTest, MemberAccessor_Nested) { create(Source{}, "b", &f32, decos)); ast::type::Struct inner_struct( - "Inner", create(Source{}, inner_members, - ast::StructDecorationList{})); + mod->RegisterSymbol("Inner"), "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", + ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", create(Source{}, outer_members, ast::StructDecorationList{})); @@ -432,8 +433,9 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) { create(Source{}, "b", &f32, decos)); ast::type::Struct inner_struct( - "Inner", create(Source{}, inner_members, - ast::StructDecorationList{})); + mod->RegisterSymbol("Inner"), "Inner", + create(Source{}, inner_members, + ast::StructDecorationList{})); ast::type::Alias alias(mod->RegisterSymbol("Inner"), "Inner", &inner_struct); @@ -441,7 +443,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) { outer_members.push_back( create(Source{}, "inner", &alias, decos)); - ast::type::Struct s_type("Outer", + ast::type::Struct s_type(mod->RegisterSymbol("Outer"), "Outer", create(Source{}, outer_members, ast::StructDecorationList{})); @@ -505,14 +507,15 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) { create(Source{}, "b", &f32, decos)); ast::type::Struct inner_struct( - "Inner", create(Source{}, inner_members, - ast::StructDecorationList{})); + mod->RegisterSymbol("Inner"), "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", + ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", create(Source{}, outer_members, ast::StructDecorationList{})); @@ -583,14 +586,15 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) { create(Source{}, "b", &f32, decos)); ast::type::Struct inner_struct( - "Inner", create(Source{}, inner_members, - ast::StructDecorationList{})); + mod->RegisterSymbol("Inner"), "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", + ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", create(Source{}, outer_members, ast::StructDecorationList{})); @@ -881,13 +885,13 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) { ast::StructMemberList{create( Source{}, "baz", &vec3, decos)}, ast::StructDecorationList{}); - ast::type::Struct c_type("C", s); + ast::type::Struct c_type(mod->RegisterSymbol("C"), "C", s); s = create(Source{}, ast::StructMemberList{create( Source{}, "bar", &c_type, decos)}, ast::StructDecorationList{}); - ast::type::Struct b_type("B", s); + ast::type::Struct b_type(mod->RegisterSymbol("B"), "B", s); ast::type::Array b_ary_type(&b_type, 3, ast::ArrayDecorationList{}); @@ -895,7 +899,7 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) { ast::StructMemberList{create( Source{}, "foo", &b_ary_type, decos)}, ast::StructDecorationList{}); - ast::type::Struct a_type("A", s); + ast::type::Struct a_type(mod->RegisterSymbol("A"), "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 79bb488ad8..eb03bc6167 100644 --- a/src/writer/spirv/builder_assign_test.cc +++ b/src/writer/spirv/builder_assign_test.cc @@ -235,7 +235,7 @@ TEST_F(BuilderTest, Assign_StructMember) { members.push_back(create(Source{}, "b", &f32, decos)); auto* s = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s_type("my_struct", s); + ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s); ast::Variable v(Source{}, "ident", ast::StorageClass::kFunction, &s_type, false, nullptr, ast::VariableDecorationList{}); diff --git a/src/writer/spirv/builder_constructor_expression_test.cc b/src/writer/spirv/builder_constructor_expression_test.cc index ac33690253..c00af4553b 100644 --- a/src/writer/spirv/builder_constructor_expression_test.cc +++ b/src/writer/spirv/builder_constructor_expression_test.cc @@ -949,7 +949,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Struct) { create(Source{}, "b", ty.vec3(), decos), }, ast::StructDecorationList{}); - ast::type::Struct s_type("my_struct", s); + ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s); auto* t = Construct(&s_type, 2.0f, vec3(2.0f, 2.0f, 2.0f)); @@ -1088,7 +1088,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Struct) { create(Source{}, "a", ty.f32, decos), }, ast::StructDecorationList{}); - ast::type::Struct s_type("my_struct", s); + ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s); auto* t = Construct(&s_type); @@ -1504,7 +1504,7 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct) { create(Source{}, "b", ty.vec3(), decos), }, ast::StructDecorationList{}); - ast::type::Struct s_type("my_struct", s); + ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s); auto* t = Construct(&s_type, 2.f, vec3(2.f, 2.f, 2.f)); @@ -1525,7 +1525,7 @@ TEST_F(SpvBuilderConstructorTest, }, ast::StructDecorationList{}); - ast::type::Struct s_type("my_struct", s); + ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s); auto* t = Construct(&s_type, 2.f, "a", 2.f); diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc index 7953a43713..04a5a95128 100644 --- a/src/writer/spirv/builder_function_test.cc +++ b/src/writer/spirv/builder_function_test.cc @@ -271,7 +271,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { auto* str = create(Source{}, members, s_decos); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod->RegisterSymbol("Data"), "Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); auto* data_var = diff --git a/src/writer/spirv/builder_global_variable_test.cc b/src/writer/spirv/builder_global_variable_test.cc index da47bb0df2..86d8f19785 100644 --- a/src/writer/spirv/builder_global_variable_test.cc +++ b/src/writer/spirv/builder_global_variable_test.cc @@ -534,7 +534,8 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { members.push_back(create(Source{}, "b", &i32, decos)); ast::type::Struct A( - "A", create(Source{}, members, ast::StructDecorationList{})); + mod->RegisterSymbol("A"), "A", + create(Source{}, members, ast::StructDecorationList{})); ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A}; ast::Variable var(Source{}, "b", ast::StorageClass::kStorageBuffer, &ac, @@ -571,7 +572,8 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) { members.push_back(create(Source{}, "a", &i32, decos)); ast::type::Struct A( - "A", create(Source{}, members, ast::StructDecorationList{})); + mod->RegisterSymbol("A"), "A", + create(Source{}, members, ast::StructDecorationList{})); ast::type::Alias B(mod->RegisterSymbol("B"), "B", &A); ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &B}; @@ -607,7 +609,8 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) { members.push_back(create(Source{}, "a", &i32, decos)); ast::type::Struct A( - "A", create(Source{}, members, ast::StructDecorationList{})); + mod->RegisterSymbol("A"), "A", + create(Source{}, members, ast::StructDecorationList{})); ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A}; ast::type::Alias B(mod->RegisterSymbol("B"), "B", &ac); @@ -643,7 +646,8 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) { members.push_back(create(Source{}, "a", &i32, decos)); ast::type::Struct A( - "A", create(Source{}, members, ast::StructDecorationList{})); + mod->RegisterSymbol("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 9c7ec94948..83d1f618f1 100644 --- a/src/writer/spirv/builder_intrinsic_test.cc +++ b/src/writer/spirv/builder_intrinsic_test.cc @@ -1312,7 +1312,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) { create(Source{}, "a", ty.array(), decos)); auto* s = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s_type("my_struct", s); + ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s); auto* var = Var("b", ast::StorageClass::kPrivate, &s_type); @@ -1354,7 +1354,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) { create(Source{}, "a", ty.array(), decos)); auto* s = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s_type("my_struct", s); + ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s); auto* var = Var("b", ast::StorageClass::kPrivate, &s_type); auto expr = Call("arrayLength", create( @@ -1398,7 +1398,7 @@ TEST_F(IntrinsicBuilderTest, DISABLED_Call_ArrayLength_Ptr) { create(Source{}, "a", ty.array(), decos)); auto* s = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s_type("my_struct", s); + ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "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 638dc462bd..2ed7ffb3f0 100644 --- a/src/writer/spirv/builder_type_test.cc +++ b/src/writer/spirv/builder_type_test.cc @@ -280,7 +280,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) { TEST_F(BuilderTest_Type, GenerateStruct_Empty) { auto* s = create(Source{}, ast::StructMemberList{}, ast::StructDecorationList{}); - ast::type::Struct s_type("S", s); + ast::type::Struct s_type(mod->RegisterSymbol("S"), "S", s); auto id = b.GenerateTypeIfNeeded(&s_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -301,7 +301,7 @@ TEST_F(BuilderTest_Type, GenerateStruct) { members.push_back(create(Source{}, "a", &f32, decos)); auto* s = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s_type("my_struct", s); + ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s); auto id = b.GenerateTypeIfNeeded(&s_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -326,7 +326,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_Decorated) { struct_decos.push_back(create(Source{})); auto* s = create(Source{}, members, struct_decos); - ast::type::Struct s_type("my_struct", s); + ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s); auto id = b.GenerateTypeIfNeeded(&s_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -355,7 +355,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers) { members.push_back(create(Source{}, "b", &f32, b_decos)); auto* s = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s_type("S", s); + ast::type::Struct s_type(mod->RegisterSymbol("S"), "S", s); auto id = b.GenerateTypeIfNeeded(&s_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -392,7 +392,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_NonLayout_Matrix) { create(Source{}, "c", &glsl_mat4x4, empty_c)); auto* s = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s_type("S", s); + ast::type::Struct s_type(mod->RegisterSymbol("S"), "S", s); auto id = b.GenerateTypeIfNeeded(&s_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -438,7 +438,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutMatrix) { create(Source{}, "c", &glsl_mat4x4, c_decos)); auto* s = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s_type("S", s); + ast::type::Struct s_type(mod->RegisterSymbol("S"), "S", s); auto id = b.GenerateTypeIfNeeded(&s_type); ASSERT_FALSE(b.has_error()) << b.error(); @@ -505,7 +505,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutArraysOfMatrix) { create(Source{}, "c", &glsl_mat4x4, c_decos)); auto* s = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s_type("S", s); + ast::type::Struct s_type(mod->RegisterSymbol("S"), "S", s); auto id = b.GenerateTypeIfNeeded(&s_type); ASSERT_FALSE(b.has_error()) << b.error(); diff --git a/src/writer/wgsl/generator_impl_alias_type_test.cc b/src/writer/wgsl/generator_impl_alias_type_test.cc index 6d7fdab6c9..7a4da55299 100644 --- a/src/writer/wgsl/generator_impl_alias_type_test.cc +++ b/src/writer/wgsl/generator_impl_alias_type_test.cc @@ -54,7 +54,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructedType_Struct) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("A", str); + ast::type::Struct s(mod.RegisterSymbol("A"), "A", str); ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s); ASSERT_TRUE(gen.EmitConstructedType(&s)) << gen.error(); @@ -83,7 +83,7 @@ TEST_F(WgslGeneratorImplTest, EmitAlias_ToStruct) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("A", str); + ast::type::Struct s(mod.RegisterSymbol("A"), "A", str); ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s); ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error(); diff --git a/src/writer/wgsl/generator_impl_function_test.cc b/src/writer/wgsl/generator_impl_function_test.cc index 05ef50760f..e47cae54dd 100644 --- a/src/writer/wgsl/generator_impl_function_test.cc +++ b/src/writer/wgsl/generator_impl_function_test.cc @@ -200,7 +200,7 @@ TEST_F(WgslGeneratorImplTest, auto* str = create(Source{}, members, s_decos); - ast::type::Struct s("Data", str); + ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str); ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s); auto* data_var = diff --git a/src/writer/wgsl/generator_impl_type_test.cc b/src/writer/wgsl/generator_impl_type_test.cc index 2377569164..32dbf55f3b 100644 --- a/src/writer/wgsl/generator_impl_type_test.cc +++ b/src/writer/wgsl/generator_impl_type_test.cc @@ -75,7 +75,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_Read) { decos.push_back(&block_deco); ast::Struct str(Source{}, members, decos); - ast::type::Struct s("S", &str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", &str); ast::type::AccessControl a(ast::AccessControl::kReadOnly, &s); @@ -95,7 +95,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_ReadWrite) { decos.push_back(&block_deco); ast::Struct str(Source{}, members, decos); - ast::type::Struct s("S", &str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", &str); ast::type::AccessControl a(ast::AccessControl::kReadWrite, &s); @@ -186,7 +186,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Struct) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); ASSERT_TRUE(gen.EmitType(&s)) << gen.error(); EXPECT_EQ(gen.result(), "S"); @@ -207,7 +207,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_StructDecl) { auto* str = create(Source{}, members, ast::StructDecorationList{}); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error(); EXPECT_EQ(gen.result(), R"(struct S { @@ -235,7 +235,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Struct_WithDecoration) { auto* str = create(Source{}, members, decos); - ast::type::Struct s("S", str); + ast::type::Struct s(mod.RegisterSymbol("S"), "S", str); ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error(); EXPECT_EQ(gen.result(), R"([[block]]