From 3aa226138ea909c46092dbf21b65143828c2f311 Mon Sep 17 00:00:00 2001 From: Antonio Maiorano Date: Mon, 19 Apr 2021 21:31:43 +0000 Subject: [PATCH] Rename type::Struct to type::StructType This is to avoid name conflicts once we move all classes from namespace `type` to `sem`. Bug: tint:724 Change-Id: I23cdec636cb5bcf0bbba03ee7bb7c44252ddade7 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48361 Commit-Queue: Antonio Maiorano Kokoro: Kokoro Reviewed-by: Ben Clayton --- src/ast/module.cc | 4 +- src/inspector/inspector.cc | 6 +- src/inspector/inspector_test.cc | 62 ++++++++++--------- src/program_builder.h | 26 ++++---- src/reader/spirv/parser_impl.cc | 4 +- .../spirv/parser_impl_convert_type_test.cc | 12 ++-- src/reader/wgsl/parser_impl.cc | 4 +- src/reader/wgsl/parser_impl.h | 2 +- .../wgsl/parser_impl_global_decl_test.cc | 16 ++--- .../wgsl/parser_impl_type_alias_test.cc | 6 +- src/resolver/resolver.cc | 28 ++++----- src/resolver/resolver.h | 6 +- src/sem/struct.cc | 2 +- src/sem/struct.h | 8 +-- src/sem/type_mappings.h | 4 +- src/transform/calculate_array_length.cc | 8 +-- src/transform/canonicalize_entry_point_io.cc | 18 +++--- src/transform/decompose_storage_access.cc | 8 +-- src/transform/hlsl.cc | 2 +- src/transform/spirv.cc | 12 ++-- src/type/access_control_type_test.cc | 2 +- src/type/alias_type_test.cc | 2 +- src/type/array_type_test.cc | 2 +- src/type/bool_type_test.cc | 2 +- src/type/depth_texture_type_test.cc | 2 +- src/type/external_texture_type_test.cc | 2 +- src/type/f32_type_test.cc | 2 +- src/type/i32_type_test.cc | 2 +- src/type/matrix_type_test.cc | 2 +- src/type/multisampled_texture_type_test.cc | 2 +- src/type/pointer_type_test.cc | 2 +- src/type/sampled_texture_type_test.cc | 2 +- src/type/sampler_type_test.cc | 2 +- src/type/storage_texture_type_test.cc | 2 +- src/type/struct_type.cc | 16 ++--- src/type/struct_type.h | 10 +-- src/type/struct_type_test.cc | 2 +- src/type/u32_type_test.cc | 2 +- src/type/vector_type_test.cc | 2 +- src/writer/hlsl/generator_impl.cc | 16 ++--- src/writer/hlsl/generator_impl.h | 2 +- src/writer/msl/generator_impl.cc | 16 ++--- src/writer/msl/generator_impl.h | 2 +- src/writer/spirv/builder.cc | 25 ++++---- src/writer/spirv/builder.h | 2 +- src/writer/wgsl/generator_impl.cc | 6 +- src/writer/wgsl/generator_impl.h | 2 +- 47 files changed, 187 insertions(+), 182 deletions(-) diff --git a/src/ast/module.cc b/src/ast/module.cc index 50217c0c3d..c26e6ed7f0 100644 --- a/src/ast/module.cc +++ b/src/ast/module.cc @@ -85,10 +85,10 @@ void Module::to_str(const sem::Info& sem, if (auto* alias = ty->As()) { out << alias->symbol().to_str() << " -> " << alias->type()->type_name() << std::endl; - if (auto* str = alias->type()->As()) { + if (auto* str = alias->type()->As()) { str->impl()->to_str(sem, out, indent); } - } else if (auto* str = ty->As()) { + } else if (auto* str = ty->As()) { out << str->symbol().to_str() << " "; str->impl()->to_str(sem, out, indent); } diff --git a/src/inspector/inspector.cc b/src/inspector/inspector.cc index f532847b95..c9ca62d532 100644 --- a/src/inspector/inspector.cc +++ b/src/inspector/inspector.cc @@ -386,7 +386,7 @@ std::vector Inspector::GetUniformBufferResourceBindings( auto binding_info = ruv.second; auto* unwrapped_type = var->Type()->UnwrapIfNeeded(); - auto* str = unwrapped_type->As(); + auto* str = unwrapped_type->As(); if (str == nullptr) { continue; } @@ -551,7 +551,7 @@ void Inspector::AddEntryPointInOutVariables( auto* unwrapped_type = type->UnwrapAll(); - if (auto* struct_ty = unwrapped_type->As()) { + if (auto* struct_ty = unwrapped_type->As()) { // Recurse into members. for (auto* member : struct_ty->impl()->members()) { AddEntryPointInOutVariables( @@ -606,7 +606,7 @@ std::vector Inspector::GetStorageBufferResourceBindingsImpl( continue; } - auto* str = var->Type()->UnwrapIfNeeded()->As(); + auto* str = var->Type()->UnwrapIfNeeded()->As(); if (!str) { continue; } diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index 62616b7e58..f3ea3110f2 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -62,7 +62,7 @@ class InspectorHelper : public ProgramBuilder { /// Generates a struct that contains user-defined IO members /// @param name the name of the generated struct /// @param inout_vars tuples of {name, loc} that will be the struct members - type::Struct* MakeInOutStruct( + type::StructType* MakeInOutStruct( std::string name, std::vector> inout_vars) { ast::StructMemberList members; @@ -212,9 +212,9 @@ class InspectorHelper : public ProgramBuilder { /// @param member_types a vector of member types /// @param is_block whether or not to decorate as a Block /// @returns a struct type - type::Struct* MakeStructType(const std::string& name, - std::vector member_types, - bool is_block) { + type::StructType* MakeStructType(const std::string& name, + std::vector member_types, + bool is_block) { ast::StructMemberList members; for (auto* type : member_types) { members.push_back(Member(StructMemberName(members.size(), type), type)); @@ -235,8 +235,9 @@ class InspectorHelper : public ProgramBuilder { /// @param name name for the type /// @param member_types a vector of member types /// @returns a struct type that has the layout for an uniform buffer. - type::Struct* MakeUniformBufferType(const std::string& name, - std::vector member_types) { + type::StructType* MakeUniformBufferType( + const std::string& name, + std::vector member_types) { auto* struct_type = MakeStructType(name, member_types, true); return struct_type; } @@ -247,7 +248,7 @@ class InspectorHelper : public ProgramBuilder { /// @returns a tuple {struct type, access control type}, where the struct has /// the layout for a storage buffer, and the control type wraps the /// struct. - std::tuple MakeStorageBufferTypes( + std::tuple MakeStorageBufferTypes( const std::string& name, std::vector member_types) { auto* struct_type = MakeStructType(name, member_types, true); @@ -262,7 +263,7 @@ class InspectorHelper : public ProgramBuilder { /// @returns a tuple {struct type, access control type}, where the struct has /// the layout for a read-only storage buffer, and the control type /// wraps the struct. - std::tuple + std::tuple MakeReadOnlyStorageBufferTypes(const std::string& name, std::vector member_types) { auto* struct_type = MakeStructType(name, member_types, true); @@ -1680,18 +1681,19 @@ TEST_F(InspectorGetResourceBindingsTest, Empty) { } TEST_F(InspectorGetResourceBindingsTest, Simple) { - type::Struct* ub_struct_type = MakeUniformBufferType("ub_type", {ty.i32()}); + type::StructType* ub_struct_type = + MakeUniformBufferType("ub_type", {ty.i32()}); AddUniformBuffer("ub_var", ub_struct_type, 0, 0); MakeStructVariableReferenceBodyFunction("ub_func", "ub_var", {{0, ty.i32()}}); - type::Struct* sb_struct_type; + type::StructType* sb_struct_type; type::AccessControl* sb_control_type; std::tie(sb_struct_type, sb_control_type) = MakeStorageBufferTypes("sb_type", {ty.i32()}); AddStorageBuffer("sb_var", sb_control_type, 1, 0); MakeStructVariableReferenceBodyFunction("sb_func", "sb_var", {{0, ty.i32()}}); - type::Struct* rosb_struct_type; + type::StructType* rosb_struct_type; type::AccessControl* rosb_control_type; std::tie(rosb_struct_type, rosb_control_type) = MakeReadOnlyStorageBufferTypes("rosb_type", {ty.i32()}); @@ -1801,7 +1803,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingEntryPoint) { } TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) { - type::Struct* foo_struct_type = MakeUniformBufferType("foo_type", {ty.i32()}); + type::StructType* foo_struct_type = + MakeUniformBufferType("foo_type", {ty.i32()}); AddUniformBuffer("foo_ub", foo_struct_type, 0, 0); MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub", {{0, ty.i32()}}); @@ -1844,7 +1847,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingBlockDeco) { } TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) { - type::Struct* foo_struct_type = MakeUniformBufferType("foo_type", {ty.i32()}); + type::StructType* foo_struct_type = + MakeUniformBufferType("foo_type", {ty.i32()}); AddUniformBuffer("foo_ub", foo_struct_type, 0, 0); MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub", {{0, ty.i32()}}); @@ -1870,7 +1874,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) { } TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) { - type::Struct* foo_struct_type = + type::StructType* foo_struct_type = MakeUniformBufferType("foo_type", {ty.i32(), ty.u32(), ty.f32()}); AddUniformBuffer("foo_ub", foo_struct_type, 0, 0); @@ -1898,7 +1902,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) { } TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingPadding) { - type::Struct* foo_struct_type = + type::StructType* foo_struct_type = MakeUniformBufferType("foo_type", {ty.vec3()}); AddUniformBuffer("foo_ub", foo_struct_type, 0, 0); @@ -1926,7 +1930,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingPadding) { } TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) { - type::Struct* ub_struct_type = + type::StructType* ub_struct_type = MakeUniformBufferType("ub_type", {ty.i32(), ty.u32(), ty.f32()}); AddUniformBuffer("ub_foo", ub_struct_type, 0, 0); AddUniformBuffer("ub_bar", ub_struct_type, 0, 1); @@ -1985,7 +1989,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) { // TODO(bclayton) - This is not a legal structure layout for uniform buffer // usage. Once crbug.com/tint/628 is implemented, this will fail validation // and will need to be fixed. - type::Struct* foo_struct_type = + type::StructType* foo_struct_type = MakeUniformBufferType("foo_type", {ty.i32(), u32_array_type(4)}); AddUniformBuffer("foo_ub", foo_struct_type, 0, 0); @@ -2012,7 +2016,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) { - type::Struct* foo_struct_type; + type::StructType* foo_struct_type; type::AccessControl* foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes("foo_type", {ty.i32()}); @@ -2041,7 +2045,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) { - type::Struct* foo_struct_type; + type::StructType* foo_struct_type; type::AccessControl* foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes("foo_type", {ty.i32(), ty.u32(), ty.f32()}); @@ -2071,7 +2075,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) { - type::Struct* sb_struct_type; + type::StructType* sb_struct_type; type::AccessControl* sb_control_type; std::tie(sb_struct_type, sb_control_type) = MakeStorageBufferTypes("sb_type", {ty.i32(), ty.u32(), ty.f32()}); @@ -2132,7 +2136,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) { - type::Struct* foo_struct_type; + type::StructType* foo_struct_type; type::AccessControl* foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes("foo_type", {ty.i32(), u32_array_type(4)}); @@ -2161,7 +2165,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) { - type::Struct* foo_struct_type; + type::StructType* foo_struct_type; type::AccessControl* foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes("foo_type", {ty.i32(), u32_array_type(0)}); @@ -2190,7 +2194,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingPadding) { - type::Struct* foo_struct_type; + type::StructType* foo_struct_type; type::AccessControl* foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes("foo_type", {ty.vec3()}); @@ -2220,7 +2224,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingPadding) { } TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) { - type::Struct* foo_struct_type; + type::StructType* foo_struct_type; type::AccessControl* foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes("foo_type", {ty.i32()}); @@ -2242,7 +2246,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) { } TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) { - type::Struct* foo_struct_type; + type::StructType* foo_struct_type; type::AccessControl* foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes("foo_type", {ty.i32()}); @@ -2272,7 +2276,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) { TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, MultipleStorageBuffers) { - type::Struct* sb_struct_type; + type::StructType* sb_struct_type; type::AccessControl* sb_control_type; std::tie(sb_struct_type, sb_control_type) = MakeReadOnlyStorageBufferTypes("sb_type", {ty.i32(), ty.u32(), ty.f32()}); @@ -2333,7 +2337,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, } TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) { - type::Struct* foo_struct_type; + type::StructType* foo_struct_type; type::AccessControl* foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes("foo_type", {ty.i32(), u32_array_type(4)}); @@ -2363,7 +2367,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) { TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingRuntimeArray) { - type::Struct* foo_struct_type; + type::StructType* foo_struct_type; type::AccessControl* foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes("foo_type", {ty.i32(), u32_array_type(0)}); @@ -2392,7 +2396,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, } TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) { - type::Struct* foo_struct_type; + type::StructType* foo_struct_type; type::AccessControl* foo_control_type; std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes("foo_type", {ty.i32()}); diff --git a/src/program_builder.h b/src/program_builder.h index a930fd52bd..e1b08636b9 100644 --- a/src/program_builder.h +++ b/src/program_builder.h @@ -561,8 +561,8 @@ class ProgramBuilder { /// @param impl the struct implementation /// @returns a struct pointer template - type::Struct* struct_(NAME&& name, ast::Struct* impl) const { - return builder->create( + type::StructType* struct_(NAME&& name, ast::Struct* impl) const { + return builder->create( builder->Sym(std::forward(name)), impl); } @@ -1174,18 +1174,18 @@ class ProgramBuilder { return create(Expr(std::forward(val))); } - /// Creates a ast::Struct and type::Struct, registering the type::Struct with - /// the AST().ConstructedTypes(). + /// Creates a ast::Struct and type::StructType, registering the + /// type::StructType with the AST().ConstructedTypes(). /// @param source the source information /// @param name the struct name /// @param members the struct members /// @param decorations the optional struct decorations /// @returns the struct type template - type::Struct* Structure(const Source& source, - NAME&& name, - ast::StructMemberList members, - ast::DecorationList decorations = {}) { + type::StructType* Structure(const Source& source, + NAME&& name, + ast::StructMemberList members, + ast::DecorationList decorations = {}) { auto* impl = create(source, std::move(members), std::move(decorations)); auto* type = ty.struct_(Sym(std::forward(name)), impl); @@ -1193,16 +1193,16 @@ class ProgramBuilder { return type; } - /// Creates a ast::Struct and type::Struct, registering the type::Struct with - /// the AST().ConstructedTypes(). + /// Creates a ast::Struct and type::StructType, registering the + /// type::StructType with the AST().ConstructedTypes(). /// @param name the struct name /// @param members the struct members /// @param decorations the optional struct decorations /// @returns the struct type template - type::Struct* Structure(NAME&& name, - ast::StructMemberList members, - ast::DecorationList decorations = {}) { + type::StructType* Structure(NAME&& name, + ast::StructMemberList members, + ast::DecorationList decorations = {}) { auto* impl = create(std::move(members), std::move(decorations)); auto* type = ty.struct_(Sym(std::forward(name)), impl); diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc index 7fc36ee842..8a17c3cf50 100644 --- a/src/reader/spirv/parser_impl.cc +++ b/src/reader/spirv/parser_impl.cc @@ -947,7 +947,7 @@ type::Type* ParserImpl::ConvertType( namer_.SuggestSanitizedName(type_id, "S"); auto name = namer_.GetName(type_id); - auto* result = builder_.create( + auto* result = builder_.create( builder_.Symbols().Register(name), ast_struct); id_to_type_[type_id] = result; if (num_non_writable_members == members.size()) { @@ -1501,7 +1501,7 @@ ast::Expression* ParserImpl::MakeNullValue(type::Type* type) { return create(Source{}, original_type, std::move(ast_components)); } - if (auto* struct_ty = type->As()) { + if (auto* struct_ty = type->As()) { ast::ExpressionList ast_components; for (auto* member : struct_ty->impl()->members()) { ast_components.emplace_back(MakeNullValue(member->type())); diff --git a/src/reader/spirv/parser_impl_convert_type_test.cc b/src/reader/spirv/parser_impl_convert_type_test.cc index b1ccd149cf..17600dda73 100644 --- a/src/reader/spirv/parser_impl_convert_type_test.cc +++ b/src/reader/spirv/parser_impl_convert_type_test.cc @@ -550,10 +550,10 @@ TEST_F(SpvParserTest, ConvertType_StructTwoMembers) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); Program program = p->program(); - EXPECT_THAT(program.str(type->As()->impl()), Eq(R"(Struct{ + EXPECT_THAT(program.str(type->As()->impl()), Eq(R"(Struct{ StructMember{field0: __u32} StructMember{field1: __f32} } @@ -571,10 +571,10 @@ TEST_F(SpvParserTest, ConvertType_StructWithBlockDecoration) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); Program program = p->program(); - EXPECT_THAT(program.str(type->As()->impl()), Eq(R"(Struct{ + EXPECT_THAT(program.str(type->As()->impl()), Eq(R"(Struct{ [[block]] StructMember{field0: __u32} } @@ -596,10 +596,10 @@ TEST_F(SpvParserTest, ConvertType_StructWithMemberDecorations) { auto* type = p->ConvertType(10); ASSERT_NE(type, nullptr); - EXPECT_TRUE(type->Is()); + EXPECT_TRUE(type->Is()); Program program = p->program(); - EXPECT_THAT(program.str(type->As()->impl()), Eq(R"(Struct{ + EXPECT_THAT(program.str(type->As()->impl()), Eq(R"(Struct{ StructMember{[[ offset 0 ]] field0: __f32} StructMember{[[ offset 8 ]] field1: __vec_2__f32} StructMember{[[ offset 16 ]] field2: __mat_2_2__f32} diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc index f7ee20fb59..95514e8a54 100644 --- a/src/reader/wgsl/parser_impl.cc +++ b/src/reader/wgsl/parser_impl.cc @@ -1121,7 +1121,7 @@ Expect ParserImpl::expect_storage_class( // struct_decl // : struct_decoration_decl* STRUCT IDENT struct_body_decl -Maybe ParserImpl::struct_decl(ast::DecorationList& decos) { +Maybe ParserImpl::struct_decl(ast::DecorationList& decos) { auto t = peek(); auto source = t.source(); @@ -1136,7 +1136,7 @@ Maybe ParserImpl::struct_decl(ast::DecorationList& decos) { if (body.errored) return Failure::kErrored; - return create( + return create( builder_.Symbols().Register(name.value), create(source, std::move(body.value), std::move(decos))); } diff --git a/src/reader/wgsl/parser_impl.h b/src/reader/wgsl/parser_impl.h index 7f4929b96a..ba756fd0cd 100644 --- a/src/reader/wgsl/parser_impl.h +++ b/src/reader/wgsl/parser_impl.h @@ -379,7 +379,7 @@ class ParserImpl { /// `struct_decoration_decl*` provided as `decos`. /// @returns the struct type or nullptr on error /// @param decos the list of decorations for the struct declaration. - Maybe struct_decl(ast::DecorationList& decos); + Maybe struct_decl(ast::DecorationList& decos); /// Parses a `struct_body_decl` grammar element, erroring on parse failure. /// @returns the struct members Expect expect_struct_body_decl(); diff --git a/src/reader/wgsl/parser_impl_global_decl_test.cc b/src/reader/wgsl/parser_impl_global_decl_test.cc index 1bbb9bd151..923828ac79 100644 --- a/src/reader/wgsl/parser_impl_global_decl_test.cc +++ b/src/reader/wgsl/parser_impl_global_decl_test.cc @@ -102,8 +102,8 @@ type B = A;)"); auto program = p->program(); ASSERT_EQ(program.AST().ConstructedTypes().size(), 2u); - ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is()); - auto* str = program.AST().ConstructedTypes()[0]->As(); + ASSERT_TRUE(program.AST().ConstructedTypes()[0]->Is()); + auto* str = program.AST().ConstructedTypes()[0]->As(); EXPECT_EQ(str->symbol(), program.Symbols().Get("A")); ASSERT_TRUE(program.AST().ConstructedTypes()[1]->Is()); @@ -165,9 +165,9 @@ TEST_F(ParserImplTest, GlobalDecl_ParsesStruct) { auto* t = program.AST().ConstructedTypes()[0]; ASSERT_NE(t, nullptr); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* str = t->As(); + auto* str = t->As(); EXPECT_EQ(str->symbol(), program.Symbols().Get("A")); EXPECT_EQ(str->impl()->members().size(), 2u); } @@ -183,9 +183,9 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithStride) { auto* t = program.AST().ConstructedTypes()[0]; ASSERT_NE(t, nullptr); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* str = t->As(); + auto* str = t->As(); EXPECT_EQ(str->symbol(), program.Symbols().Get("A")); EXPECT_EQ(str->impl()->members().size(), 1u); EXPECT_FALSE(str->IsBlockDecorated()); @@ -210,9 +210,9 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithDecoration) { auto* t = program.AST().ConstructedTypes()[0]; ASSERT_NE(t, nullptr); - ASSERT_TRUE(t->Is()); + ASSERT_TRUE(t->Is()); - auto* str = t->As(); + auto* str = t->As(); EXPECT_EQ(str->symbol(), program.Symbols().Get("A")); EXPECT_EQ(str->impl()->members().size(), 1u); EXPECT_TRUE(str->IsBlockDecorated()); diff --git a/src/reader/wgsl/parser_impl_type_alias_test.cc b/src/reader/wgsl/parser_impl_type_alias_test.cc index 17e28192e6..04a712db84 100644 --- a/src/reader/wgsl/parser_impl_type_alias_test.cc +++ b/src/reader/wgsl/parser_impl_type_alias_test.cc @@ -38,7 +38,7 @@ TEST_F(ParserImplTest, TypeDecl_ParsesType) { TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) { auto p = parser("type a = B"); - type::Struct str(p->builder().Symbols().Get("B"), {}); + type::StructType str(p->builder().Symbols().Get("B"), {}); p->register_constructed("B", &str); auto t = p->type_alias(); @@ -49,9 +49,9 @@ TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) { ASSERT_TRUE(t->Is()); auto* alias = t->As(); EXPECT_EQ(p->builder().Symbols().NameFor(alias->symbol()), "a"); - ASSERT_TRUE(alias->type()->Is()); + ASSERT_TRUE(alias->type()->Is()); - auto* s = alias->type()->As(); + auto* s = alias->type()->As(); EXPECT_EQ(s->symbol(), p->builder().Symbols().Get("B")); EXPECT_EQ(s->symbol(), p->builder().Symbols().Get("B")); } diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc index ed826d7c04..75b622445e 100644 --- a/src/resolver/resolver.cc +++ b/src/resolver/resolver.cc @@ -126,7 +126,7 @@ bool Resolver::IsStorable(type::Type* type) { if (type::ArrayType* arr = type->As()) { return IsStorable(arr->type()); } - if (type::Struct* str = type->As()) { + if (type::StructType* str = type->As()) { for (const auto* member : str->impl()->members()) { if (!IsStorable(member->type())) { return false; @@ -152,7 +152,7 @@ bool Resolver::IsHostShareable(type::Type* type) { if (auto* arr = type->As()) { return IsHostShareable(arr->type()); } - if (auto* str = type->As()) { + if (auto* str = type->As()) { for (auto* member : str->impl()->members()) { if (!IsHostShareable(member->type())) { return false; @@ -224,7 +224,7 @@ bool Resolver::ResolveInternal() { bool Resolver::Type(type::Type* ty) { ty = ty->UnwrapAliasIfNeeded(); - if (auto* str = ty->As()) { + if (auto* str = ty->As()) { if (!Structure(str)) { return false; } @@ -331,7 +331,7 @@ bool Resolver::ValidateGlobalVariable(const VariableInfo* info) { // satisfying the storage class constraints. auto* access = info->type->As(); - auto* str = access ? access->type()->As() : nullptr; + auto* str = access ? access->type()->As() : nullptr; if (!str) { diagnostics_.add_error( "variables declared in the storage class must be of an " @@ -519,7 +519,7 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func) { } // Check that we saw a pipeline IO attribute iff we need one. - if (Canonical(ty)->Is()) { + if (Canonical(ty)->Is()) { if (pipeline_io_attribute) { diagnostics_.add_error( "entry point IO attributes must not be used on structure " + @@ -555,12 +555,12 @@ bool Resolver::ValidateEntryPoint(const ast::Function* func) { return false; } - if (auto* struct_ty = Canonical(ty)->As()) { + if (auto* struct_ty = Canonical(ty)->As()) { // Validate the decorations for each struct members, and also check for // invalid member types. for (auto* member : struct_ty->impl()->members()) { auto* member_ty = Canonical(member->type()); - if (member_ty->Is()) { + if (member_ty->Is()) { diagnostics_.add_error( "entry point IO types cannot contain nested structures", member->source()); @@ -646,7 +646,7 @@ bool Resolver::Function(ast::Function* func) { return false; } - if (auto* str = param_info->type->As()) { + if (auto* str = param_info->type->As()) { auto* info = Structure(str); if (!info) { return false; @@ -670,7 +670,7 @@ bool Resolver::Function(ast::Function* func) { } } - if (auto* str = Canonical(func->return_type())->As()) { + if (auto* str = Canonical(func->return_type())->As()) { if (!ApplyStorageClassUsageToType(ast::StorageClass::kNone, str, func->source())) { diagnostics_.add_note("while instantiating return type for " + @@ -1296,7 +1296,7 @@ bool Resolver::MemberAccessor(ast::MemberAccessorExpression* expr) { type::Type* ret = nullptr; std::vector swizzle; - if (auto* ty = data_type->As()) { + if (auto* ty = data_type->As()) { Mark(expr->member()); auto symbol = expr->member()->symbol(); auto* str = Structure(ty); @@ -1909,7 +1909,7 @@ bool Resolver::DefaultAlignAndSize(type::Type* ty, align = vector_align[mat->rows()]; size = vector_align[mat->rows()] * mat->columns(); return true; - } else if (auto* s = cty->As()) { + } else if (auto* s = cty->As()) { if (auto* si = Structure(s)) { align = si->align; size = si->size; @@ -1998,7 +1998,7 @@ const sem::Array* Resolver::Array(type::ArrayType* arr, const Source& source) { return create_semantic(implicit_stride); } -bool Resolver::ValidateStructure(const type::Struct* st) { +bool Resolver::ValidateStructure(const type::StructType* st) { for (auto* member : st->impl()->members()) { if (auto* r = member->type()->UnwrapAll()->As()) { if (r->IsRuntimeArray()) { @@ -2053,7 +2053,7 @@ bool Resolver::ValidateStructure(const type::Struct* st) { return true; } -Resolver::StructInfo* Resolver::Structure(type::Struct* str) { +Resolver::StructInfo* Resolver::Structure(type::StructType* str) { auto info_it = struct_info_.find(str); if (info_it != struct_info_.end()) { // StructInfo already resolved for this structure type @@ -2369,7 +2369,7 @@ bool Resolver::ApplyStorageClassUsageToType(ast::StorageClass sc, const Source& usage) { ty = ty->UnwrapIfNeeded(); - if (auto* str = ty->As()) { + if (auto* str = ty->As()) { auto* info = Structure(str); if (!info) { return false; diff --git a/src/resolver/resolver.h b/src/resolver/resolver.h index 067941e9c3..740ebfaf53 100644 --- a/src/resolver/resolver.h +++ b/src/resolver/resolver.h @@ -245,7 +245,7 @@ class Resolver { const ast::ExpressionList& values); bool ValidateParameter(const ast::Variable* param); bool ValidateReturn(const ast::ReturnStatement* ret); - bool ValidateStructure(const type::Struct* st); + bool ValidateStructure(const type::StructType* st); bool ValidateSwitch(const ast::SwitchStatement* s); bool ValidateVariable(const ast::Variable* param); bool ValidateVectorConstructor(const type::Vector* vec_type, @@ -260,7 +260,7 @@ class Resolver { /// @returns the StructInfo for the structure `str`, building it if it hasn't /// been constructed already. If an error is raised, nullptr is returned. - StructInfo* Structure(type::Struct* str); + StructInfo* Structure(type::StructType* str); /// @returns the VariableInfo for the variable `var`, building it if it hasn't /// been constructed already. If an error is raised, nullptr is returned. @@ -330,7 +330,7 @@ class Resolver { std::unordered_map variable_to_info_; std::unordered_map function_calls_; std::unordered_map expr_info_; - std::unordered_map struct_info_; + std::unordered_map struct_info_; std::unordered_map type_to_canonical_; std::unordered_set marked_; FunctionInfo* current_function_ = nullptr; diff --git a/src/sem/struct.cc b/src/sem/struct.cc index e4d0c3cfd7..4426800859 100644 --- a/src/sem/struct.cc +++ b/src/sem/struct.cc @@ -23,7 +23,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::sem::StructMember); namespace tint { namespace sem { -Struct::Struct(type::Struct* type, +Struct::Struct(type::StructType* type, StructMemberList members, uint32_t align, uint32_t size, diff --git a/src/sem/struct.h b/src/sem/struct.h index 8d3c93dd48..d4119f4b92 100644 --- a/src/sem/struct.h +++ b/src/sem/struct.h @@ -31,7 +31,7 @@ namespace ast { class StructMember; } // namespace ast namespace type { -class Struct; +class StructType; } // namespace type namespace sem { @@ -63,7 +63,7 @@ class Struct : public Castable { /// alignment padding /// @param storage_class_usage a set of all the storage class usages /// @param pipeline_stage_uses a set of all the pipeline stage uses - Struct(type::Struct* type, + Struct(type::StructType* type, StructMemberList members, uint32_t align, uint32_t size, @@ -75,7 +75,7 @@ class Struct : public Castable { ~Struct() override; /// @returns the structure type - type::Struct* Type() const { return type_; } + type::StructType* Type() const { return type_; } /// @returns the members of the structure const StructMemberList& Members() const { return members_; } @@ -128,7 +128,7 @@ class Struct : public Castable { } private: - type::Struct* const type_; + type::StructType* const type_; StructMemberList const members_; uint32_t const align_; uint32_t const size_; diff --git a/src/sem/type_mappings.h b/src/sem/type_mappings.h index b92bc4c018..fa4573fe08 100644 --- a/src/sem/type_mappings.h +++ b/src/sem/type_mappings.h @@ -31,7 +31,7 @@ class Variable; } // namespace ast namespace type { class ArrayType; -class Struct; +class StructType; } // namespace type namespace sem { @@ -59,7 +59,7 @@ struct TypeMappings { Function* operator()(ast::Function*); MemberAccessorExpression* operator()(ast::MemberAccessorExpression*); Statement* operator()(ast::Statement*); - Struct* operator()(type::Struct*); + Struct* operator()(type::StructType*); StructMember* operator()(ast::StructMember*); Variable* operator()(ast::Variable*); //! @endcond diff --git a/src/transform/calculate_array_length.cc b/src/transform/calculate_array_length.cc index ae1d054b74..c60a99dc17 100644 --- a/src/transform/calculate_array_length.cc +++ b/src/transform/calculate_array_length.cc @@ -77,8 +77,8 @@ Output CalculateArrayLength::Run(const Program* in, const DataMap&) { // get_buffer_size_intrinsic() emits the function decorated with // BufferSizeIntrinsic that is transformed by the HLSL writer into a call to // [RW]ByteAddressBuffer.GetDimensions(). - std::unordered_map buffer_size_intrinsics; - auto get_buffer_size_intrinsic = [&](type::Struct* buffer_type) { + std::unordered_map buffer_size_intrinsics; + auto get_buffer_size_intrinsic = [&](type::StructType* buffer_type) { return utils::GetOrCreate(buffer_size_intrinsics, buffer_type, [&] { auto name = ctx.dst->Symbols().New(); auto* func = ctx.dst->create( @@ -138,7 +138,7 @@ Output CalculateArrayLength::Run(const Program* in, const DataMap&) { auto* storage_buffer_expr = accessor->structure(); auto* storage_buffer_sem = sem.Get(storage_buffer_expr); auto* storage_buffer_type = - storage_buffer_sem->Type()->UnwrapAll()->As(); + storage_buffer_sem->Type()->UnwrapAll()->As(); // Generate BufferSizeIntrinsic for this storage type if we haven't // already @@ -146,7 +146,7 @@ Output CalculateArrayLength::Run(const Program* in, const DataMap&) { if (!storage_buffer_type) { TINT_ICE(ctx.dst->Diagnostics()) - << "arrayLength(X.Y) expected X to be type::Struct, got " + << "arrayLength(X.Y) expected X to be type::StructType, got " << storage_buffer_type->FriendlyName(ctx.src->Symbols()); break; } diff --git a/src/transform/canonicalize_entry_point_io.cc b/src/transform/canonicalize_entry_point_io.cc index 38f7d6868f..3066d239ae 100644 --- a/src/transform/canonicalize_entry_point_io.cc +++ b/src/transform/canonicalize_entry_point_io.cc @@ -66,7 +66,7 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) { // Strip entry point IO decorations from struct declarations. // TODO(jrprice): This code is duplicated with the SPIR-V transform. for (auto* ty : ctx.src->AST().ConstructedTypes()) { - if (auto* struct_ty = ty->As()) { + if (auto* struct_ty = ty->As()) { // Build new list of struct members without entry point IO decorations. ast::StructMemberList new_struct_members; for (auto* member : struct_ty->impl()->members()) { @@ -81,7 +81,7 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) { } // Redeclare the struct. - auto* new_struct = ctx.dst->create( + auto* new_struct = ctx.dst->create( ctx.Clone(struct_ty->symbol()), ctx.dst->create( new_struct_members, ctx.Clone(struct_ty->impl()->decorations()))); @@ -107,11 +107,11 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) { std::function func_const_initializer; - if (auto* struct_ty = param_ty->As()) { + if (auto* struct_ty = param_ty->As()) { // Pull out all struct members and build initializer list. std::vector member_names; for (auto* member : struct_ty->impl()->members()) { - if (member->type()->UnwrapAll()->Is()) { + if (member->type()->UnwrapAll()->Is()) { TINT_ICE(ctx.dst->Diagnostics()) << "nested pipeline IO struct"; } @@ -174,7 +174,7 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) { StructMemberComparator); // Create the new struct type. - auto* in_struct = ctx.dst->create( + auto* in_struct = ctx.dst->create( ctx.dst->Symbols().New(), ctx.dst->create(new_struct_members, ast::DecorationList{})); @@ -193,10 +193,10 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) { } else { ast::StructMemberList new_struct_members; - if (auto* struct_ty = ret_type->As()) { + if (auto* struct_ty = ret_type->As()) { // Rebuild struct with only the entry point IO attributes. for (auto* member : struct_ty->impl()->members()) { - if (member->type()->UnwrapAll()->Is()) { + if (member->type()->UnwrapAll()->Is()) { TINT_ICE(ctx.dst->Diagnostics()) << "nested pipeline IO struct"; } @@ -220,7 +220,7 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) { StructMemberComparator); // Create the new struct type. - auto* out_struct = ctx.dst->create( + auto* out_struct = ctx.dst->create( ctx.dst->Symbols().New(), ctx.dst->create(new_struct_members, ast::DecorationList{})); @@ -237,7 +237,7 @@ Output CanonicalizeEntryPointIO::Run(const Program* in, const DataMap&) { }; ast::ExpressionList ret_values; - if (ret_type->Is()) { + if (ret_type->Is()) { if (!ret->value()->Is()) { // Create a const to hold the return value expression to avoid // re-evaluating it multiple times. diff --git a/src/transform/decompose_storage_access.cc b/src/transform/decompose_storage_access.cc index 002d32f41e..0ae2587d54 100644 --- a/src/transform/decompose_storage_access.cc +++ b/src/transform/decompose_storage_access.cc @@ -341,7 +341,7 @@ type::Type* ConstructedTypeOf(type::Type* ty) { if (auto* alias = ty->As()) { return alias; } - if (auto* str = ty->As()) { + if (auto* str = ty->As()) { return str; } // Not a constructed type @@ -438,7 +438,7 @@ struct State { ctx.dst->Add("offset", i * MatrixColumnStride(mat_ty)); values.emplace_back(ctx.dst->Call(load, "buffer", offset)); } - } else if (auto* str_ty = el_ty->As()) { + } else if (auto* str_ty = el_ty->As()) { auto& sem = ctx.src->Sem(); auto* str = sem.Get(str_ty); for (auto* member : str->Members()) { @@ -505,7 +505,7 @@ struct State { auto* call = ctx.dst->Call(store, "buffer", offset, access); body.emplace_back(ctx.dst->create(call)); } - } else if (auto* str_ty = el_ty->As()) { + } else if (auto* str_ty = el_ty->As()) { auto& sem = ctx.src->Sem(); auto* str = sem.Get(str_ty); for (auto* member : str->Members()) { @@ -660,7 +660,7 @@ Output DecomposeStorageAccess::Run(const Program* in, const DataMap&) { } } else { if (auto access = state.TakeAccess(accessor->structure())) { - auto* str_ty = access.type->As(); + auto* str_ty = access.type->As(); auto* member = sem.Get(str_ty)->FindMember(accessor->member()->symbol()); auto offset = member->Offset(); diff --git a/src/transform/hlsl.cc b/src/transform/hlsl.cc index 6fa55dc443..a1d7dbfac7 100644 --- a/src/transform/hlsl.cc +++ b/src/transform/hlsl.cc @@ -96,7 +96,7 @@ void Hlsl::PromoteInitializersToConstVar(CloneContext& ctx) const { } auto* src_ty = src_sem_expr->Type(); - if (src_ty->IsAnyOf()) { + if (src_ty->IsAnyOf()) { // Create a new symbol for the constant auto dst_symbol = ctx.dst->Symbols().New(); // Clone the type diff --git a/src/transform/spirv.cc b/src/transform/spirv.cc index 0077198763..b8c44e6fc5 100644 --- a/src/transform/spirv.cc +++ b/src/transform/spirv.cc @@ -111,7 +111,7 @@ void Spirv::HandleEntryPointIOTypes(CloneContext& ctx) const { // Strip entry point IO decorations from struct declarations. for (auto* ty : ctx.src->AST().ConstructedTypes()) { - if (auto* struct_ty = ty->As()) { + if (auto* struct_ty = ty->As()) { // Build new list of struct members without entry point IO decorations. ast::StructMemberList new_struct_members; for (auto* member : struct_ty->impl()->members()) { @@ -126,7 +126,7 @@ void Spirv::HandleEntryPointIOTypes(CloneContext& ctx) const { } // Redeclare the struct. - auto* new_struct = ctx.dst->create( + auto* new_struct = ctx.dst->create( ctx.Clone(struct_ty->symbol()), ctx.dst->create( new_struct_members, ctx.Clone(struct_ty->impl()->decorations()))); @@ -255,7 +255,7 @@ Symbol Spirv::HoistToInputVariables( type::Type* ty, type::Type* declared_ty, const ast::DecorationList& decorations) const { - if (!ty->Is()) { + if (!ty->Is()) { // Base case: create a global variable and return. ast::DecorationList new_decorations = RemoveDecorations(&ctx, decorations, [](const ast::Decoration* deco) { @@ -272,7 +272,7 @@ Symbol Spirv::HoistToInputVariables( // Recurse into struct members and build the initializer list. std::vector init_value_names; - auto* struct_ty = ty->As(); + auto* struct_ty = ty->As(); for (auto* member : struct_ty->impl()->members()) { auto member_var = HoistToInputVariables( ctx, func, member->type(), member->type(), member->decorations()); @@ -308,7 +308,7 @@ void Spirv::HoistToOutputVariables(CloneContext& ctx, Symbol store_value, ast::StatementList& stores) const { // Base case. - if (!ty->Is()) { + if (!ty->Is()) { // Create a global variable. ast::DecorationList new_decorations = RemoveDecorations(&ctx, decorations, [](const ast::Decoration* deco) { @@ -332,7 +332,7 @@ void Spirv::HoistToOutputVariables(CloneContext& ctx, } // Recurse into struct members. - auto* struct_ty = ty->As(); + auto* struct_ty = ty->As(); for (auto* member : struct_ty->impl()->members()) { member_accesses.push_back(ctx.Clone(member->symbol())); HoistToOutputVariables(ctx, func, member->type(), member->type(), diff --git a/src/type/access_control_type_test.cc b/src/type/access_control_type_test.cc index 2ce685628e..b8fd5aaf8c 100644 --- a/src/type/access_control_type_test.cc +++ b/src/type/access_control_type_test.cc @@ -44,7 +44,7 @@ TEST_F(AccessControlTest, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/alias_type_test.cc b/src/type/alias_type_test.cc index b9f5c2b7cb..b9a8f893d0 100644 --- a/src/type/alias_type_test.cc +++ b/src/type/alias_type_test.cc @@ -40,7 +40,7 @@ TEST_F(AliasTest, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/array_type_test.cc b/src/type/array_type_test.cc index 8986d104ee..f45f989e78 100644 --- a/src/type/array_type_test.cc +++ b/src/type/array_type_test.cc @@ -54,7 +54,7 @@ TEST_F(ArrayTest, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/bool_type_test.cc b/src/type/bool_type_test.cc index bd96693a8f..077565730b 100644 --- a/src/type/bool_type_test.cc +++ b/src/type/bool_type_test.cc @@ -34,7 +34,7 @@ TEST_F(BoolTest, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/depth_texture_type_test.cc b/src/type/depth_texture_type_test.cc index 10364c0623..eef75d571e 100644 --- a/src/type/depth_texture_type_test.cc +++ b/src/type/depth_texture_type_test.cc @@ -39,7 +39,7 @@ TEST_F(DepthTextureTest, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/external_texture_type_test.cc b/src/type/external_texture_type_test.cc index 1129c9262d..7c73d62109 100644 --- a/src/type/external_texture_type_test.cc +++ b/src/type/external_texture_type_test.cc @@ -40,7 +40,7 @@ TEST_F(ExternalTextureTest, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/f32_type_test.cc b/src/type/f32_type_test.cc index 23686a4807..a1b89d4eb8 100644 --- a/src/type/f32_type_test.cc +++ b/src/type/f32_type_test.cc @@ -34,7 +34,7 @@ TEST_F(F32Test, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/i32_type_test.cc b/src/type/i32_type_test.cc index 9170155f9e..8def688936 100644 --- a/src/type/i32_type_test.cc +++ b/src/type/i32_type_test.cc @@ -34,7 +34,7 @@ TEST_F(I32Test, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/matrix_type_test.cc b/src/type/matrix_type_test.cc index 40c7d5c1f1..92c2aaf059 100644 --- a/src/type/matrix_type_test.cc +++ b/src/type/matrix_type_test.cc @@ -43,7 +43,7 @@ TEST_F(MatrixTest, Is) { EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/multisampled_texture_type_test.cc b/src/type/multisampled_texture_type_test.cc index bcafafc712..f18c9bf97b 100644 --- a/src/type/multisampled_texture_type_test.cc +++ b/src/type/multisampled_texture_type_test.cc @@ -40,7 +40,7 @@ TEST_F(MultisampledTextureTest, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/pointer_type_test.cc b/src/type/pointer_type_test.cc index 65c517853a..ec8d062340 100644 --- a/src/type/pointer_type_test.cc +++ b/src/type/pointer_type_test.cc @@ -42,7 +42,7 @@ TEST_F(PointerTest, Is) { EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/sampled_texture_type_test.cc b/src/type/sampled_texture_type_test.cc index bfbaff8821..f7e2751e5b 100644 --- a/src/type/sampled_texture_type_test.cc +++ b/src/type/sampled_texture_type_test.cc @@ -39,7 +39,7 @@ TEST_F(SampledTextureTest, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/sampler_type_test.cc b/src/type/sampler_type_test.cc index fb6ccdf3dc..b39f67572c 100644 --- a/src/type/sampler_type_test.cc +++ b/src/type/sampler_type_test.cc @@ -45,7 +45,7 @@ TEST_F(SamplerTest, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/storage_texture_type_test.cc b/src/type/storage_texture_type_test.cc index 4dee89c960..6931059063 100644 --- a/src/type/storage_texture_type_test.cc +++ b/src/type/storage_texture_type_test.cc @@ -41,7 +41,7 @@ TEST_F(StorageTextureTest, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/struct_type.cc b/src/type/struct_type.cc index 37e78857ce..f35ff863ff 100644 --- a/src/type/struct_type.cc +++ b/src/type/struct_type.cc @@ -18,31 +18,31 @@ #include "src/program_builder.h" -TINT_INSTANTIATE_TYPEINFO(tint::type::Struct); +TINT_INSTANTIATE_TYPEINFO(tint::type::StructType); namespace tint { namespace type { -Struct::Struct(const Symbol& sym, ast::Struct* impl) +StructType::StructType(const Symbol& sym, ast::Struct* impl) : symbol_(sym), struct_(impl) {} -Struct::Struct(Struct&&) = default; +StructType::StructType(StructType&&) = default; -Struct::~Struct() = default; +StructType::~StructType() = default; -std::string Struct::type_name() const { +std::string StructType::type_name() const { return "__struct_" + symbol_.to_str(); } -std::string Struct::FriendlyName(const SymbolTable& symbols) const { +std::string StructType::FriendlyName(const SymbolTable& symbols) const { return symbols.NameFor(symbol_); } -Struct* Struct::Clone(CloneContext* ctx) const { +StructType* StructType::Clone(CloneContext* ctx) const { // Clone arguments outside of create() call to have deterministic ordering auto sym = ctx->Clone(symbol()); auto* str = ctx->Clone(impl()); - return ctx->dst->create(sym, str); + return ctx->dst->create(sym, str); } } // namespace type diff --git a/src/type/struct_type.h b/src/type/struct_type.h index 9a9487752d..4d9d8d27ba 100644 --- a/src/type/struct_type.h +++ b/src/type/struct_type.h @@ -24,15 +24,15 @@ namespace tint { namespace type { /// A structure type -class Struct : public Castable { +class StructType : public Castable { public: /// Constructor /// @param sym the symbol representing the struct /// @param impl the struct data - Struct(const Symbol& sym, ast::Struct* impl); + StructType(const Symbol& sym, ast::Struct* impl); /// Move constructor - Struct(Struct&&); - ~Struct() override; + StructType(StructType&&); + ~StructType() override; /// @returns the struct symbol const Symbol& symbol() const { return symbol_; } @@ -54,7 +54,7 @@ class Struct : public Castable { /// Clones this type and all transitive types using the `CloneContext` `ctx`. /// @param ctx the clone context /// @return the newly cloned type - Struct* Clone(CloneContext* ctx) const override; + StructType* Clone(CloneContext* ctx) const override; private: Symbol const symbol_; diff --git a/src/type/struct_type_test.cc b/src/type/struct_type_test.cc index c90bf4803a..34cafbfb39 100644 --- a/src/type/struct_type_test.cc +++ b/src/type/struct_type_test.cc @@ -44,7 +44,7 @@ TEST_F(StructTypeTest, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_TRUE(ty->Is()); + EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/u32_type_test.cc b/src/type/u32_type_test.cc index af3752d3a9..d2e45970ee 100644 --- a/src/type/u32_type_test.cc +++ b/src/type/u32_type_test.cc @@ -34,7 +34,7 @@ TEST_F(U32Test, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); EXPECT_FALSE(ty->Is()); diff --git a/src/type/vector_type_test.cc b/src/type/vector_type_test.cc index ab0cf3c67e..8b12cc374b 100644 --- a/src/type/vector_type_test.cc +++ b/src/type/vector_type_test.cc @@ -42,7 +42,7 @@ TEST_F(VectorTest, Is) { EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); - EXPECT_FALSE(ty->Is()); + EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_FALSE(ty->Is()); EXPECT_TRUE(ty->Is()); diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc index f4741ce17d..b3f7de0a63 100644 --- a/src/writer/hlsl/generator_impl.cc +++ b/src/writer/hlsl/generator_impl.cc @@ -207,7 +207,7 @@ bool GeneratorImpl::EmitConstructedType(std::ostream& out, if (auto* alias = ty->As()) { // HLSL typedef is for intrinsic types only. For an alias'd struct, // generate a secondary struct with the new name. - if (auto* str = alias->type()->As()) { + if (auto* str = alias->type()->As()) { if (!EmitStructType(out, str, builder_.Symbols().NameFor(alias->symbol()))) { return false; @@ -220,7 +220,7 @@ bool GeneratorImpl::EmitConstructedType(std::ostream& out, } out << " " << builder_.Symbols().NameFor(alias->symbol()) << ";" << std::endl; - } else if (auto* str = ty->As()) { + } else if (auto* str = ty->As()) { if (!EmitStructType(out, str, builder_.Symbols().NameFor(str->symbol()))) { return false; } @@ -1317,7 +1317,7 @@ bool GeneratorImpl::EmitTypeConstructor(std::ostream& pre, bool brackets = expr->type() ->UnwrapAliasIfNeeded() - ->IsAnyOf(); + ->IsAnyOf(); if (brackets) { out << "{"; @@ -1708,7 +1708,7 @@ bool GeneratorImpl::EmitEntryPointData( } auto* type = var->Type()->UnwrapIfNeeded(); - if (auto* strct = type->As()) { + if (auto* strct = type->As()) { out << "ConstantBuffer<" << builder_.Symbols().NameFor(strct->symbol()) << "> " << builder_.Symbols().NameFor(decl->symbol()) << RegisterAndSpace('b', binding_point) << ";" << std::endl; @@ -2030,7 +2030,7 @@ bool GeneratorImpl::EmitEntryPointFunction(std::ostream& out, for (auto* var : func->params()) { auto* sem = builder_.Sem().Get(var); auto* type = sem->Type(); - if (!type->Is()) { + if (!type->Is()) { TINT_ICE(diagnostics_) << "Unsupported non-struct entry point parameter"; } @@ -2132,7 +2132,7 @@ bool GeneratorImpl::EmitZeroValue(std::ostream& out, type::Type* type) { return false; } } - } else if (auto* str = type->As()) { + } else if (auto* str = type->As()) { out << "{"; bool first = true; for (auto* member : str->impl()->members()) { @@ -2449,7 +2449,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, out << "Comparison"; } out << "State"; - } else if (auto* str = type->As()) { + } else if (auto* str = type->As()) { out << builder_.Symbols().NameFor(str->symbol()); } else if (auto* tex = type->As()) { auto* storage = tex->As(); @@ -2539,7 +2539,7 @@ bool GeneratorImpl::EmitType(std::ostream& out, } bool GeneratorImpl::EmitStructType(std::ostream& out, - const type::Struct* str, + const type::StructType* str, const std::string& name) { auto* sem_str = builder_.Sem().Get(str); diff --git a/src/writer/hlsl/generator_impl.h b/src/writer/hlsl/generator_impl.h index 4c8a186f85..4e5410a584 100644 --- a/src/writer/hlsl/generator_impl.h +++ b/src/writer/hlsl/generator_impl.h @@ -299,7 +299,7 @@ class GeneratorImpl : public TextGenerator { /// @param name the struct name /// @returns true if the struct is emitted bool EmitStructType(std::ostream& out, - const type::Struct* ty, + const type::StructType* ty, const std::string& name); /// Handles a unary op expression /// @param pre the preamble for the expression stream diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index 30016a5edf..1c3474bed0 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -155,7 +155,7 @@ bool GeneratorImpl::EmitConstructedType(const type::Type* ty) { } out_ << " " << program_->Symbols().NameFor(alias->symbol()) << ";" << std::endl; - } else if (auto* str = ty->As()) { + } else if (auto* str = ty->As()) { if (!EmitStructType(str)) { return false; } @@ -886,7 +886,7 @@ bool GeneratorImpl::EmitContinue(ast::ContinueStatement*) { } bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) { - if (expr->type()->IsAnyOf()) { + if (expr->type()->IsAnyOf()) { out_ << "{"; } else { if (!EmitType(expr->type(), "")) { @@ -915,7 +915,7 @@ bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) { } } - if (expr->type()->IsAnyOf()) { + if (expr->type()->IsAnyOf()) { out_ << "}"; } else { out_ << ")"; @@ -942,7 +942,7 @@ bool GeneratorImpl::EmitZeroValue(type::Type* type) { return false; } out_ << "}"; - } else if (type->As()) { + } else if (type->As()) { out_ << "{}"; } else { diagnostics_.add_error("Invalid type for zero emission: " + @@ -1429,7 +1429,7 @@ bool GeneratorImpl::EmitEntryPointFunction(ast::Function* func) { out_ << " " << program_->Symbols().NameFor(var->symbol()); - if (type->Is()) { + if (type->Is()) { out_ << " [[stage_in]]"; } else { auto& decos = var->decorations(); @@ -1947,7 +1947,7 @@ bool GeneratorImpl::EmitType(type::Type* type, const std::string& name) { out_ << "*"; } else if (type->Is()) { out_ << "sampler"; - } else if (auto* str = type->As()) { + } else if (auto* str = type->As()) { // The struct type emits as just the name. The declaration would be emitted // as part of emitting the constructed types. out_ << program_->Symbols().NameFor(str->symbol()); @@ -2042,7 +2042,7 @@ bool GeneratorImpl::EmitPackedType(type::Type* type, const std::string& name) { return EmitType(type, name); } -bool GeneratorImpl::EmitStructType(const type::Struct* str) { +bool GeneratorImpl::EmitStructType(const type::StructType* str) { // TODO(dsinclair): Block decoration? // if (str->impl()->decoration() != ast::Decoration::kNone) { // } @@ -2345,7 +2345,7 @@ GeneratorImpl::SizeAndAlign GeneratorImpl::MslPackedTypeSizeAndAlign( return SizeAndAlign{el_size_align.size * num_els, el_size_align.align}; } - if (auto* str = ty->As()) { + if (auto* str = ty->As()) { // TODO(crbug.com/tint/650): There's an assumption here that MSL's default // structure size and alignment matches WGSL's. We need to confirm this. auto* sem = program_->Sem().Get(str); diff --git a/src/writer/msl/generator_impl.h b/src/writer/msl/generator_impl.h index a9ddb6355c..c576476538 100644 --- a/src/writer/msl/generator_impl.h +++ b/src/writer/msl/generator_impl.h @@ -206,7 +206,7 @@ class GeneratorImpl : public TextGenerator { /// Handles generating a struct declaration /// @param str the struct to generate /// @returns true if the struct is emitted - bool EmitStructType(const type::Struct* str); + bool EmitStructType(const type::StructType* str); /// Handles emitting a type constructor /// @param expr the type constructor expression /// @returns true if the constructor is emitted diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 3d955f85be..a78dad2e45 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -864,8 +864,8 @@ bool Builder::GenerateMemberAccessor(ast::MemberAccessorExpression* expr, // If the data_type is a structure we're accessing a member, if it's a // vector we're accessing a swizzle. - if (data_type->Is()) { - auto* strct = data_type->As()->impl(); + if (data_type->Is()) { + auto* strct = data_type->As()->impl(); auto symbol = expr->member()->symbol(); uint32_t idx = 0; @@ -1252,7 +1252,7 @@ bool Builder::is_constructor_const(ast::Expression* expr, bool is_global_init) { subtype = mat->type()->UnwrapAll(); } else if (auto* arr = subtype->As()) { subtype = arr->type()->UnwrapAll(); - } else if (auto* str = subtype->As()) { + } else if (auto* str = subtype->As()) { subtype = str->impl()->members()[i]->type()->UnwrapAll(); } if (subtype != TypeOf(sc)->UnwrapAll()) { @@ -1329,7 +1329,8 @@ uint32_t Builder::GenerateTypeConstructorExpression( // If the result is not a vector then we should have validated that the // value type is a correctly sized vector so we can just use it directly. if (result_type == value_type || result_type->Is() || - result_type->Is() || result_type->Is()) { + result_type->Is() || + result_type->Is()) { out << "_" << id; ops.push_back(Operand::Int(id)); @@ -1980,14 +1981,14 @@ uint32_t Builder::GenerateIntrinsic(ast::CallExpression* call, params.push_back(Operand::Int(struct_id)); auto* type = TypeOf(accessor->structure())->UnwrapAll(); - if (!type->Is()) { + if (!type->Is()) { error_ = "invalid type (" + type->type_name() + ") for runtime array length"; return 0; } // Runtime array must be the last member in the structure - params.push_back(Operand::Int( - uint32_t(type->As()->impl()->members().size() - 1))); + params.push_back(Operand::Int(uint32_t( + type->As()->impl()->members().size() - 1))); if (!push_function_inst(spv::Op::OpArrayLength, params)) { return 0; @@ -2934,7 +2935,7 @@ uint32_t Builder::GenerateTypeIfNeeded(type::Type* type) { return GenerateTypeIfNeeded(alias->type()); } if (auto* ac = type->As()) { - if (!ac->type()->UnwrapIfNeeded()->Is()) { + if (!ac->type()->UnwrapIfNeeded()->Is()) { return GenerateTypeIfNeeded(ac->type()); } } @@ -2949,8 +2950,8 @@ uint32_t Builder::GenerateTypeIfNeeded(type::Type* type) { if (auto* ac = type->As()) { // The non-struct case was handled above. auto* subtype = ac->type()->UnwrapIfNeeded(); - if (!GenerateStructType(subtype->As(), ac->access_control(), - result)) { + if (!GenerateStructType(subtype->As(), + ac->access_control(), result)) { return 0; } } else if (auto* arr = type->As()) { @@ -2971,7 +2972,7 @@ uint32_t Builder::GenerateTypeIfNeeded(type::Type* type) { if (!GeneratePointerType(ptr, result)) { return 0; } - } else if (auto* str = type->As()) { + } else if (auto* str = type->As()) { if (!GenerateStructType(str, ast::AccessControl::kReadWrite, result)) { return 0; } @@ -3144,7 +3145,7 @@ bool Builder::GeneratePointerType(type::Pointer* ptr, const Operand& result) { return true; } -bool Builder::GenerateStructType(type::Struct* struct_type, +bool Builder::GenerateStructType(type::StructType* struct_type, ast::AccessControl access_control, const Operand& result) { auto struct_id = result.to_i(); diff --git a/src/writer/spirv/builder.h b/src/writer/spirv/builder.h index d70280b295..f45918db68 100644 --- a/src/writer/spirv/builder.h +++ b/src/writer/spirv/builder.h @@ -449,7 +449,7 @@ class Builder { /// @param access_control the access controls to assign to the struct /// @param result the result operand /// @returns true if the vector was successfully generated - bool GenerateStructType(type::Struct* struct_type, + bool GenerateStructType(type::StructType* struct_type, ast::AccessControl access_control, const Operand& result); /// Generates a struct member diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc index eeb9fc62c4..3aeafe422d 100644 --- a/src/writer/wgsl/generator_impl.cc +++ b/src/writer/wgsl/generator_impl.cc @@ -123,7 +123,7 @@ bool GeneratorImpl::EmitConstructedType(const type::Type* ty) { return false; } out_ << ";" << std::endl; - } else if (auto* str = ty->As()) { + } else if (auto* str = ty->As()) { if (!EmitStructType(str)) { return false; } @@ -430,7 +430,7 @@ bool GeneratorImpl::EmitType(type::Type* type) { if (sampler->IsComparison()) { out_ << "_comparison"; } - } else if (auto* str = type->As()) { + } else if (auto* str = type->As()) { // The struct, as a type, is just the name. We should have already emitted // the declaration through a call to |EmitStructType| earlier. out_ << program_->Symbols().NameFor(str->symbol()); @@ -511,7 +511,7 @@ bool GeneratorImpl::EmitType(type::Type* type) { return true; } -bool GeneratorImpl::EmitStructType(const type::Struct* str) { +bool GeneratorImpl::EmitStructType(const type::StructType* str) { auto* impl = str->impl(); for (auto* deco : impl->decorations()) { out_ << "[["; diff --git a/src/writer/wgsl/generator_impl.h b/src/writer/wgsl/generator_impl.h index 785c4cb416..984bba3f8d 100644 --- a/src/writer/wgsl/generator_impl.h +++ b/src/writer/wgsl/generator_impl.h @@ -176,7 +176,7 @@ class GeneratorImpl : public TextGenerator { /// Handles generating a struct declaration /// @param str the struct /// @returns true if the struct is emitted - bool EmitStructType(const type::Struct* str); + bool EmitStructType(const type::StructType* str); /// Handles emitting an image format /// @param fmt the format to generate /// @returns true if the format is emitted