diff --git a/src/tint/ast/type_name_test.cc b/src/tint/ast/type_name_test.cc index 9e01f0ca9e..f5fe496b48 100644 --- a/src/tint/ast/type_name_test.cc +++ b/src/tint/ast/type_name_test.cc @@ -23,13 +23,13 @@ using namespace tint::number_suffixes; // NOLINT using TypeNameTest = TestHelper; TEST_F(TypeNameTest, Creation_NonTemplated) { - auto* t = ty.type_name("ty"); + auto* t = ty("ty"); ASSERT_NE(t->name, nullptr); EXPECT_EQ(t->name->symbol, Symbols().Get("ty")); } TEST_F(TypeNameTest, Creation_Templated) { - auto* t = ty.type_name("ty", 1_a, 2._a, false); + auto* t = ty("ty", 1_a, 2._a, false); auto* name = As(t->name); ASSERT_NE(name, nullptr); EXPECT_EQ(name->symbol, Symbols().Get("ty")); @@ -40,7 +40,7 @@ TEST_F(TypeNameTest, Creation_Templated) { } TEST_F(TypeNameTest, Creation_WithSource) { - auto* t = ty.type_name(Source{{20, 2}}, "ty"); + auto* t = ty(Source{{20, 2}}, "ty"); ASSERT_NE(t->name, nullptr); EXPECT_EQ(t->name->symbol, Symbols().Get("ty")); @@ -53,7 +53,7 @@ TEST_F(TypeNameTest, Assert_InvalidSymbol) { EXPECT_FATAL_FAILURE( { ProgramBuilder b; - b.ty.type_name(""); + b.ty(""); }, "internal compiler error"); } @@ -63,7 +63,7 @@ TEST_F(TypeNameTest, Assert_DifferentProgramID_Symbol) { { ProgramBuilder b1; ProgramBuilder b2; - b1.ty.type_name(b2.Sym("b2")); + b1.ty(b2.Sym("b2")); }, "internal compiler error"); } diff --git a/src/tint/inspector/inspector_test.cc b/src/tint/inspector/inspector_test.cc index 44b174424d..160b3b6f58 100644 --- a/src/tint/inspector/inspector_test.cc +++ b/src/tint/inspector/inspector_test.cc @@ -885,7 +885,7 @@ TEST_F(InspectorGetEntryPointTest, OverrideReferencedByArraySizeViaAlias) { Alias("MyArray", ty.array(ty.f32(), Mul(2_a, Expr("bar")))); Override("zoo", ty.u32()); Alias("MyArrayUnused", ty.array(ty.f32(), Mul(2_a, Expr("zoo")))); - GlobalVar("v", type::AddressSpace::kWorkgroup, ty.type_name("MyArray")); + GlobalVar("v", type::AddressSpace::kWorkgroup, ty("MyArray")); Func("ep", utils::Empty, ty.void_(), utils::Vector{ Assign(Phony(), IndexAccessor("v", 0_a)), @@ -1076,7 +1076,7 @@ TEST_F(InspectorGetEntryPointTest, InputSampleMaskStructReferenced) { Func("ep_func", utils::Vector{ - Param("in_var", ty.type_name("in_struct"), utils::Empty), + Param("in_var", ty("in_struct"), utils::Empty), }, ty.void_(), utils::Vector{ @@ -1124,9 +1124,9 @@ TEST_F(InspectorGetEntryPointTest, OutputSampleMaskStructReferenced) { utils::Vector{Builtin(ast::BuiltinValue::kSampleMask)}), }); - Func("ep_func", utils::Empty, ty.type_name("out_struct"), + Func("ep_func", utils::Empty, ty("out_struct"), utils::Vector{ - Decl(Var("out_var", ty.type_name("out_struct"))), + Decl(Var("out_var", ty("out_struct"))), Return("out_var"), }, utils::Vector{ @@ -1170,7 +1170,7 @@ TEST_F(InspectorGetEntryPointTest, InputPositionStructReferenced) { Func("ep_func", utils::Vector{ - Param("in_var", ty.type_name("in_struct"), utils::Empty), + Param("in_var", ty("in_struct"), utils::Empty), }, ty.void_(), utils::Vector{ @@ -1217,7 +1217,7 @@ TEST_F(InspectorGetEntryPointTest, FrontFacingStructReferenced) { Func("ep_func", utils::Vector{ - Param("in_var", ty.type_name("in_struct"), utils::Empty), + Param("in_var", ty("in_struct"), utils::Empty), }, ty.void_(), utils::Vector{ @@ -1264,7 +1264,7 @@ TEST_F(InspectorGetEntryPointTest, SampleIndexStructReferenced) { Func("ep_func", utils::Vector{ - Param("in_var", ty.type_name("in_struct"), utils::Empty), + Param("in_var", ty("in_struct"), utils::Empty), }, ty.void_(), utils::Vector{ @@ -1310,7 +1310,7 @@ TEST_F(InspectorGetEntryPointTest, NumWorkgroupsStructReferenced) { Func("ep_func", utils::Vector{ - Param("in_var", ty.type_name("in_struct"), utils::Empty), + Param("in_var", ty("in_struct"), utils::Empty), }, ty.void_(), utils::Vector{ @@ -1352,9 +1352,9 @@ TEST_F(InspectorGetEntryPointTest, FragDepthStructReferenced) { utils::Vector{Builtin(ast::BuiltinValue::kFragDepth)}), }); - Func("ep_func", utils::Empty, ty.type_name("out_struct"), + Func("ep_func", utils::Empty, ty("out_struct"), utils::Vector{ - Decl(Var("out_var", ty.type_name("out_struct"))), + Decl(Var("out_var", ty("out_struct"))), Return("out_var"), }, utils::Vector{ @@ -1376,7 +1376,7 @@ TEST_F(InspectorGetEntryPointTest, ImplicitInterpolate) { Func("ep_func", utils::Vector{ - Param("in_var", ty.type_name("in_struct"), utils::Empty), + Param("in_var", ty("in_struct"), utils::Empty), }, ty.void_(), utils::Vector{ @@ -1407,7 +1407,7 @@ TEST_P(InspectorGetEntryPointInterpolateTest, Test) { Func("ep_func", utils::Vector{ - Param("in_var", ty.type_name("in_struct"), utils::Empty), + Param("in_var", ty("in_struct"), utils::Empty), }, ty.void_(), utils::Vector{ diff --git a/src/tint/inspector/test_inspector_builder.cc b/src/tint/inspector/test_inspector_builder.cc index a24f18ab4d..96139e243c 100644 --- a/src/tint/inspector/test_inspector_builder.cc +++ b/src/tint/inspector/test_inspector_builder.cc @@ -119,7 +119,7 @@ std::function InspectorBuilder::MakeStorageBufferTypes( const std::string& name, utils::VectorRef member_types) { MakeStructType(name, member_types); - return [this, name] { return ty.type_name(name); }; + return [this, name] { return ty(name); }; } void InspectorBuilder::AddUniformBuffer(const std::string& name, diff --git a/src/tint/program_builder.cc b/src/tint/program_builder.cc index 9c2019e2e2..9b9e1d2a46 100644 --- a/src/tint/program_builder.cc +++ b/src/tint/program_builder.cc @@ -128,7 +128,7 @@ std::string ProgramBuilder::FriendlyName(std::nullptr_t) const { } const ast::TypeName* ProgramBuilder::TypesBuilder::Of(const ast::TypeDecl* decl) const { - return type_name(decl->name); + return (*this)(decl->name); } ProgramBuilder::TypesBuilder::TypesBuilder(ProgramBuilder* pb) : builder(pb) {} diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h index dc3560a1a4..ba40256a47 100644 --- a/src/tint/program_builder.h +++ b/src/tint/program_builder.h @@ -904,7 +904,7 @@ class ProgramBuilder { /// @param args the optional template arguments /// @returns the type name template > - const ast::TypeName* type_name(NAME&& name, ARGS&&... args) const { + const ast::TypeName* operator()(NAME&& name, ARGS&&... args) const { return builder->create( builder->Ident(std::forward(name), std::forward(args)...)); } @@ -915,7 +915,7 @@ class ProgramBuilder { /// @param args the optional template arguments /// @returns the type name template - const ast::TypeName* type_name(const Source& source, NAME&& name, ARGS&&... args) const { + const ast::TypeName* operator()(const Source& source, NAME&& name, ARGS&&... args) const { return builder->create( source, builder->Ident(std::forward(name), std::forward(args)...)); } diff --git a/src/tint/reader/spirv/parser_type.cc b/src/tint/reader/spirv/parser_type.cc index 40245ca72e..10fd5b014d 100644 --- a/src/tint/reader/spirv/parser_type.cc +++ b/src/tint/reader/spirv/parser_type.cc @@ -271,7 +271,7 @@ Alias::Alias(Symbol n, const Type* ty) : Base(n), type(ty) {} Alias::Alias(const Alias&) = default; const ast::Type* Alias::Build(ProgramBuilder& b) const { - return b.ty.type_name(name); + return b.ty(name); } Struct::Struct(Symbol n, TypeList m) : Base(n), members(std::move(m)) {} @@ -279,7 +279,7 @@ Struct::Struct(const Struct&) = default; Struct::~Struct() = default; const ast::Type* Struct::Build(ProgramBuilder& b) const { - return b.ty.type_name(name); + return b.ty(name); } /// The PIMPL state of the Types object. diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc index 27c01d96a7..41aced0ed9 100644 --- a/src/tint/reader/wgsl/parser_impl.cc +++ b/src/tint/reader/wgsl/parser_impl.cc @@ -1213,7 +1213,7 @@ Maybe ParserImpl::type_specifier() { auto& t = peek(); Source source; if (match(Token::Type::kIdentifier, &source)) { - return builder_.ty.type_name(source, t.to_str()); + return builder_.ty(source, t.to_str()); } return type_specifier_without_ident(); diff --git a/src/tint/resolver/address_space_layout_validation_test.cc b/src/tint/resolver/address_space_layout_validation_test.cc index 40558429e6..e62bafb68b 100644 --- a/src/tint/resolver/address_space_layout_validation_test.cc +++ b/src/tint/resolver/address_space_layout_validation_test.cc @@ -39,7 +39,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, StorageBuffer_UnalignedMember) Member(Source{{34, 56}}, "b", ty.f32(), utils::Vector{MemberAlign(1_i)}), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("S"), type::AddressSpace::kStorage, Group(0_a), + GlobalVar(Source{{78, 90}}, "a", ty("S"), type::AddressSpace::kStorage, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -69,7 +69,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, StorageBuffer_UnalignedMember_S Member(Source{{34, 56}}, "b", ty.f32(), utils::Vector{MemberAlign(4_i)}), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("S"), type::AddressSpace::kStorage, Group(0_a), + GlobalVar(Source{{78, 90}}, "a", ty("S"), type::AddressSpace::kStorage, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -97,11 +97,11 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_UnalignedMember_S Structure(Source{{34, 56}}, "Outer", utils::Vector{ Member("scalar", ty.f32()), - Member(Source{{56, 78}}, "inner", ty.type_name("Inner")), + Member(Source{{56, 78}}, "inner", ty("Inner")), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + Binding(0_a)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -141,12 +141,11 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, Structure(Source{{34, 56}}, "Outer", utils::Vector{ Member("scalar", ty.f32()), - Member(Source{{56, 78}}, "inner", ty.type_name("Inner"), - utils::Vector{MemberAlign(16_i)}), + Member(Source{{56, 78}}, "inner", ty("Inner"), utils::Vector{MemberAlign(16_i)}), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -167,11 +166,11 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_UnalignedMember_A Structure(Source{{12, 34}}, "Outer", utils::Vector{ Member("scalar", ty.f32()), - Member(Source{{56, 78}}, "inner", ty.type_name("Inner")), + Member(Source{{56, 78}}, "inner", ty("Inner")), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + Binding(0_a)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -200,12 +199,11 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_UnalignedMember_A Structure(Source{{12, 34}}, "Outer", utils::Vector{ Member("scalar", ty.f32()), - Member(Source{{34, 56}}, "inner", ty.type_name("Inner"), - utils::Vector{MemberAlign(16_i)}), + Member(Source{{34, 56}}, "inner", ty("Inner"), utils::Vector{MemberAlign(16_i)}), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -232,12 +230,12 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_MembersOffsetNotM Structure(Source{{34, 56}}, "Outer", utils::Vector{ - Member(Source{{56, 78}}, "inner", ty.type_name("Inner")), + Member(Source{{56, 78}}, "inner", ty("Inner")), Member(Source{{78, 90}}, "scalar", ty.i32()), }); - GlobalVar(Source{{22, 24}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{22, 24}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + Binding(0_a)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -284,12 +282,12 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, Structure(Source{{34, 56}}, "Outer", utils::Vector{ - Member(Source{{56, 78}}, "inner", ty.type_name("Inner")), + Member(Source{{56, 78}}, "inner", ty("Inner")), Member(Source{{78, 90}}, "scalar", ty.i32()), }); - GlobalVar(Source{{22, 24}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{22, 24}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + Binding(0_a)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -332,12 +330,12 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, Structure(Source{{34, 56}}, "Outer", utils::Vector{ - Member(Source{{56, 78}}, "inner", ty.type_name("Inner")), + Member(Source{{56, 78}}, "inner", ty("Inner")), Member(Source{{78, 90}}, "scalar", ty.i32(), utils::Vector{MemberAlign(16_i)}), }); - GlobalVar(Source{{22, 34}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{22, 34}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -357,8 +355,8 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_Vec3MemberOffset_ Member("s", ty.f32()), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("ScalarPackedAtEndOfVec3"), - type::AddressSpace::kUniform, Group(0_a), Binding(0_a)); + GlobalVar(Source{{78, 90}}, "a", ty("ScalarPackedAtEndOfVec3"), type::AddressSpace::kUniform, + Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -380,8 +378,8 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_Vec3F16MemberOffs Member("s", ty.f16()), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("ScalarPackedAtEndOfVec3"), - type::AddressSpace::kUniform, Group(0_a), Binding(0_a)); + GlobalVar(Source{{78, 90}}, "a", ty("ScalarPackedAtEndOfVec3"), type::AddressSpace::kUniform, + Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -402,12 +400,12 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid Structure(Source{{12, 34}}, "Outer", utils::Vector{ - Member("inner", ty.type_name(Source{{34, 56}}, "Inner")), + Member("inner", ty(Source{{34, 56}}, "Inner")), Member("scalar", ty.i32()), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + Binding(0_a)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -436,12 +434,12 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid Structure(Source{{12, 34}}, "Outer", utils::Vector{ - Member("inner", ty.type_name(Source{{34, 56}}, "Inner")), + Member("inner", ty(Source{{34, 56}}, "Inner")), Member("scalar", ty.i32()), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + Binding(0_a)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -479,12 +477,12 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid Structure(Source{{12, 34}}, "Outer", utils::Vector{ - Member("inner", ty.type_name(Source{{34, 56}}, "Inner")), + Member("inner", ty(Source{{34, 56}}, "Inner")), Member("scalar", ty.i32()), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + Binding(0_a)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -523,8 +521,8 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("inner", ty.array(Source{{34, 56}}, ty.array(ty.f32(), 4_u), 4_u)), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + Binding(0_a)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -552,12 +550,12 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, UniformBuffer_InvalidArrayStrid Structure(Source{{12, 34}}, "Outer", utils::Vector{ - Member("inner", ty.type_name(Source{{34, 56}}, "Inner")), + Member("inner", ty(Source{{34, 56}}, "Inner")), Member("scalar", ty.i32()), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), type::AddressSpace::kUniform, - Group(0_a), Binding(0_a)); + GlobalVar(Source{{78, 90}}, "a", ty("Outer"), type::AddressSpace::kUniform, Group(0_a), + Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -575,7 +573,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, PushConstant_UnalignedMember) { Source{{12, 34}}, "S", utils::Vector{Member("a", ty.f32(), utils::Vector{MemberSize(5_a)}), Member(Source{{34, 56}}, "b", ty.f32(), utils::Vector{MemberAlign(1_i)})}); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("S"), type::AddressSpace::kPushConstant); + GlobalVar(Source{{78, 90}}, "a", ty("S"), type::AddressSpace::kPushConstant); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -600,7 +598,7 @@ TEST_F(ResolverAddressSpaceLayoutValidationTest, PushConstant_Aligned) { Enable(ast::Extension::kChromiumExperimentalPushConstant); Structure("S", utils::Vector{Member("a", ty.f32(), utils::Vector{MemberSize(5_a)}), Member("b", ty.f32(), utils::Vector{MemberAlign(4_i)})}); - GlobalVar("a", ty.type_name("S"), type::AddressSpace::kPushConstant); + GlobalVar("a", ty("S"), type::AddressSpace::kPushConstant); ASSERT_TRUE(r()->Resolve()) << r()->error(); } diff --git a/src/tint/resolver/address_space_validation_test.cc b/src/tint/resolver/address_space_validation_test.cc index b85feeb473..fb4981e225 100644 --- a/src/tint/resolver/address_space_validation_test.cc +++ b/src/tint/resolver/address_space_validation_test.cc @@ -79,7 +79,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Private_RuntimeArrayIn // struct S { m : array }; // var v : S; Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.array(ty.i32()))}); - GlobalVar(Source{{56, 78}}, "v", ty.type_name("S"), type::AddressSpace::kPrivate); + GlobalVar(Source{{56, 78}}, "v", ty("S"), type::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -92,7 +92,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Private_RuntimeArrayInSt // struct S { m : array }; // type t = ptr; Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.array(ty.i32()))}); - Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kPrivate)); + Alias("t", ty.pointer(ty("S"), type::AddressSpace::kPrivate)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -126,7 +126,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Workgroup_RuntimeArray // struct S { m : array }; // var v : S; Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.array(ty.i32()))}); - GlobalVar(Source{{56, 78}}, "v", ty.type_name("S"), type::AddressSpace::kWorkgroup); + GlobalVar(Source{{56, 78}}, "v", ty("S"), type::AddressSpace::kWorkgroup); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -139,7 +139,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Workgroup_RuntimeArrayIn // struct S { m : array }; // type t = ptr; Structure("S", utils::Vector{Member(Source{{12, 34}}, "m", ty.array(ty.i32()))}); - Alias(Source{{56, 78}}, "t", ty.pointer(ty.type_name("S"), type::AddressSpace::kWorkgroup)); + Alias(Source{{56, 78}}, "t", ty.pointer(ty("S"), type::AddressSpace::kWorkgroup)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -178,8 +178,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_BoolAlias) { // type a = bool; // @binding(0) @group(0) var g : a; Alias("a", ty.bool_()); - GlobalVar(Source{{56, 78}}, "g", ty.type_name(Source{{12, 34}}, "a"), - type::AddressSpace::kStorage, Binding(0_a), Group(0_a)); + GlobalVar(Source{{56, 78}}, "g", ty(Source{{12, 34}}, "a"), type::AddressSpace::kStorage, + Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -194,7 +194,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_BoolAlias) { // type t = ptr; Alias("a", ty.bool_()); Alias(Source{{56, 78}}, "t", - ty.pointer(ty.type_name(Source{{12, 34}}, "a"), type::AddressSpace::kStorage)); + ty.pointer(ty(Source{{12, 34}}, "a"), type::AddressSpace::kStorage)); ASSERT_FALSE(r()->Resolve()); @@ -273,7 +273,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_F16Alias) { Enable(ast::Extension::kF16); Alias("a", ty.f16()); - GlobalVar("g", ty.type_name("a"), type::AddressSpace::kStorage, Binding(0_a), Group(0_a)); + GlobalVar("g", ty("a"), type::AddressSpace::kStorage, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -285,7 +285,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_F16Alias) { Enable(ast::Extension::kF16); Alias("a", ty.f16()); - Alias("t", ty.pointer(ty.type_name("a"), type::AddressSpace::kStorage)); + Alias("t", ty.pointer(ty("a"), type::AddressSpace::kStorage)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -324,8 +324,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ArrayF32) { // struct S{ a : f32 }; // var g : array; Structure("S", utils::Vector{Member("a", ty.f32())}); - GlobalVar("g", ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kStorage, - type::Access::kRead, Binding(0_a), Group(0_a)); + GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, type::Access::kRead, + Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -334,7 +334,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ArrayF32) { // struct S{ a : f32 }; // type t = ptr>; Structure("S", utils::Vector{Member("a", ty.f32())}); - Alias("t", ty.pointer(ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kStorage)); + Alias("t", ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kStorage)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -346,8 +346,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_ArrayF16) { Enable(ast::Extension::kF16); Structure("S", utils::Vector{Member("a", ty.f16())}); - GlobalVar("g", ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kStorage, - type::Access::kRead, Binding(0_a), Group(0_a)); + GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, type::Access::kRead, + Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -359,8 +359,8 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_ArrayF16) { Enable(ast::Extension::kF16); Structure("S", utils::Vector{Member("a", ty.f16())}); - Alias("t", ty.pointer(ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kStorage, - type::Access::kRead)); + Alias("t", + ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kStorage, type::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -369,8 +369,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructI32) { // struct S { x : i32 }; // var g : S; Structure("S", utils::Vector{Member("x", ty.i32())}); - GlobalVar("g", ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead, - Binding(0_a), Group(0_a)); + GlobalVar("g", ty("S"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), + Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -379,7 +379,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32) { // struct S { x : i32 }; // type t = ptr; Structure("S", utils::Vector{Member("x", ty.i32())}); - Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead)); + Alias("t", ty.pointer(ty("S"), type::AddressSpace::kStorage, type::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -389,10 +389,10 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructI32Alias // type a1 = S; // var g : a1; Structure("S", utils::Vector{Member("x", ty.i32())}); - Alias("a1", ty.type_name("S")); - Alias("a2", ty.type_name("a1")); - GlobalVar("g", ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead, - Binding(0_a), Group(0_a)); + Alias("a1", ty("S")); + Alias("a2", ty("a1")); + GlobalVar("g", ty("a2"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), + Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -402,9 +402,9 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructI32Aliases // type a1 = S; // type t = ptr; Structure("S", utils::Vector{Member("x", ty.i32())}); - Alias("a1", ty.type_name("S")); - Alias("a2", ty.type_name("a1")); - Alias("t", ty.pointer(ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead)); + Alias("a1", ty("S")); + Alias("a2", ty("a1")); + Alias("t", ty.pointer(ty("a2"), type::AddressSpace::kStorage, type::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -415,8 +415,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructF16) { Enable(ast::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - GlobalVar("g", ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead, - Binding(0_a), Group(0_a)); + GlobalVar("g", ty("S"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), + Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -427,7 +427,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16) { Enable(ast::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kStorage, type::Access::kRead)); + Alias("t", ty.pointer(ty("S"), type::AddressSpace::kStorage, type::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -439,10 +439,10 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_Storage_StructF16Alias Enable(ast::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - Alias("a1", ty.type_name("S")); - Alias("a2", ty.type_name("a1")); - GlobalVar("g", ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead, - Binding(0_a), Group(0_a)); + Alias("a1", ty("S")); + Alias("a2", ty("a1")); + GlobalVar("g", ty("a2"), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), + Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -454,9 +454,9 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_Storage_StructF16Aliases Enable(ast::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - Alias("a1", ty.type_name("S")); - Alias("a2", ty.type_name("a1")); - Alias("g", ty.pointer(ty.type_name("a2"), type::AddressSpace::kStorage, type::Access::kRead)); + Alias("a1", ty("S")); + Alias("a2", ty("a1")); + Alias("g", ty.pointer(ty("a2"), type::AddressSpace::kStorage, type::Access::kRead)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -543,8 +543,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBuffer_Struct_R Structure("S", utils::Vector{Member(Source{{56, 78}}, "m", ty.array(Source{{12, 34}}, ty.i32()))}); - GlobalVar(Source{{90, 12}}, "svar", ty.type_name("S"), type::AddressSpace::kUniform, - Binding(0_a), Group(0_a)); + GlobalVar(Source{{90, 12}}, "svar", ty("S"), type::AddressSpace::kUniform, Binding(0_a), + Group(0_a)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -560,7 +560,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBuffer_Struct_Run Structure("S", utils::Vector{Member(Source{{56, 78}}, "m", ty.array(Source{{12, 34}}, ty.i32()))}); - Alias("t", ty.pointer(Source{{90, 12}}, ty.type_name("S"), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(Source{{90, 12}}, ty("S"), type::AddressSpace::kUniform)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -603,8 +603,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferBoolAlias // type a = bool; // var g : a; Alias("a", ty.bool_()); - GlobalVar(Source{{56, 78}}, "g", ty.type_name(Source{{12, 34}}, "a"), - type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar(Source{{56, 78}}, "g", ty(Source{{12, 34}}, "a"), type::AddressSpace::kUniform, + Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -618,8 +618,8 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferBoolAlias) // type a = bool; // type t = ptr; Alias("a", ty.bool_()); - Alias("t", ty.pointer(Source{{56, 78}}, ty.type_name(Source{{12, 34}}, "a"), - type::AddressSpace::kUniform)); + Alias("t", + ty.pointer(Source{{56, 78}}, ty(Source{{12, 34}}, "a"), type::AddressSpace::kUniform)); ASSERT_FALSE(r()->Resolve()); @@ -732,8 +732,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferArrayF32) // } // var g : array; Structure("S", utils::Vector{Member("a", ty.f32(), utils::Vector{MemberSize(16_a)})}); - GlobalVar("g", ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kUniform, Binding(0_a), - Group(0_a)); + GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -744,7 +743,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferArrayF32) { // } // type t = ptr>; Structure("S", utils::Vector{Member("a", ty.f32(), utils::Vector{MemberSize(16_a)})}); - Alias("t", ty.pointer(ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -758,8 +757,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferArrayF16) Enable(ast::Extension::kF16); Structure("S", utils::Vector{Member("a", ty.f16(), utils::Vector{MemberSize(16_a)})}); - GlobalVar("g", ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kUniform, Binding(0_a), - Group(0_a)); + GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -773,7 +771,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferArrayF16) { Enable(ast::Extension::kF16); Structure("S", utils::Vector{Member("a", ty.f16(), utils::Vector{MemberSize(16_a)})}); - Alias("t", ty.pointer(ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -782,7 +780,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferStructI32 // struct S { x : i32 }; // var g : S; Structure("S", utils::Vector{Member("x", ty.i32())}); - GlobalVar("g", ty.type_name("S"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar("g", ty("S"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -791,7 +789,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferStructI32) // struct S { x : i32 }; // type t = ptr; Structure("S", utils::Vector{Member("x", ty.i32())}); - Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(ty("S"), type::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -801,8 +799,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferStructI32 // type a1 = S; // var g : a1; Structure("S", utils::Vector{Member("x", ty.i32())}); - Alias("a1", ty.type_name("S")); - GlobalVar("g", ty.type_name("a1"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + Alias("a1", ty("S")); + GlobalVar("g", ty("a1"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -812,8 +810,8 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferStructI32Al // type a1 = S; // type t = ptr; Structure("S", utils::Vector{Member("x", ty.i32())}); - Alias("a1", ty.type_name("S")); - Alias("t", ty.pointer(ty.type_name("a1"), type::AddressSpace::kUniform)); + Alias("a1", ty("S")); + Alias("t", ty.pointer(ty("a1"), type::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -825,7 +823,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferStructF16 Enable(ast::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - GlobalVar("g", ty.type_name("S"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + GlobalVar("g", ty("S"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -837,7 +835,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferStructF16) Enable(ast::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - Alias("t", ty.pointer(ty.type_name("S"), type::AddressSpace::kUniform)); + Alias("t", ty.pointer(ty("S"), type::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -850,8 +848,8 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_UniformBufferStructF16 Enable(ast::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - Alias("a1", ty.type_name("S")); - GlobalVar("g", ty.type_name("a1"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); + Alias("a1", ty("S")); + GlobalVar("g", ty("a1"), type::AddressSpace::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -864,8 +862,8 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_UniformBufferStructF16Al Enable(ast::Extension::kF16); Structure("S", utils::Vector{Member("x", ty.f16())}); - Alias("a1", ty.type_name("S")); - Alias("t", ty.pointer(ty.type_name("a1"), type::AddressSpace::kUniform)); + Alias("a1", ty("S")); + Alias("t", ty.pointer(ty("a1"), type::AddressSpace::kUniform)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -995,7 +993,7 @@ TEST_F(ResolverAddressSpaceValidationTest, GlobalVariable_PushConstantArrayF32) // var g : array; Enable(ast::Extension::kChromiumExperimentalPushConstant); Structure("S", utils::Vector{Member("a", ty.f32())}); - GlobalVar("g", ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kPushConstant); + GlobalVar("g", ty.array(ty("S"), 3_u), type::AddressSpace::kPushConstant); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -1006,7 +1004,7 @@ TEST_F(ResolverAddressSpaceValidationTest, PointerAlias_PushConstantArrayF32) { // type t = ptr>; Enable(ast::Extension::kChromiumExperimentalPushConstant); Structure("S", utils::Vector{Member("a", ty.f32())}); - Alias("t", ty.pointer(ty.array(ty.type_name("S"), 3_u), type::AddressSpace::kPushConstant)); + Alias("t", ty.pointer(ty.array(ty("S"), 3_u), type::AddressSpace::kPushConstant)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } diff --git a/src/tint/resolver/alias_analysis_test.cc b/src/tint/resolver/alias_analysis_test.cc index 66d503367d..12cfc58c3e 100644 --- a/src/tint/resolver/alias_analysis_test.cc +++ b/src/tint/resolver/alias_analysis_test.cc @@ -724,8 +724,8 @@ TEST_F(ResolverAliasAnalysisTest, NoAccess_MemberAccessor) { Structure("S", utils::Vector{Member("a", ty.i32())}); Func("f2", utils::Vector{ - Param("p1", ty.pointer(ty.type_name("S"), type::AddressSpace::kFunction)), - Param("p2", ty.pointer(ty.type_name("S"), type::AddressSpace::kFunction)), + Param("p1", ty.pointer(ty("S"), type::AddressSpace::kFunction)), + Param("p2", ty.pointer(ty("S"), type::AddressSpace::kFunction)), }, ty.void_(), utils::Vector{ @@ -734,7 +734,7 @@ TEST_F(ResolverAliasAnalysisTest, NoAccess_MemberAccessor) { }); Func("f1", utils::Empty, ty.void_(), utils::Vector{ - Decl(Var("v", ty.type_name("S"))), + Decl(Var("v", ty("S"))), CallStmt(Call("f2", AddressOf("v"), AddressOf("v"))), }); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -753,17 +753,17 @@ TEST_F(ResolverAliasAnalysisTest, Read_MemberAccessor) { Structure("S", utils::Vector{Member("a", ty.i32())}); Func("f2", utils::Vector{ - Param("p1", ty.pointer(ty.type_name("S"), type::AddressSpace::kFunction)), - Param("p2", ty.pointer(ty.type_name("S"), type::AddressSpace::kFunction)), + Param("p1", ty.pointer(ty("S"), type::AddressSpace::kFunction)), + Param("p2", ty.pointer(ty("S"), type::AddressSpace::kFunction)), }, ty.void_(), utils::Vector{ Assign(Phony(), MemberAccessor(Deref("p2"), "a")), - Assign(Deref("p1"), Construct(ty.type_name("S"))), + Assign(Deref("p1"), Construct(ty("S"))), }); Func("f1", utils::Empty, ty.void_(), utils::Vector{ - Decl(Var("v", ty.type_name("S"))), + Decl(Var("v", ty("S"))), CallStmt( Call("f2", AddressOf(Source{{12, 34}}, "v"), AddressOf(Source{{56, 76}}, "v"))), }); @@ -785,8 +785,8 @@ TEST_F(ResolverAliasAnalysisTest, Write_MemberAccessor) { Structure("S", utils::Vector{Member("a", ty.i32())}); Func("f2", utils::Vector{ - Param("p1", ty.pointer(ty.type_name("S"), type::AddressSpace::kFunction)), - Param("p2", ty.pointer(ty.type_name("S"), type::AddressSpace::kFunction)), + Param("p1", ty.pointer(ty("S"), type::AddressSpace::kFunction)), + Param("p2", ty.pointer(ty("S"), type::AddressSpace::kFunction)), }, ty.void_(), utils::Vector{ @@ -795,7 +795,7 @@ TEST_F(ResolverAliasAnalysisTest, Write_MemberAccessor) { }); Func("f1", utils::Empty, ty.void_(), utils::Vector{ - Decl(Var("v", ty.type_name("S"))), + Decl(Var("v", ty("S"))), CallStmt( Call("f2", AddressOf(Source{{12, 34}}, "v"), AddressOf(Source{{56, 76}}, "v"))), }); diff --git a/src/tint/resolver/bitcast_validation_test.cc b/src/tint/resolver/bitcast_validation_test.cc index c6d4cb4913..b02cf7d87c 100644 --- a/src/tint/resolver/bitcast_validation_test.cc +++ b/src/tint/resolver/bitcast_validation_test.cc @@ -148,7 +148,7 @@ TEST_P(ResolverBitcastValidationTestInvalidDstTy, Test) { // Use an alias so we can put a Source on the bitcast type Alias("T", dst.ast(*this)); - WrapInFunction(Bitcast(ty.type_name(Source{{12, 34}}, "T"), src.expr(*this, 0))); + WrapInFunction(Bitcast(ty(Source{{12, 34}}, "T"), src.expr(*this, 0))); auto expected = "12:34 error: cannot bitcast to '" + dst.sem(*this)->FriendlyName(Symbols()) + "'"; diff --git a/src/tint/resolver/builtin_validation_test.cc b/src/tint/resolver/builtin_validation_test.cc index 281ca475c6..cfd9877893 100644 --- a/src/tint/resolver/builtin_validation_test.cc +++ b/src/tint/resolver/builtin_validation_test.cc @@ -123,7 +123,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsFunctionUsedAsType) { utils::Vector{ Return(1_i), }); - WrapInFunction(Construct(ty.type_name(Source{{56, 78}}, "mix"))); + WrapInFunction(Construct(ty(Source{{56, 78}}, "mix"))); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), R"(56:78 error: cannot use function 'mix' as type @@ -152,7 +152,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalConstUsedAsVariab TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalConstUsedAsType) { GlobalConst(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i)); - WrapInFunction(Construct(ty.type_name(Source{{56, 78}}, "mix"))); + WrapInFunction(Construct(ty(Source{{56, 78}}, "mix"))); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), R"(56:78 error: cannot use variable 'mix' as type @@ -182,7 +182,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalVarUsedAsVariable TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalVarUsedAsType) { GlobalVar(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i), type::AddressSpace::kPrivate); - WrapInFunction(Construct(ty.type_name(Source{{56, 78}}, "mix"))); + WrapInFunction(Construct(ty(Source{{56, 78}}, "mix"))); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), R"(56:78 error: cannot use variable 'mix' as type @@ -215,7 +215,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsAliasUsedAsVariable) { TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsAliasUsedAsType) { auto* mix = Alias(Source{{12, 34}}, "mix", ty.i32()); - auto* use = Construct(ty.type_name("mix")); + auto* use = Construct(ty("mix")); WrapInFunction(use); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -249,7 +249,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsStructUsedAsType) { auto* mix = Structure("mix", utils::Vector{ Member("m", ty.i32()), }); - auto* use = Construct(ty.type_name("mix")); + auto* use = Construct(ty("mix")); WrapInFunction(use); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -695,9 +695,8 @@ TEST_F(ResolverBuiltinValidationTest, WorkgroupUniformLoad_AtomicInStruct) { // workgroupUniformLoad(&v); // } Structure("Inner", utils::Vector{Member("a", ty.array(ty.atomic(), 4_a))}); - Structure("S", utils::Vector{Member("i", ty.type_name("Inner"))}); - GlobalVar(Source{{12, 34}}, "v", ty.array(ty.type_name("S"), 4_a), - type::AddressSpace::kWorkgroup); + Structure("S", utils::Vector{Member("i", ty("Inner"))}); + GlobalVar(Source{{12, 34}}, "v", ty.array(ty("S"), 4_a), type::AddressSpace::kWorkgroup); WrapInFunction(CallStmt(Call("workgroupUniformLoad", AddressOf("v")))); EXPECT_FALSE(r()->Resolve()); diff --git a/src/tint/resolver/builtins_validation_test.cc b/src/tint/resolver/builtins_validation_test.cc index efee2c913e..abdd1a9604 100644 --- a/src/tint/resolver/builtins_validation_test.cc +++ b/src/tint/resolver/builtins_validation_test.cc @@ -221,7 +221,7 @@ TEST_F(ResolverBuiltinsValidationTest, StructBuiltinInsideEntryPoint_Ignored) { }), }); - Func("fragShader", utils::Empty, ty.void_(), utils::Vector{Decl(Var("s", ty.type_name("S")))}, + Func("fragShader", utils::Empty, ty.void_(), utils::Vector{Decl(Var("s", ty("S")))}, utils::Vector{ Stage(ast::PipelineStage::kFragment), }); diff --git a/src/tint/resolver/const_eval_binary_op_test.cc b/src/tint/resolver/const_eval_binary_op_test.cc index d9efb4b430..30c802e14c 100644 --- a/src/tint/resolver/const_eval_binary_op_test.cc +++ b/src/tint/resolver/const_eval_binary_op_test.cc @@ -1954,8 +1954,7 @@ TEST_F(ResolverConstEvalTest, ShortCircuit_And_Error_StructInit) { GlobalConst("one", Expr(1_a)); auto* lhs = Equal("one", 0_a); auto* rhs = Equal( - MemberAccessor(Construct(ty.type_name("S"), Expr(1_a), Expr(Source{{12, 34}}, true)), "a"), - 0_a); + MemberAccessor(Construct(ty("S"), Expr(1_a), Expr(Source{{12, 34}}, true)), "a"), 0_a); GlobalConst("result", LogicalAnd(lhs, rhs)); EXPECT_FALSE(r()->Resolve()); @@ -1975,8 +1974,7 @@ TEST_F(ResolverConstEvalTest, ShortCircuit_Or_Error_StructInit) { GlobalConst("one", Expr(1_a)); auto* lhs = Equal("one", 1_a); auto* rhs = Equal( - MemberAccessor(Construct(ty.type_name("S"), Expr(1_a), Expr(Source{{12, 34}}, true)), "a"), - 0_a); + MemberAccessor(Construct(ty("S"), Expr(1_a), Expr(Source{{12, 34}}, true)), "a"), 0_a); GlobalConst("result", LogicalOr(lhs, rhs)); EXPECT_FALSE(r()->Resolve()); @@ -2148,7 +2146,7 @@ TEST_F(ResolverConstEvalTest, ShortCircuit_And_Error_MemberAccess) { // const one = 1; // const result = (one == 0) && (s.c == 0); Structure("S", utils::Vector{Member("a", ty.i32()), Member("b", ty.f32())}); - GlobalConst("s", Construct(ty.type_name("S"), Expr(1_a), Expr(2.0_a))); + GlobalConst("s", Construct(ty("S"), Expr(1_a), Expr(2.0_a))); GlobalConst("one", Expr(1_a)); auto* lhs = Equal("one", 0_a); auto* rhs = Equal(MemberAccessor(Source{{12, 34}}, "s", "c"), 0_a); @@ -2167,7 +2165,7 @@ TEST_F(ResolverConstEvalTest, ShortCircuit_Or_Error_MemberAccess) { // const one = 1; // const result = (one == 1) || (s.c == 0); Structure("S", utils::Vector{Member("a", ty.i32()), Member("b", ty.f32())}); - GlobalConst("s", Construct(ty.type_name("S"), Expr(1_a), Expr(2.0_a))); + GlobalConst("s", Construct(ty("S"), Expr(1_a), Expr(2.0_a))); GlobalConst("one", Expr(1_a)); auto* lhs = Equal("one", 1_a); auto* rhs = Equal(MemberAccessor(Source{{12, 34}}, "s", "c"), 0_a); diff --git a/src/tint/resolver/const_eval_construction_test.cc b/src/tint/resolver/const_eval_construction_test.cc index 306911fa22..d8b25b9484 100644 --- a/src/tint/resolver/const_eval_construction_test.cc +++ b/src/tint/resolver/const_eval_construction_test.cc @@ -1618,7 +1618,7 @@ TEST_F(ResolverConstEvalTest, Array_Struct_f32_Zero) { Member("m1", ty.f32()), Member("m2", ty.f32()), }); - auto* expr = Construct(ty.array(ty.type_name("S"), 2_u)); + auto* expr = Construct(ty.array(ty("S"), 2_u)); WrapInFunction(expr); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1853,9 +1853,9 @@ TEST_F(ResolverConstEvalTest, Array_Struct_f32_Elements) { Member("m1", ty.f32()), Member("m2", ty.f32()), }); - auto* expr = Construct(ty.array(ty.type_name("S"), 2_u), // - Construct(ty.type_name("S"), 1_f, 2_f), // - Construct(ty.type_name("S"), 3_f, 4_f)); + auto* expr = Construct(ty.array(ty("S"), 2_u), // + Construct(ty("S"), 1_f, 2_f), // + Construct(ty("S"), 3_f, 4_f)); WrapInFunction(expr); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1992,7 +1992,7 @@ TEST_F(ResolverConstEvalTest, Struct_Nested_ZeroInit) { TEST_F(ResolverConstEvalTest, Struct_I32s_ZeroInit) { Structure( "S", utils::Vector{Member("m1", ty.i32()), Member("m2", ty.i32()), Member("m3", ty.i32())}); - auto* expr = Construct(ty.type_name("S")); + auto* expr = Construct(ty("S")); WrapInFunction(expr); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -2037,7 +2037,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedScalars_ZeroInit) { Member("m4", ty.f16()), Member("m5", ty.bool_()), }); - auto* expr = Construct(ty.type_name("S")); + auto* expr = Construct(ty("S")); WrapInFunction(expr); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -2090,7 +2090,7 @@ TEST_F(ResolverConstEvalTest, Struct_VectorF32s_ZeroInit) { Member("m2", ty.vec3()), Member("m3", ty.vec3()), }); - auto* expr = Construct(ty.type_name("S")); + auto* expr = Construct(ty("S")); WrapInFunction(expr); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -2147,7 +2147,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_ZeroInit) { Member("m4", ty.vec3()), Member("m5", ty.vec2()), }); - auto* expr = Construct(ty.type_name("S")); + auto* expr = Construct(ty("S")); WrapInFunction(expr); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -2221,10 +2221,10 @@ TEST_F(ResolverConstEvalTest, Struct_Struct_ZeroInit) { }); Structure("Outer", utils::Vector{ - Member("m1", ty.type_name("Inner")), - Member("m2", ty.type_name("Inner")), + Member("m1", ty("Inner")), + Member("m2", ty("Inner")), }); - auto* expr = Construct(ty.type_name("Outer")); + auto* expr = Construct(ty("Outer")); WrapInFunction(expr); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -2267,7 +2267,7 @@ TEST_F(ResolverConstEvalTest, Struct_MixedScalars_Construct) { Member("m4", ty.f16()), Member("m5", ty.bool_()), }); - auto* expr = Construct(ty.type_name("S"), 1_i, 2_u, 3_f, 4_h, false); + auto* expr = Construct(ty("S"), 1_i, 2_u, 3_f, 4_h, false); WrapInFunction(expr); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -2324,8 +2324,8 @@ TEST_F(ResolverConstEvalTest, Struct_MixedVectors_Construct) { Member("m4", ty.vec3()), Member("m5", ty.vec2()), }); - auto* expr = Construct(ty.type_name("S"), vec2(1_i), vec3(2_u), vec4(3_f), - vec3(4_h), vec2(false)); + auto* expr = Construct(ty("S"), vec2(1_i), vec3(2_u), vec4(3_f), vec3(4_h), + vec2(false)); WrapInFunction(expr); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -2399,12 +2399,12 @@ TEST_F(ResolverConstEvalTest, Struct_Struct_Construct) { }); Structure("Outer", utils::Vector{ - Member("m1", ty.type_name("Inner")), - Member("m2", ty.type_name("Inner")), + Member("m1", ty("Inner")), + Member("m2", ty("Inner")), }); - auto* expr = Construct(ty.type_name("Outer"), // - Construct(ty.type_name("Inner"), 1_i, 2_u, 3_f), - Construct(ty.type_name("Inner"), 4_i, 0_u, 6_f)); + auto* expr = + Construct(ty("Outer"), // + Construct(ty("Inner"), 1_i, 2_u, 3_f), Construct(ty("Inner"), 4_i, 0_u, 6_f)); WrapInFunction(expr); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -2442,7 +2442,7 @@ TEST_F(ResolverConstEvalTest, Struct_Array_Construct) { Member("m1", ty.array()), Member("m2", ty.array()), }); - auto* expr = Construct(ty.type_name("S"), // + auto* expr = Construct(ty("S"), // Construct(ty.array(), 1_i, 2_i), Construct(ty.array(), 1_f, 2_f, 3_f)); WrapInFunction(expr); diff --git a/src/tint/resolver/const_eval_member_access_test.cc b/src/tint/resolver/const_eval_member_access_test.cc index 374cf46dab..f228509c70 100644 --- a/src/tint/resolver/const_eval_member_access_test.cc +++ b/src/tint/resolver/const_eval_member_access_test.cc @@ -28,12 +28,12 @@ TEST_F(ResolverConstEvalTest, StructMemberAccess) { }); Structure("Outer", utils::Vector{ - Member("o1", ty.type_name("Inner")), - Member("o2", ty.type_name("Inner")), + Member("o1", ty("Inner")), + Member("o2", ty("Inner")), }); - auto* outer_expr = Construct(ty.type_name("Outer"), // - Construct(ty.type_name("Inner"), 1_i, 2_u, 3_f, true), - Construct(ty.type_name("Inner"))); + auto* outer_expr = + Construct(ty("Outer"), // + Construct(ty("Inner"), 1_i, 2_u, 3_f, true), Construct(ty("Inner"))); auto* o1_expr = MemberAccessor(outer_expr, "o1"); auto* i2_expr = MemberAccessor(o1_expr, "i2"); WrapInFunction(i2_expr); diff --git a/src/tint/resolver/dependency_graph_test.cc b/src/tint/resolver/dependency_graph_test.cc index d63f00a562..146fd5e3f6 100644 --- a/src/tint/resolver/dependency_graph_test.cc +++ b/src/tint/resolver/dependency_graph_test.cc @@ -468,12 +468,12 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source auto& b = *builder; switch (kind) { case SymbolUseKind::GlobalVarType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); b.GlobalVar(b.Sym(), node, type::AddressSpace::kPrivate); return node; } case SymbolUseKind::GlobalVarArrayElemType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); b.GlobalVar(b.Sym(), b.ty.array(node, 4_i), type::AddressSpace::kPrivate); return node; } @@ -483,22 +483,22 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source return node; } case SymbolUseKind::GlobalVarVectorElemType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); b.GlobalVar(b.Sym(), b.ty.vec3(node), type::AddressSpace::kPrivate); return node; } case SymbolUseKind::GlobalVarMatrixElemType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); b.GlobalVar(b.Sym(), b.ty.mat3x4(node), type::AddressSpace::kPrivate); return node; } case SymbolUseKind::GlobalVarSampledTexElemType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); b.GlobalVar(b.Sym(), b.ty.sampled_texture(type::TextureDimension::k2d, node)); return node; } case SymbolUseKind::GlobalVarMultisampledTexElemType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); b.GlobalVar(b.Sym(), b.ty.multisampled_texture(type::TextureDimension::k2d, node)); return node; } @@ -508,12 +508,12 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source return node; } case SymbolUseKind::GlobalConstType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); b.GlobalConst(b.Sym(), node, b.Expr(1_i)); return node; } case SymbolUseKind::GlobalConstArrayElemType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); b.GlobalConst(b.Sym(), b.ty.array(node, 4_i), b.Expr(1_i)); return node; } @@ -523,12 +523,12 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source return node; } case SymbolUseKind::GlobalConstVectorElemType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); b.GlobalConst(b.Sym(), b.ty.vec3(node), b.Expr(1_i)); return node; } case SymbolUseKind::GlobalConstMatrixElemType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); b.GlobalConst(b.Sym(), b.ty.mat3x4(node), b.Expr(1_i)); return node; } @@ -538,12 +538,12 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source return node; } case SymbolUseKind::AliasType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); b.Alias(b.Sym(), node); return node; } case SymbolUseKind::StructMemberType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); b.Structure(b.Sym(), utils::Vector{b.Member("m", node)}); return node; } @@ -553,17 +553,17 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source return node; } case SymbolUseKind::ParameterType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); parameters.Push(b.Param(b.Sym(), node)); return node; } case SymbolUseKind::LocalVarType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); statements.Push(b.Decl(b.Var(b.Sym(), node))); return node; } case SymbolUseKind::LocalVarArrayElemType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); statements.Push(b.Decl(b.Var(b.Sym(), b.ty.array(node, 4_u), b.Expr(1_i)))); return node; } @@ -573,12 +573,12 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source return node; } case SymbolUseKind::LocalVarVectorElemType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); statements.Push(b.Decl(b.Var(b.Sym(), b.ty.vec3(node)))); return node; } case SymbolUseKind::LocalVarMatrixElemType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); statements.Push(b.Decl(b.Var(b.Sym(), b.ty.mat3x4(node)))); return node; } @@ -588,7 +588,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source return node; } case SymbolUseKind::LocalLetType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); statements.Push(b.Decl(b.Let(b.Sym(), node, b.Expr(1_i)))); return node; } @@ -598,7 +598,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source return node; } case SymbolUseKind::NestedLocalVarType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); nested_statements.Push(b.Decl(b.Var(b.Sym(), node))); return node; } @@ -608,7 +608,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source return node; } case SymbolUseKind::NestedLocalLetType: { - auto* node = b.ty.type_name(source, symbol); + auto* node = b.ty(source, symbol); nested_statements.Push(b.Decl(b.Let(b.Sym(), node, b.Expr(1_i)))); return node; } @@ -665,7 +665,7 @@ TEST_F(ResolverDependencyGraphUsedBeforeDeclTest, TypeConstructed) { // type T = i32; Func("F", utils::Empty, ty.void_(), - utils::Vector{Block(Ignore(Construct(ty.type_name(Source{{12, 34}}, "T"))))}); + utils::Vector{Block(Ignore(Construct(ty(Source{{12, 34}}, "T"))))}); Alias(Source{{56, 78}}, "T", ty.i32()); Build(); @@ -678,7 +678,7 @@ TEST_F(ResolverDependencyGraphUsedBeforeDeclTest, TypeUsedByLocal) { // type T = i32; Func("F", utils::Empty, ty.void_(), - utils::Vector{Block(Decl(Var("v", ty.type_name(Source{{12, 34}}, "T"))))}); + utils::Vector{Block(Decl(Var("v", ty(Source{{12, 34}}, "T"))))}); Alias(Source{{56, 78}}, "T", ty.i32()); Build(); @@ -688,8 +688,7 @@ TEST_F(ResolverDependencyGraphUsedBeforeDeclTest, TypeUsedByParam) { // fn F(p : T) {} // type T = i32; - Func("F", utils::Vector{Param("p", ty.type_name(Source{{12, 34}}, "T"))}, ty.void_(), - utils::Empty); + Func("F", utils::Vector{Param("p", ty(Source{{12, 34}}, "T"))}, ty.void_(), utils::Empty); Alias(Source{{56, 78}}, "T", ty.i32()); Build(); @@ -699,7 +698,7 @@ TEST_F(ResolverDependencyGraphUsedBeforeDeclTest, TypeUsedAsReturnType) { // fn F() -> T {} // type T = i32; - Func("F", utils::Empty, ty.type_name(Source{{12, 34}}, "T"), utils::Empty); + Func("F", utils::Empty, ty(Source{{12, 34}}, "T"), utils::Empty); Alias(Source{{56, 78}}, "T", ty.i32()); Build(); @@ -709,7 +708,7 @@ TEST_F(ResolverDependencyGraphUsedBeforeDeclTest, TypeByStructMember) { // struct S { m : T }; // type T = i32; - Structure("S", utils::Vector{Member("m", ty.type_name(Source{{12, 34}}, "T"))}); + Structure("S", utils::Vector{Member("m", ty(Source{{12, 34}}, "T"))}); Alias(Source{{56, 78}}, "T", ty.i32()); Build(); @@ -848,7 +847,7 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, IndirectCall) { TEST_F(ResolverDependencyGraphCyclicRefTest, Alias_Direct) { // type T = T; - Alias(Source{{12, 34}}, "T", ty.type_name(Source{{56, 78}}, "T")); + Alias(Source{{12, 34}}, "T", ty(Source{{56, 78}}, "T")); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -861,9 +860,9 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, Alias_Indirect) { // 2: type X = Y; // 3: type Z = X; - Alias(Source{{1, 1}}, "Y", ty.type_name(Source{{1, 10}}, "Z")); - Alias(Source{{2, 1}}, "X", ty.type_name(Source{{2, 10}}, "Y")); - Alias(Source{{3, 1}}, "Z", ty.type_name(Source{{3, 10}}, "X")); + Alias(Source{{1, 1}}, "Y", ty(Source{{1, 10}}, "Z")); + Alias(Source{{2, 1}}, "X", ty(Source{{2, 10}}, "Y")); + Alias(Source{{3, 1}}, "Z", ty(Source{{3, 10}}, "X")); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -878,8 +877,7 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, Struct_Direct) { // a: S; // }; - Structure(Source{{12, 34}}, "S", - utils::Vector{Member("a", ty.type_name(Source{{56, 78}}, "S"))}); + Structure(Source{{12, 34}}, "S", utils::Vector{Member("a", ty(Source{{56, 78}}, "S"))}); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -892,9 +890,9 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, Struct_Indirect) { // 2: struct X { y: Y; }; // 3: struct Z { x: X; }; - Structure(Source{{1, 1}}, "Y", utils::Vector{Member("z", ty.type_name(Source{{1, 10}}, "Z"))}); - Structure(Source{{2, 1}}, "X", utils::Vector{Member("y", ty.type_name(Source{{2, 10}}, "Y"))}); - Structure(Source{{3, 1}}, "Z", utils::Vector{Member("x", ty.type_name(Source{{3, 10}}, "X"))}); + Structure(Source{{1, 1}}, "Y", utils::Vector{Member("z", ty(Source{{1, 10}}, "Z"))}); + Structure(Source{{2, 1}}, "X", utils::Vector{Member("y", ty(Source{{2, 10}}, "Y"))}); + Structure(Source{{3, 1}}, "Z", utils::Vector{Member("x", ty(Source{{3, 10}}, "X"))}); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -968,13 +966,13 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, Mixed_RecursiveDependencies) { // 5: type R = A; // 6: const L : S = Z; - Func(Source{{1, 1}}, "F", utils::Empty, ty.type_name(Source{{1, 5}}, "R"), + Func(Source{{1, 1}}, "F", utils::Empty, ty(Source{{1, 5}}, "R"), utils::Vector{Return(Expr(Source{{1, 10}}, "Z"))}); - Alias(Source{{2, 1}}, "A", ty.type_name(Source{{2, 10}}, "S")); - Structure(Source{{3, 1}}, "S", utils::Vector{Member("a", ty.type_name(Source{{3, 10}}, "A"))}); + Alias(Source{{2, 1}}, "A", ty(Source{{2, 10}}, "S")); + Structure(Source{{3, 1}}, "S", utils::Vector{Member("a", ty(Source{{3, 10}}, "A"))}); GlobalVar(Source{{4, 1}}, "Z", Expr(Source{{4, 10}}, "L")); - Alias(Source{{5, 1}}, "R", ty.type_name(Source{{5, 10}}, "A")); - GlobalConst(Source{{6, 1}}, "L", ty.type_name(Source{{5, 5}}, "S"), Expr(Source{{5, 10}}, "Z")); + Alias(Source{{5, 1}}, "R", ty(Source{{5, 10}}, "A")); + GlobalConst(Source{{6, 1}}, "L", ty(Source{{5, 5}}, "S"), Expr(Source{{5, 10}}, "Z")); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -1232,7 +1230,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) { return use; }; #define V add_use(value_decl, Expr(value_sym), __LINE__, "V()") -#define T add_use(type_decl, ty.type_name(type_sym), __LINE__, "T()") +#define T add_use(type_decl, ty(type_sym), __LINE__, "T()") #define F add_use(func_decl, Ident(func_sym), __LINE__, "F()") Alias(Sym(), T); @@ -1334,9 +1332,9 @@ TEST_F(ResolverDependencyGraphTraversalTest, InferredType) { TEST_F(ResolverDependencyGraphTraversalTest, chromium_1273451) { Structure("A", utils::Vector{Member("a", ty.i32())}); Structure("B", utils::Vector{Member("b", ty.i32())}); - Func("f", utils::Vector{Param("a", ty.type_name("A"))}, ty.type_name("B"), + Func("f", utils::Vector{Param("a", ty("A"))}, ty("B"), utils::Vector{ - Return(Construct(ty.type_name("B"))), + Return(Construct(ty("B"))), }); Build(); } diff --git a/src/tint/resolver/evaluation_stage_test.cc b/src/tint/resolver/evaluation_stage_test.cc index 258031cb49..2b160530d0 100644 --- a/src/tint/resolver/evaluation_stage_test.cc +++ b/src/tint/resolver/evaluation_stage_test.cc @@ -270,7 +270,7 @@ TEST_F(ResolverEvaluationStageTest, MemberAccessor_Const) { // const str = S(); // str.m Structure("S", utils::Vector{Member("m", ty.i32())}); - auto* str = Const("str", Construct(ty.type_name("S"))); + auto* str = Const("str", Construct(ty("S"))); auto* expr = MemberAccessor(str, "m"); WrapInFunction(str, expr); @@ -284,7 +284,7 @@ TEST_F(ResolverEvaluationStageTest, MemberAccessor_Runtime) { // var str = S(); // str.m Structure("S", utils::Vector{Member("m", ty.i32())}); - auto* str = Var("str", Construct(ty.type_name("S"))); + auto* str = Var("str", Construct(ty("S"))); auto* expr = MemberAccessor(str, "m"); WrapInFunction(str, expr); diff --git a/src/tint/resolver/f16_extension_test.cc b/src/tint/resolver/f16_extension_test.cc index 8e5271e597..1c150ef3b5 100644 --- a/src/tint/resolver/f16_extension_test.cc +++ b/src/tint/resolver/f16_extension_test.cc @@ -123,14 +123,14 @@ TEST_P(ResolverF16ExtensionShortNameTest, Vec2hTypeUsedWithExtension) { // var v : vec2h; Enable(ast::Extension::kF16); - GlobalVar("v", ty.type_name(Source{{12, 34}}, GetParam()), type::AddressSpace::kPrivate); + GlobalVar("v", ty(Source{{12, 34}}, GetParam()), type::AddressSpace::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_P(ResolverF16ExtensionShortNameTest, Vec2hTypeUsedWithoutExtension) { // var v : vec2h; - GlobalVar("v", ty.type_name(Source{{12, 34}}, GetParam()), type::AddressSpace::kPrivate); + GlobalVar("v", ty(Source{{12, 34}}, GetParam()), type::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: f16 type used without 'f16' extension enabled"); diff --git a/src/tint/resolver/function_validation_test.cc b/src/tint/resolver/function_validation_test.cc index 0c075d71e1..4117f994d5 100644 --- a/src/tint/resolver/function_validation_test.cc +++ b/src/tint/resolver/function_validation_test.cc @@ -963,7 +963,7 @@ TEST_F(ResolverFunctionValidationTest, ReturnIsConstructible_StructOfAtomic) { Structure("S", utils::Vector{ Member("m", ty.atomic(ty.i32())), }); - auto* ret_type = ty.type_name(Source{{12, 34}}, "S"); + auto* ret_type = ty(Source{{12, 34}}, "S"); Func("f", utils::Empty, ret_type, utils::Empty); EXPECT_FALSE(r()->Resolve()); @@ -982,7 +982,7 @@ TEST_F(ResolverFunctionValidationTest, ParameterStoreType_NonAtomicFree) { Structure("S", utils::Vector{ Member("m", ty.atomic(ty.i32())), }); - auto* ret_type = ty.type_name(Source{{12, 34}}, "S"); + auto* ret_type = ty(Source{{12, 34}}, "S"); auto* bar = Param("bar", ret_type); Func("f", utils::Vector{bar}, ty.void_(), utils::Empty); @@ -994,7 +994,7 @@ TEST_F(ResolverFunctionValidationTest, ParameterSotreType_AtomicFree) { Structure("S", utils::Vector{ Member("m", ty.i32()), }); - auto* ret_type = ty.type_name(Source{{12, 34}}, "S"); + auto* ret_type = ty(Source{{12, 34}}, "S"); auto* bar = Param(Source{{12, 34}}, "bar", ret_type); Func("f", utils::Vector{bar}, ty.void_(), utils::Empty); diff --git a/src/tint/resolver/host_shareable_validation_test.cc b/src/tint/resolver/host_shareable_validation_test.cc index 10358426f7..f699135861 100644 --- a/src/tint/resolver/host_shareable_validation_test.cc +++ b/src/tint/resolver/host_shareable_validation_test.cc @@ -59,8 +59,8 @@ TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) { TEST_F(ResolverHostShareableValidationTest, Aliases) { Alias("a1", ty.bool_()); - auto* s = Structure( - "S", utils::Vector{Member(Source{{56, 78}}, "x", ty.type_name(Source{{12, 34}}, "a1"))}); + auto* s = + Structure("S", utils::Vector{Member(Source{{56, 78}}, "x", ty(Source{{12, 34}}, "a1"))}); auto* a2 = Alias("a2", ty.Of(s)); GlobalVar(Source{{90, 12}}, "g", ty.Of(a2), type::AddressSpace::kStorage, type::Access::kRead, Binding(0_a), Group(0_a)); diff --git a/src/tint/resolver/materialize_test.cc b/src/tint/resolver/materialize_test.cc index 3f7740f149..274244d8c8 100644 --- a/src/tint/resolver/materialize_test.cc +++ b/src/tint/resolver/materialize_test.cc @@ -350,7 +350,7 @@ TEST_P(MaterializeAbstractNumericToConcreteType, Test) { break; case Method::kStruct: Structure("S", utils::Vector{Member("v", target_ty())}); - WrapInFunction(Construct(ty.type_name("S"), abstract_expr)); + WrapInFunction(Construct(ty("S"), abstract_expr)); break; case Method::kBinaryOp: { // Add 0 to ensure no overflow with max float values @@ -1218,7 +1218,7 @@ using MaterializeAbstractNumericToUnrelatedType = resolver::ResolverTest; TEST_F(MaterializeAbstractNumericToUnrelatedType, AIntToStructVarInit) { Structure("S", utils::Vector{Member("a", ty.i32())}); - WrapInFunction(Decl(Var("v", ty.type_name("S"), Expr(Source{{12, 34}}, 1_a)))); + WrapInFunction(Decl(Var("v", ty("S"), Expr(Source{{12, 34}}, 1_a)))); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), @@ -1227,7 +1227,7 @@ TEST_F(MaterializeAbstractNumericToUnrelatedType, AIntToStructVarInit) { TEST_F(MaterializeAbstractNumericToUnrelatedType, AIntToStructLetInit) { Structure("S", utils::Vector{Member("a", ty.i32())}); - WrapInFunction(Decl(Let("v", ty.type_name("S"), Expr(Source{{12, 34}}, 1_a)))); + WrapInFunction(Decl(Let("v", ty("S"), Expr(Source{{12, 34}}, 1_a)))); EXPECT_FALSE(r()->Resolve()); EXPECT_THAT( r()->error(), diff --git a/src/tint/resolver/override_test.cc b/src/tint/resolver/override_test.cc index 69102c7094..813d4de37a 100644 --- a/src/tint/resolver/override_test.cc +++ b/src/tint/resolver/override_test.cc @@ -249,7 +249,7 @@ TEST_F(ResolverOverrideTest, TransitiveReferences_ViaArraySize_Alias) { auto* a = Override("a", ty.i32()); auto* b = Override("b", ty.i32(), Mul(2_a, "a")); auto* arr_ty = Alias("arr_ty", ty.array(ty.i32(), Mul(2_a, "b"))); - auto* arr = GlobalVar("arr", type::AddressSpace::kWorkgroup, ty.type_name("arr_ty")); + auto* arr = GlobalVar("arr", type::AddressSpace::kWorkgroup, ty("arr_ty")); Override("unused", ty.i32(), Expr(1_a)); auto* func = Func("foo", utils::Empty, ty.void_(), utils::Vector{ @@ -294,8 +294,8 @@ TEST_F(ResolverOverrideTest, TransitiveReferences_MultipleEntryPoints) { auto* d = Override("d", ty.i32()); Alias("arr_ty1", ty.array(ty.i32(), Mul("b1", "c1"))); Alias("arr_ty2", ty.array(ty.i32(), Mul("b2", "c2"))); - auto* arr1 = GlobalVar("arr1", type::AddressSpace::kWorkgroup, ty.type_name("arr_ty1")); - auto* arr2 = GlobalVar("arr2", type::AddressSpace::kWorkgroup, ty.type_name("arr_ty2")); + auto* arr1 = GlobalVar("arr1", type::AddressSpace::kWorkgroup, ty("arr_ty1")); + auto* arr2 = GlobalVar("arr2", type::AddressSpace::kWorkgroup, ty("arr_ty2")); Override("unused", ty.i32(), Expr(1_a)); auto* func1 = Func("foo1", utils::Empty, ty.void_(), utils::Vector{ diff --git a/src/tint/resolver/resolver_test_helper.h b/src/tint/resolver/resolver_test_helper.h index 647e3eeacb..d5a669838c 100644 --- a/src/tint/resolver/resolver_test_helper.h +++ b/src/tint/resolver/resolver_test_helper.h @@ -565,7 +565,7 @@ struct DataType> { auto* type = DataType::AST(b); b.AST().AddTypeDecl(b.ty.alias(name, type)); } - return b.ty.type_name(name); + return b.ty(name); } /// @param b the ProgramBuilder /// @return the semantic aliased type diff --git a/src/tint/resolver/type_validation_test.cc b/src/tint/resolver/type_validation_test.cc index c75db20d86..1b2597c38b 100644 --- a/src/tint/resolver/type_validation_test.cc +++ b/src/tint/resolver/type_validation_test.cc @@ -362,7 +362,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_NestedStorageBufferLargeArray) { // var a : S; Structure("S", utils::Vector{Member(Source{{12, 34}}, "a", ty.array(Source{{12, 20}}, ty.f32(), 65536_a))}); - GlobalVar("a", ty.type_name(Source{{12, 30}}, "S"), type::AddressSpace::kStorage, + GlobalVar("a", ty(Source{{12, 30}}, "S"), type::AddressSpace::kStorage, utils::Vector{Binding(0_u), Group(0_u)}); EXPECT_TRUE(r()->Resolve()) << r()->error(); } @@ -374,7 +374,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ImplicitStride) { // var a : array; Structure("S", utils::Vector{Member(Source{{12, 34}}, "a", ty.f32(), utils::Vector{MemberOffset(800000_a)})}); - GlobalVar("a", ty.array(ty.type_name(Source{{12, 30}}, "S"), Expr(Source{{12, 34}}, 65535_a)), + GlobalVar("a", ty.array(ty(Source{{12, 30}}, "S"), Expr(Source{{12, 34}}, 65535_a)), type::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -640,11 +640,11 @@ TEST_F(ResolverTypeValidationTest, Struct_TooBig) { // } Structure(Source{{10, 34}}, "Bar", utils::Vector{Member("a", ty.array())}); - Structure(Source{{12, 34}}, "Foo", - utils::Vector{Member("a", ty.array(ty.type_name(Source{{12, 30}}, "Bar"), - Expr(Source{{12, 34}}, 65535_a))), - Member("b", ty.array(ty.type_name(Source{{12, 30}}, "Bar"), - Expr(Source{{12, 34}}, 65535_a)))}); + Structure( + Source{{12, 34}}, "Foo", + utils::Vector{ + Member("a", ty.array(ty(Source{{12, 30}}, "Bar"), Expr(Source{{12, 34}}, 65535_a))), + Member("b", ty.array(ty(Source{{12, 30}}, "Bar"), Expr(Source{{12, 34}}, 65535_a)))}); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -705,8 +705,7 @@ TEST_F(ResolverTypeValidationTest, RuntimeArrayInStructInArray) { // var a : array; Structure("Foo", utils::Vector{Member("rt", ty.array())}); - GlobalVar("v", ty.array(ty.type_name(Source{{12, 34}}, "Foo"), 4_u), - type::AddressSpace::kPrivate); + GlobalVar("v", ty.array(ty(Source{{12, 34}}, "Foo"), 4_u), type::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()) << r()->error(); EXPECT_EQ(r()->error(), @@ -886,7 +885,7 @@ TEST_F(ResolverTypeValidationTest, VariableAsType) { // var a : i32; // var b : a; GlobalVar("a", ty.i32(), type::AddressSpace::kPrivate); - GlobalVar("b", ty.type_name("a"), type::AddressSpace::kPrivate); + GlobalVar("b", ty("a"), type::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -898,7 +897,7 @@ TEST_F(ResolverTypeValidationTest, FunctionAsType) { // fn f() {} // var v : f; Func("f", utils::Empty, ty.void_(), {}); - GlobalVar("v", ty.type_name("f"), type::AddressSpace::kPrivate); + GlobalVar("v", ty("f"), type::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -908,7 +907,7 @@ note: 'f' declared here)"); TEST_F(ResolverTypeValidationTest, BuiltinAsType) { // var v : max; - GlobalVar("v", ty.type_name("max"), type::AddressSpace::kPrivate); + GlobalVar("v", ty("max"), type::AddressSpace::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "error: cannot use builtin 'max' as type"); @@ -1426,7 +1425,7 @@ TEST_P(BuiltinTypeAliasTest, CheckEquivalent) { Enable(ast::Extension::kF16); - WrapInFunction(Decl(Var("aliased", ty.type_name(params.alias))), + WrapInFunction(Decl(Var("aliased", ty(params.alias))), Decl(Var("explicit", params.type(*this))), // Assign("explicit", "aliased")); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1438,7 +1437,7 @@ TEST_P(BuiltinTypeAliasTest, Construct) { Enable(ast::Extension::kF16); - WrapInFunction(Decl(Var("v", params.type(*this), Construct(ty.type_name(params.alias))))); + WrapInFunction(Decl(Var("v", params.type(*this), Construct(ty(params.alias))))); EXPECT_TRUE(r()->Resolve()) << r()->error(); } INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest, diff --git a/src/tint/resolver/variable_test.cc b/src/tint/resolver/variable_test.cc index b62812a41e..54629e3517 100644 --- a/src/tint/resolver/variable_test.cc +++ b/src/tint/resolver/variable_test.cc @@ -902,7 +902,7 @@ TEST_F(ResolverVariableTest, LocalConst_ExplicitType_Decls) { auto* c_vu32 = Const("e", ty.vec3(), vec3()); auto* c_vf32 = Const("f", ty.vec3(), vec3()); auto* c_mf32 = Const("g", ty.mat3x3(), mat3x3()); - auto* c_s = Const("h", ty.type_name("S"), Construct(ty.type_name("S"))); + auto* c_s = Const("h", ty("S"), Construct(ty("S"))); WrapInFunction(c_i32, c_u32, c_f32, c_vi32, c_vu32, c_vf32, c_mf32, c_s); @@ -954,7 +954,7 @@ TEST_F(ResolverVariableTest, LocalConst_ImplicitType_Decls) { Construct(ty.vec(nullptr, 3), Expr(0._a)), Construct(ty.vec(nullptr, 3), Expr(0._a)), Construct(ty.vec(nullptr, 3), Expr(0._a)))); - auto* c_s = Const("m", Construct(ty.type_name("S"))); + auto* c_s = Const("m", Construct(ty("S"))); WrapInFunction(c_i32, c_u32, c_f32, c_ai, c_af, c_vi32, c_vu32, c_vf32, c_vai, c_vaf, c_mf32, c_maf32, c_s); @@ -1265,7 +1265,7 @@ TEST_F(ResolverVariableTest, Param_ShadowsAlias) { // } auto* a = Alias("a", ty.i32()); - auto* p = Param("a", ty.type_name("a")); + auto* p = Param("a", ty("a")); Func("F", utils::Vector{p}, ty.void_(), utils::Empty); ASSERT_TRUE(r()->Resolve()) << r()->error(); diff --git a/src/tint/transform/canonicalize_entry_point_io.cc b/src/tint/transform/canonicalize_entry_point_io.cc index f17bc90f32..61bb6ae1b8 100644 --- a/src/tint/transform/canonicalize_entry_point_io.cc +++ b/src/tint/transform/canonicalize_entry_point_io.cc @@ -459,7 +459,7 @@ struct CanonicalizeEntryPointIO::State { ctx.InsertBefore(ctx.src->AST().GlobalDeclarations(), func_ast, in_struct); // Create a new function parameter using this struct type. - auto* param = ctx.dst->Param(InputStructSymbol(), ctx.dst->ty.type_name(struct_name)); + auto* param = ctx.dst->Param(InputStructSymbol(), ctx.dst->ty(struct_name)); wrapper_ep_parameters.Push(param); } @@ -503,7 +503,7 @@ struct CanonicalizeEntryPointIO::State { ctx.InsertBefore(ctx.src->AST().GlobalDeclarations(), func_ast, out_struct); // Create the output struct object, assign its members, and return it. - auto* result_object = ctx.dst->Var(wrapper_result, ctx.dst->ty.type_name(out_struct->name)); + auto* result_object = ctx.dst->Var(wrapper_result, ctx.dst->ty(out_struct->name)); wrapper_body.Push(ctx.dst->Decl(result_object)); for (auto* assignment : assignments) { wrapper_body.Push(assignment); @@ -633,9 +633,7 @@ struct CanonicalizeEntryPointIO::State { CreateGlobalOutputVariables(); } else { auto* output_struct = CreateOutputStruct(); - wrapper_ret_type = [&, output_struct] { - return ctx.dst->ty.type_name(output_struct->name); - }; + wrapper_ret_type = [&, output_struct] { return ctx.dst->ty(output_struct->name); }; } } diff --git a/src/tint/transform/clamp_frag_depth.cc b/src/tint/transform/clamp_frag_depth.cc index 6b1580969c..b8ba51139a 100644 --- a/src/tint/transform/clamp_frag_depth.cc +++ b/src/tint/transform/clamp_frag_depth.cc @@ -124,7 +124,7 @@ Transform::ApplyResult ClampFragDepth::Apply(const Program* src, const DataMap&, utils::Vector{b.Member("min", b.ty.f32()), b.Member("max", b.ty.f32())}); auto args_sym = b.Symbols().New("frag_depth_clamp_args"); - b.GlobalVar(args_sym, b.ty.type_name("FragDepthClampArgs"), type::AddressSpace::kPushConstant); + b.GlobalVar(args_sym, b.ty("FragDepthClampArgs"), type::AddressSpace::kPushConstant); auto base_fn_sym = b.Symbols().New("clamp_frag_depth"); b.Func(base_fn_sym, utils::Vector{b.Param("v", b.ty.f32())}, b.ty.f32(), diff --git a/src/tint/transform/decompose_strided_array.cc b/src/tint/transform/decompose_strided_array.cc index 4f5410f45c..129e417136 100644 --- a/src/tint/transform/decompose_strided_array.cc +++ b/src/tint/transform/decompose_strided_array.cc @@ -87,7 +87,7 @@ Transform::ApplyResult DecomposeStridedArray::Apply(const Program* src, return name; }); auto* count = ctx.Clone(ast->count); - return b.ty.array(b.ty.type_name(el_ty), count); + return b.ty.array(b.ty(el_ty), count); } if (ast::GetAttribute(ast->attributes)) { // Strip the @stride attribute diff --git a/src/tint/transform/decompose_strided_array_test.cc b/src/tint/transform/decompose_strided_array_test.cc index abc01f2295..0f1e21c4d3 100644 --- a/src/tint/transform/decompose_strided_array_test.cc +++ b/src/tint/transform/decompose_strided_array_test.cc @@ -510,16 +510,15 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) { // } ProgramBuilder b; b.Alias("ARR", b.ty.array(32)); - auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.type_name("ARR"))}); + auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty("ARR"))}); b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ - b.Decl(b.Let("a", b.ty.type_name("ARR"), b.MemberAccessor("s", "a"))), + b.Decl(b.Let("a", b.ty("ARR"), b.MemberAccessor("s", "a"))), b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i))), - b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.type_name("ARR"))), - b.Assign(b.MemberAccessor("s", "a"), - b.Construct(b.ty.type_name("ARR"), 1_f, 2_f, 3_f, 4_f)), + b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty("ARR"))), + b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty("ARR"), 1_f, 2_f, 3_f, 4_f)), b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5_f), }, utils::Vector{ @@ -577,20 +576,20 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) { ProgramBuilder b; b.Alias("ARR_A", b.ty.array(8)); b.Alias("ARR_B", - b.ty.array( // - b.ty.array(b.ty.type_name("ARR_A"), 3_u, 16), // + b.ty.array( // + b.ty.array(b.ty("ARR_A"), 3_u, 16), // 4_u, 128)); - auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.type_name("ARR_B"))}); + auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty("ARR_B"))}); b.GlobalVar("s", b.ty.Of(S), type::AddressSpace::kStorage, type::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ - b.Decl(b.Let("a", b.ty.type_name("ARR_B"), b.MemberAccessor("s", "a"))), - b.Decl(b.Let("b", b.ty.array(b.ty.type_name("ARR_A"), 3_u, 16), + b.Decl(b.Let("a", b.ty("ARR_B"), b.MemberAccessor("s", "a"))), + b.Decl(b.Let("b", b.ty.array(b.ty("ARR_A"), 3_u, 16), b.IndexAccessor( // b.MemberAccessor("s", "a"), // 3_i))), - b.Decl(b.Let("c", b.ty.type_name("ARR_A"), + b.Decl(b.Let("c", b.ty("ARR_A"), b.IndexAccessor( // b.IndexAccessor( // b.MemberAccessor("s", "a"), // @@ -604,7 +603,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) { 3_i), 2_i), 1_i))), - b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.type_name("ARR_B"))), + b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty("ARR_B"))), b.Assign(b.IndexAccessor( // b.IndexAccessor( // b.IndexAccessor( // diff --git a/src/tint/transform/demote_to_helper.cc b/src/tint/transform/demote_to_helper.cc index 48a76b7cba..3763f7ca0c 100644 --- a/src/tint/transform/demote_to_helper.cc +++ b/src/tint/transform/demote_to_helper.cc @@ -187,7 +187,7 @@ Transform::ApplyResult DemoteToHelper::Apply(const Program* src, const DataMap&, // Declare a struct to hold the result values. auto* result_struct = sem_call->Type()->As(); auto* atomic_ty = result_struct->Members()[0]->Type(); - result_ty = b.ty.type_name( + result_ty = b.ty( utils::GetOrCreate(atomic_cmpxchg_result_types, atomic_ty, [&]() { auto name = b.Sym(); b.Structure( diff --git a/src/tint/transform/direct_variable_access.cc b/src/tint/transform/direct_variable_access.cc index a46b384e4c..c2a4234b5c 100644 --- a/src/tint/transform/direct_variable_access.cc +++ b/src/tint/transform/direct_variable_access.cc @@ -1075,7 +1075,7 @@ struct DirectVariableAccess::State { b.Alias(symbol, b.ty.array(b.ty.u32(), u32(num_dyn_indices))); return symbol; }); - return name.IsValid() ? b.ty.type_name(name) : nullptr; + return name.IsValid() ? b.ty(name) : nullptr; } /// @returns a name describing the given shape diff --git a/src/tint/transform/multiplanar_external_texture.cc b/src/tint/transform/multiplanar_external_texture.cc index ebb6d7b6e3..652023e53d 100644 --- a/src/tint/transform/multiplanar_external_texture.cc +++ b/src/tint/transform/multiplanar_external_texture.cc @@ -144,9 +144,8 @@ struct MultiplanarExternalTexture::State { b.GlobalVar(syms.plane_1, b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32()), b.Group(AInt(bps.plane_1.group)), b.Binding(AInt(bps.plane_1.binding))); syms.params = b.Symbols().New("ext_tex_params"); - b.GlobalVar(syms.params, b.ty.type_name("ExternalTextureParams"), - type::AddressSpace::kUniform, b.Group(AInt(bps.params.group)), - b.Binding(AInt(bps.params.binding))); + b.GlobalVar(syms.params, b.ty("ExternalTextureParams"), type::AddressSpace::kUniform, + b.Group(AInt(bps.params.group)), b.Binding(AInt(bps.params.binding))); // Replace the original texture_external binding with a texture_2d binding. auto cloned_attributes = ctx.Clone(global->attributes); @@ -184,7 +183,7 @@ struct MultiplanarExternalTexture::State { ctx.Replace(param, b.Param(syms.plane_0, tex2d_f32())); ctx.InsertAfter(fn->params, param, b.Param(syms.plane_1, tex2d_f32())); ctx.InsertAfter(fn->params, param, - b.Param(syms.params, b.ty.type_name(params_struct_sym))); + b.Param(syms.params, b.ty(params_struct_sym))); } } } @@ -261,8 +260,8 @@ struct MultiplanarExternalTexture::State { b.Member("numPlanes", b.ty.u32()), b.Member("doYuvToRgbConversionOnly", b.ty.u32()), b.Member("yuvToRgbConversionMatrix", b.ty.mat3x4()), - b.Member("gammaDecodeParams", b.ty.type_name("GammaTransferParams")), - b.Member("gammaEncodeParams", b.ty.type_name("GammaTransferParams")), + b.Member("gammaDecodeParams", b.ty("GammaTransferParams")), + b.Member("gammaEncodeParams", b.ty("GammaTransferParams")), b.Member("gamutConversionMatrix", b.ty.mat3x3()), b.Member("coordTransformationMatrix", b.ty.mat3x2())}; @@ -280,7 +279,7 @@ struct MultiplanarExternalTexture::State { gamma_correction_sym, utils::Vector{ b.Param("v", b.ty.vec3()), - b.Param("params", b.ty.type_name(gamma_transfer_struct_sym)), + b.Param("params", b.ty(gamma_transfer_struct_sym)), }, b.ty.vec3(), utils::Vector{ @@ -428,7 +427,7 @@ struct MultiplanarExternalTexture::State { b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32())), b.Param("smp", b.ty.sampler(type::SamplerKind::kSampler)), b.Param("coord", b.ty.vec2(b.ty.f32())), - b.Param("params", b.ty.type_name(params_struct_sym)), + b.Param("params", b.ty(params_struct_sym)), }, b.ty.vec4(b.ty.f32()), buildTextureBuiltinBody(sem::BuiltinType::kTextureSampleBaseClampToEdge)); @@ -475,7 +474,7 @@ struct MultiplanarExternalTexture::State { b.Param("plane1", b.ty.sampled_texture(type::TextureDimension::k2d, b.ty.f32())), b.Param("coord", CreateASTTypeFor(ctx, coord_ty)), - b.Param("params", b.ty.type_name(params_struct_sym)), + b.Param("params", b.ty(params_struct_sym)), }, b.ty.vec4(b.ty.f32()), // buildTextureBuiltinBody(sem::BuiltinType::kTextureLoad)); diff --git a/src/tint/transform/spirv_atomic.cc b/src/tint/transform/spirv_atomic.cc index 915da00d4a..9ad5b3edcb 100644 --- a/src/tint/transform/spirv_atomic.cc +++ b/src/tint/transform/spirv_atomic.cc @@ -197,7 +197,7 @@ struct SpirvAtomic::State { ty, // [&](const type::I32*) { return b.ty.atomic(CreateASTTypeFor(ctx, ty)); }, [&](const type::U32*) { return b.ty.atomic(CreateASTTypeFor(ctx, ty)); }, - [&](const sem::Struct* str) { return b.ty.type_name(Fork(str->Declaration()).name); }, + [&](const sem::Struct* str) { return b.ty(Fork(str->Declaration()).name); }, [&](const type::Array* arr) -> const ast::Type* { if (arr->Count()->Is()) { return b.ty.array(AtomicTypeFor(arr->ElemType())); diff --git a/src/tint/transform/std140.cc b/src/tint/transform/std140.cc index cc497a23d1..c66e396b75 100644 --- a/src/tint/transform/std140.cc +++ b/src/tint/transform/std140.cc @@ -405,7 +405,7 @@ struct Std140::State { ty, // [&](const sem::Struct* str) -> const ast::Type* { if (auto std140 = std140_structs.Find(str)) { - return b.ty.type_name(*std140); + return b.ty(*std140); } return nullptr; }, @@ -423,7 +423,7 @@ struct Std140::State { utils::Transform(members, [&](auto* member) { return member->symbol; }), }; }); - return b.ty.type_name(std140_mat.name); + return b.ty(std140_mat.name); } return nullptr; }, diff --git a/src/tint/transform/transform.cc b/src/tint/transform/transform.cc index 2076e066e6..d50d5c3d36 100644 --- a/src/tint/transform/transform.cc +++ b/src/tint/transform/transform.cc @@ -122,7 +122,7 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type if (auto* alias = type_decl->As()) { if (ty == ctx.src->Sem().Get(alias)) { // Alias found. Use the alias name to ensure types compare equal. - return ctx.dst->ty.type_name(ctx.Clone(alias->name)); + return ctx.dst->ty(ctx.Clone(alias->name)); } } } @@ -138,7 +138,7 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type return ctx.dst->ty.array(el, u32(count.value()), std::move(attrs)); } if (auto* s = ty->As()) { - return ctx.dst->ty.type_name(ctx.Clone(s->Declaration()->name)); + return ctx.dst->ty(ctx.Clone(s->Declaration()->name)); } if (auto* s = ty->As()) { return CreateASTTypeFor(ctx, s->StoreType()); diff --git a/src/tint/transform/truncate_interstage_variables.cc b/src/tint/transform/truncate_interstage_variables.cc index b2d7ff1dd8..d7d811f5a3 100644 --- a/src/tint/transform/truncate_interstage_variables.cc +++ b/src/tint/transform/truncate_interstage_variables.cc @@ -139,15 +139,15 @@ Transform::ApplyResult TruncateInterstageVariables::Apply(const Program* src, // Create the mapping function to truncate the shader io. auto mapping_fn_sym = b.Symbols().New("truncate_shader_output"); - b.Func(mapping_fn_sym, - utils::Vector{b.Param("io", ctx.Clone(func_ast->return_type))}, - b.ty.type_name(new_struct_sym), - utils::Vector{b.Return(b.Construct(b.ty.type_name(new_struct_sym), - std::move(initializer_exprs)))}); + b.Func( + mapping_fn_sym, utils::Vector{b.Param("io", ctx.Clone(func_ast->return_type))}, + b.ty(new_struct_sym), + utils::Vector{ + b.Return(b.Construct(b.ty(new_struct_sym), std::move(initializer_exprs)))}); return TruncatedStructAndConverter{new_struct_sym, mapping_fn_sym}; }); - ctx.Replace(func_ast->return_type, b.ty.type_name(entry.truncated_struct)); + ctx.Replace(func_ast->return_type, b.ty(entry.truncated_struct)); entry_point_functions_to_truncate_functions.Add(func_sem, entry.truncate_fn); } diff --git a/src/tint/type/struct_test.cc b/src/tint/type/struct_test.cc index ff72d0b7e6..6434a24ad9 100644 --- a/src/tint/type/struct_test.cc +++ b/src/tint/type/struct_test.cc @@ -60,7 +60,7 @@ TEST_F(TypeStructTest, Layout) { }); auto* outer_st = Structure("Outer", utils::Vector{ - Member("inner", ty.type_name("Inner")), + Member("inner", ty("Inner")), Member("a", ty.i32()), }); @@ -118,13 +118,13 @@ TEST_F(TypeStructTest, IsConstructable) { }); auto* outer = Structure("Outer", utils::Vector{ - Member("inner", ty.type_name("Inner")), + Member("inner", ty("Inner")), Member("a", ty.i32()), }); auto* outer_runtime_sized_array = Structure("OuterRuntimeSizedArray", utils::Vector{ - Member("inner", ty.type_name("Inner")), + Member("inner", ty("Inner")), Member("a", ty.i32()), Member("runtime_sized_array", ty.array()), }); @@ -152,12 +152,12 @@ TEST_F(TypeStructTest, HasCreationFixedFootprint) { }); auto* outer = Structure("Outer", utils::Vector{ - Member("inner", ty.type_name("Inner")), + Member("inner", ty("Inner")), }); auto* outer_with_runtime_sized_array = Structure("OuterRuntimeSizedArray", utils::Vector{ - Member("inner", ty.type_name("Inner")), + Member("inner", ty("Inner")), Member("runtime_sized_array", ty.array()), }); @@ -185,12 +185,12 @@ TEST_F(TypeStructTest, HasFixedFootprint) { }); auto* outer = Structure("Outer", utils::Vector{ - Member("inner", ty.type_name("Inner")), + Member("inner", ty("Inner")), }); auto* outer_with_runtime_sized_array = Structure("OuterRuntimeSizedArray", utils::Vector{ - Member("inner", ty.type_name("Inner")), + Member("inner", ty("Inner")), Member("runtime_sized_array", ty.array()), }); diff --git a/src/tint/writer/glsl/generator_impl_variable_decl_statement_test.cc b/src/tint/writer/glsl/generator_impl_variable_decl_statement_test.cc index 2cbea9540b..eced7dd125 100644 --- a/src/tint/writer/glsl/generator_impl_variable_decl_statement_test.cc +++ b/src/tint/writer/glsl/generator_impl_variable_decl_statement_test.cc @@ -411,7 +411,7 @@ void f() { TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const_arr_struct_zero) { Structure("S", utils::Vector{Member("a", ty.i32()), Member("b", ty.f32())}); - auto* C = Const("C", Construct(ty.array(ty.type_name("S"), 2_i))); + auto* C = Const("C", Construct(ty.array(ty("S"), 2_i))); Func("f", utils::Empty, ty.void_(), utils::Vector{ Decl(C), diff --git a/src/tint/writer/msl/generator_impl_test.cc b/src/tint/writer/msl/generator_impl_test.cc index ff3a4c997a..6a0a9922de 100644 --- a/src/tint/writer/msl/generator_impl_test.cc +++ b/src/tint/writer/msl/generator_impl_test.cc @@ -262,9 +262,9 @@ TEST_F(MslGeneratorImplTest, WorkgroupMatrixInStruct) { Member("m2", ty.mat4x4()), }); Structure("S2", utils::Vector{ - Member("s", ty.type_name("S1")), + Member("s", ty("S1")), }); - GlobalVar("s", ty.type_name("S2"), type::AddressSpace::kWorkgroup); + GlobalVar("s", ty("S2"), type::AddressSpace::kWorkgroup); Func("comp_main", utils::Empty, ty.void_(), utils::Vector{Decl(Let("x", Expr("s")))}, utils::Vector{ Stage(ast::PipelineStage::kCompute),