From c4e076ffe6365b8e5254488362340cfbb355efc6 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Thu, 8 Sep 2022 01:04:34 +0000 Subject: [PATCH] Rename attribute values. This CL renames the attributes to store `expr` instead of `value`. This closer matches what is stored. Bug: tint:1633 Change-Id: If1db34d1f9186afa111c394f18ed049dd2f56f91 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/101525 Reviewed-by: Ben Clayton Commit-Queue: Dan Sinclair Kokoro: Kokoro --- src/tint/ast/binding_attribute.cc | 8 +++--- src/tint/ast/binding_attribute.h | 8 +++--- src/tint/ast/binding_attribute_test.cc | 2 +- src/tint/ast/group_attribute.cc | 8 +++--- src/tint/ast/group_attribute.h | 8 +++--- src/tint/ast/group_attribute_test.cc | 2 +- src/tint/ast/id_attribute.cc | 8 +++--- src/tint/ast/id_attribute.h | 8 +++--- src/tint/ast/id_attribute_test.cc | 2 +- src/tint/ast/location_attribute.cc | 8 +++--- src/tint/ast/location_attribute.h | 8 +++--- src/tint/ast/location_attribute_test.cc | 2 +- src/tint/ast/struct_member_align_attribute.cc | 6 ++-- src/tint/ast/struct_member_align_attribute.h | 6 ++-- .../ast/struct_member_align_attribute_test.cc | 4 +-- src/tint/ast/variable_test.cc | 4 +-- src/tint/reader/spirv/function.cc | 3 +- .../wgsl/parser_impl_function_decl_test.cc | 4 +-- .../wgsl/parser_impl_function_header_test.cc | 4 +-- .../parser_impl_global_constant_decl_test.cc | 4 +-- .../wgsl/parser_impl_param_list_test.cc | 4 +-- ...arser_impl_struct_member_attribute_test.cc | 10 +++---- .../wgsl/parser_impl_struct_member_test.cc | 9 +++--- ...arser_impl_variable_attribute_list_test.cc | 5 ++-- .../parser_impl_variable_attribute_test.cc | 28 ++++++++----------- src/tint/resolver/resolver.cc | 22 +++++++-------- src/tint/writer/wgsl/generator_impl.cc | 10 +++---- 27 files changed, 94 insertions(+), 101 deletions(-) diff --git a/src/tint/ast/binding_attribute.cc b/src/tint/ast/binding_attribute.cc index 405fe98658..38f1d0f889 100644 --- a/src/tint/ast/binding_attribute.cc +++ b/src/tint/ast/binding_attribute.cc @@ -25,8 +25,8 @@ namespace tint::ast { BindingAttribute::BindingAttribute(ProgramID pid, NodeID nid, const Source& src, - const ast::Expression* val) - : Base(pid, nid, src), value(val) {} + const ast::Expression* exp) + : Base(pid, nid, src), expr(exp) {} BindingAttribute::~BindingAttribute() = default; @@ -37,8 +37,8 @@ std::string BindingAttribute::Name() const { const BindingAttribute* BindingAttribute::Clone(CloneContext* ctx) const { // Clone arguments outside of create() call to have deterministic ordering auto src = ctx->Clone(source); - auto* value_ = ctx->Clone(value); - return ctx->dst->create(src, value_); + auto* expr_ = ctx->Clone(expr); + return ctx->dst->create(src, expr_); } } // namespace tint::ast diff --git a/src/tint/ast/binding_attribute.h b/src/tint/ast/binding_attribute.h index 39ca2b67f5..7bb7add6a2 100644 --- a/src/tint/ast/binding_attribute.h +++ b/src/tint/ast/binding_attribute.h @@ -29,8 +29,8 @@ class BindingAttribute final : public Castable { /// @param pid the identifier of the program that owns this node /// @param nid the unique node identifier /// @param src the source of this node - /// @param value the binding value expression - BindingAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* value); + /// @param expr the binding expression + BindingAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* expr); ~BindingAttribute() override; /// @returns the WGSL name for the attribute @@ -42,8 +42,8 @@ class BindingAttribute final : public Castable { /// @return the newly cloned node const BindingAttribute* Clone(CloneContext* ctx) const override; - /// the binding value expression - const ast::Expression* const value; + /// the binding expression + const ast::Expression* const expr; }; } // namespace tint::ast diff --git a/src/tint/ast/binding_attribute_test.cc b/src/tint/ast/binding_attribute_test.cc index ec8538cdf9..941bd68147 100644 --- a/src/tint/ast/binding_attribute_test.cc +++ b/src/tint/ast/binding_attribute_test.cc @@ -22,7 +22,7 @@ using BindingAttributeTest = TestHelper; TEST_F(BindingAttributeTest, Creation) { auto* d = Binding(2_a); - EXPECT_TRUE(d->value->Is()); + EXPECT_TRUE(d->expr->Is()); } } // namespace diff --git a/src/tint/ast/group_attribute.cc b/src/tint/ast/group_attribute.cc index 9f44003a54..ff60bd573a 100644 --- a/src/tint/ast/group_attribute.cc +++ b/src/tint/ast/group_attribute.cc @@ -25,8 +25,8 @@ namespace tint::ast { GroupAttribute::GroupAttribute(ProgramID pid, NodeID nid, const Source& src, - const ast::Expression* val) - : Base(pid, nid, src), value(val) {} + const ast::Expression* exp) + : Base(pid, nid, src), expr(exp) {} GroupAttribute::~GroupAttribute() = default; @@ -37,8 +37,8 @@ std::string GroupAttribute::Name() const { const GroupAttribute* GroupAttribute::Clone(CloneContext* ctx) const { // Clone arguments outside of create() call to have deterministic ordering auto src = ctx->Clone(source); - auto* value_ = ctx->Clone(value); - return ctx->dst->create(src, value_); + auto* expr_ = ctx->Clone(expr); + return ctx->dst->create(src, expr_); } } // namespace tint::ast diff --git a/src/tint/ast/group_attribute.h b/src/tint/ast/group_attribute.h index 5110489f51..552a69f6a4 100644 --- a/src/tint/ast/group_attribute.h +++ b/src/tint/ast/group_attribute.h @@ -29,8 +29,8 @@ class GroupAttribute final : public Castable { /// @param pid the identifier of the program that owns this node /// @param nid the unique node identifier /// @param src the source of this node - /// @param value the group value expression - GroupAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* value); + /// @param expr the group expression + GroupAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* expr); ~GroupAttribute() override; /// @returns the WGSL name for the attribute @@ -42,8 +42,8 @@ class GroupAttribute final : public Castable { /// @return the newly cloned node const GroupAttribute* Clone(CloneContext* ctx) const override; - /// The group value expression - const ast::Expression* const value; + /// The group expression + const ast::Expression* const expr; }; } // namespace tint::ast diff --git a/src/tint/ast/group_attribute_test.cc b/src/tint/ast/group_attribute_test.cc index 616ea37aa8..c8e2130b57 100644 --- a/src/tint/ast/group_attribute_test.cc +++ b/src/tint/ast/group_attribute_test.cc @@ -22,7 +22,7 @@ using GroupAttributeTest = TestHelper; TEST_F(GroupAttributeTest, Creation) { auto* d = Group(2_a); - EXPECT_TRUE(d->value->Is()); + EXPECT_TRUE(d->expr->Is()); } } // namespace diff --git a/src/tint/ast/id_attribute.cc b/src/tint/ast/id_attribute.cc index 9c1d1ae09e..0515f01caf 100644 --- a/src/tint/ast/id_attribute.cc +++ b/src/tint/ast/id_attribute.cc @@ -22,8 +22,8 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IdAttribute); namespace tint::ast { -IdAttribute::IdAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* val) - : Base(pid, nid, src), value(val) {} +IdAttribute::IdAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* exp) + : Base(pid, nid, src), expr(exp) {} IdAttribute::~IdAttribute() = default; @@ -34,8 +34,8 @@ std::string IdAttribute::Name() const { const IdAttribute* IdAttribute::Clone(CloneContext* ctx) const { // Clone arguments outside of create() call to have deterministic ordering auto src = ctx->Clone(source); - auto* value_ = ctx->Clone(value); - return ctx->dst->create(src, value_); + auto* expr_ = ctx->Clone(expr); + return ctx->dst->create(src, expr_); } } // namespace tint::ast diff --git a/src/tint/ast/id_attribute.h b/src/tint/ast/id_attribute.h index f707bdee21..f683080d95 100644 --- a/src/tint/ast/id_attribute.h +++ b/src/tint/ast/id_attribute.h @@ -29,8 +29,8 @@ class IdAttribute final : public Castable { /// @param pid the identifier of the program that owns this node /// @param nid the unique node identifier /// @param src the source of this node - /// @param val the numeric id value expression - IdAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* val); + /// @param expr the numeric id expression + IdAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* expr); ~IdAttribute() override; /// @returns the WGSL name for the attribute @@ -42,8 +42,8 @@ class IdAttribute final : public Castable { /// @return the newly cloned node const IdAttribute* Clone(CloneContext* ctx) const override; - /// The id value expression - const ast::Expression* const value; + /// The id expression + const ast::Expression* const expr; }; } // namespace tint::ast diff --git a/src/tint/ast/id_attribute_test.cc b/src/tint/ast/id_attribute_test.cc index 84605b1a62..eeef23b0bb 100644 --- a/src/tint/ast/id_attribute_test.cc +++ b/src/tint/ast/id_attribute_test.cc @@ -24,7 +24,7 @@ using IdAttributeTest = TestHelper; TEST_F(IdAttributeTest, Creation) { auto* d = Id(12_a); - EXPECT_TRUE(d->value->Is()); + EXPECT_TRUE(d->expr->Is()); } } // namespace diff --git a/src/tint/ast/location_attribute.cc b/src/tint/ast/location_attribute.cc index e1d101b6f2..4f34144b0a 100644 --- a/src/tint/ast/location_attribute.cc +++ b/src/tint/ast/location_attribute.cc @@ -25,8 +25,8 @@ namespace tint::ast { LocationAttribute::LocationAttribute(ProgramID pid, NodeID nid, const Source& src, - const ast::Expression* val) - : Base(pid, nid, src), value(val) {} + const ast::Expression* exp) + : Base(pid, nid, src), expr(exp) {} LocationAttribute::~LocationAttribute() = default; @@ -37,8 +37,8 @@ std::string LocationAttribute::Name() const { const LocationAttribute* LocationAttribute::Clone(CloneContext* ctx) const { // Clone arguments outside of create() call to have deterministic ordering auto src = ctx->Clone(source); - auto value_ = ctx->Clone(value); - return ctx->dst->create(src, value_); + auto expr_ = ctx->Clone(expr); + return ctx->dst->create(src, expr_); } } // namespace tint::ast diff --git a/src/tint/ast/location_attribute.h b/src/tint/ast/location_attribute.h index 48c623f1a3..43d5edf15e 100644 --- a/src/tint/ast/location_attribute.h +++ b/src/tint/ast/location_attribute.h @@ -29,8 +29,8 @@ class LocationAttribute final : public Castable { /// @param pid the identifier of the program that owns this node /// @param nid the unique node identifier /// @param src the source of this node - /// @param value the location value expression - LocationAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* value); + /// @param expr the location expression + LocationAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* expr); ~LocationAttribute() override; /// @returns the WGSL name for the attribute @@ -42,8 +42,8 @@ class LocationAttribute final : public Castable { /// @return the newly cloned node const LocationAttribute* Clone(CloneContext* ctx) const override; - /// The location value - const ast::Expression* const value; + /// The location expression + const ast::Expression* const expr; }; } // namespace tint::ast diff --git a/src/tint/ast/location_attribute_test.cc b/src/tint/ast/location_attribute_test.cc index d921131863..681ea43ba1 100644 --- a/src/tint/ast/location_attribute_test.cc +++ b/src/tint/ast/location_attribute_test.cc @@ -22,7 +22,7 @@ using LocationAttributeTest = TestHelper; TEST_F(LocationAttributeTest, Creation) { auto* d = Location(2_a); - EXPECT_TRUE(d->value->Is()); + EXPECT_TRUE(d->expr->Is()); } } // namespace diff --git a/src/tint/ast/struct_member_align_attribute.cc b/src/tint/ast/struct_member_align_attribute.cc index e188e7bdc9..2a213623e5 100644 --- a/src/tint/ast/struct_member_align_attribute.cc +++ b/src/tint/ast/struct_member_align_attribute.cc @@ -27,7 +27,7 @@ StructMemberAlignAttribute::StructMemberAlignAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* a) - : Base(pid, nid, src), align(a) {} + : Base(pid, nid, src), expr(a) {} StructMemberAlignAttribute::~StructMemberAlignAttribute() = default; @@ -38,8 +38,8 @@ std::string StructMemberAlignAttribute::Name() const { const StructMemberAlignAttribute* StructMemberAlignAttribute::Clone(CloneContext* ctx) const { // Clone arguments outside of create() call to have deterministic ordering auto src = ctx->Clone(source); - auto* align_ = ctx->Clone(align); - return ctx->dst->create(src, align_); + auto* expr_ = ctx->Clone(expr); + return ctx->dst->create(src, expr_); } } // namespace tint::ast diff --git a/src/tint/ast/struct_member_align_attribute.h b/src/tint/ast/struct_member_align_attribute.h index 2043b01cba..6da1894072 100644 --- a/src/tint/ast/struct_member_align_attribute.h +++ b/src/tint/ast/struct_member_align_attribute.h @@ -30,7 +30,7 @@ class StructMemberAlignAttribute final : public Castable(val); - EXPECT_EQ(val, d->align); - EXPECT_TRUE(d->align->Is()); + EXPECT_EQ(val, d->expr); + EXPECT_TRUE(d->expr->Is()); } } // namespace diff --git a/src/tint/ast/variable_test.cc b/src/tint/ast/variable_test.cc index 5b3ccb055a..2fed042b79 100644 --- a/src/tint/ast/variable_test.cc +++ b/src/tint/ast/variable_test.cc @@ -102,8 +102,8 @@ TEST_F(VariableTest, WithAttributes) { auto* location = ast::GetAttribute(attributes); ASSERT_NE(nullptr, location); - ASSERT_NE(nullptr, location->value); - EXPECT_TRUE(location->value->Is()); + ASSERT_NE(nullptr, location->expr); + EXPECT_TRUE(location->expr->Is()); } TEST_F(VariableTest, HasBindingPoint_BothProvided) { diff --git a/src/tint/reader/spirv/function.cc b/src/tint/reader/spirv/function.cc index 661b42c051..773ba46fcf 100644 --- a/src/tint/reader/spirv/function.cc +++ b/src/tint/reader/spirv/function.cc @@ -1110,8 +1110,7 @@ void FunctionEmitter::IncrementLocation(AttributeList* attributes) { // The old one doesn't leak because it's kept in the builder's AST node // list. attr = builder_.Location( - loc_attr->source, - AInt(loc_attr->value->As()->value + 1)); + loc_attr->source, AInt(loc_attr->expr->As()->value + 1)); } } } diff --git a/src/tint/reader/wgsl/parser_impl_function_decl_test.cc b/src/tint/reader/wgsl/parser_impl_function_decl_test.cc index 96669dcdc2..c9f55cfb50 100644 --- a/src/tint/reader/wgsl/parser_impl_function_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_function_decl_test.cc @@ -256,9 +256,9 @@ TEST_F(ParserImplTest, FunctionDecl_ReturnTypeAttributeList) { ASSERT_EQ(ret_type_attributes.Length(), 1u); auto* loc = ret_type_attributes[0]->As(); ASSERT_TRUE(loc != nullptr); - EXPECT_TRUE(loc->value->Is()); + EXPECT_TRUE(loc->expr->Is()); - auto* exp = loc->value->As(); + auto* exp = loc->expr->As(); EXPECT_EQ(1u, exp->value); auto* body = f->body; diff --git a/src/tint/reader/wgsl/parser_impl_function_header_test.cc b/src/tint/reader/wgsl/parser_impl_function_header_test.cc index fe81317c49..c65c6e05e6 100644 --- a/src/tint/reader/wgsl/parser_impl_function_header_test.cc +++ b/src/tint/reader/wgsl/parser_impl_function_header_test.cc @@ -57,8 +57,8 @@ TEST_F(ParserImplTest, FunctionHeader_AttributeReturnType) { auto* loc = f->return_type_attributes[0]->As(); ASSERT_TRUE(loc != nullptr); - ASSERT_TRUE(loc->value->Is()); - auto* exp = loc->value->As(); + ASSERT_TRUE(loc->expr->Is()); + auto* exp = loc->expr->As(); EXPECT_EQ(exp->value, 1u); } diff --git a/src/tint/reader/wgsl/parser_impl_global_constant_decl_test.cc b/src/tint/reader/wgsl/parser_impl_global_constant_decl_test.cc index 2f1397ffab..01ed4d99cf 100644 --- a/src/tint/reader/wgsl/parser_impl_global_constant_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_global_constant_decl_test.cc @@ -201,7 +201,7 @@ TEST_F(ParserImplTest, GlobalOverrideDecl_WithId) { auto* override_attr = ast::GetAttribute(override->attributes); ASSERT_NE(override_attr, nullptr); - EXPECT_TRUE(override_attr->value->Is()); + EXPECT_TRUE(override_attr->expr->Is()); } TEST_F(ParserImplTest, GlobalOverrideDecl_WithId_TrailingComma) { @@ -231,7 +231,7 @@ TEST_F(ParserImplTest, GlobalOverrideDecl_WithId_TrailingComma) { auto* override_attr = ast::GetAttribute(override->attributes); ASSERT_NE(override_attr, nullptr); - EXPECT_TRUE(override_attr->value->Is()); + EXPECT_TRUE(override_attr->expr->Is()); } TEST_F(ParserImplTest, GlobalOverrideDecl_WithoutId) { diff --git a/src/tint/reader/wgsl/parser_impl_param_list_test.cc b/src/tint/reader/wgsl/parser_impl_param_list_test.cc index 46c8c807ba..26c1852cb8 100644 --- a/src/tint/reader/wgsl/parser_impl_param_list_test.cc +++ b/src/tint/reader/wgsl/parser_impl_param_list_test.cc @@ -120,8 +120,8 @@ TEST_F(ParserImplTest, ParamList_Attributes) { ASSERT_TRUE(attrs_1[0]->Is()); auto* attr = attrs_1[0]->As(); - ASSERT_TRUE(attr->value->Is()); - auto* loc = attr->value->As(); + ASSERT_TRUE(attr->expr->Is()); + auto* loc = attr->expr->As(); EXPECT_EQ(loc->value, 1u); EXPECT_EQ(e.value[1]->source.range.begin.line, 1u); diff --git a/src/tint/reader/wgsl/parser_impl_struct_member_attribute_test.cc b/src/tint/reader/wgsl/parser_impl_struct_member_attribute_test.cc index 4fb95280d1..cc6d186d32 100644 --- a/src/tint/reader/wgsl/parser_impl_struct_member_attribute_test.cc +++ b/src/tint/reader/wgsl/parser_impl_struct_member_attribute_test.cc @@ -102,9 +102,9 @@ TEST_F(ParserImplTest, Attribute_Align) { ASSERT_TRUE(member_attr->Is()); auto* o = member_attr->As(); - ASSERT_TRUE(o->align->Is()); - EXPECT_EQ(o->align->As()->value, 4); - EXPECT_EQ(o->align->As()->suffix, + ASSERT_TRUE(o->expr->Is()); + EXPECT_EQ(o->expr->As()->value, 4); + EXPECT_EQ(o->expr->As()->suffix, ast::IntLiteralExpression::Suffix::kNone); } @@ -121,9 +121,9 @@ TEST_F(ParserImplTest, Attribute_Align_TrailingComma) { ASSERT_TRUE(member_attr->Is()); auto* o = member_attr->As(); - ASSERT_TRUE(o->align->Is()); + ASSERT_TRUE(o->expr->Is()); - auto* expr = o->align->As(); + auto* expr = o->expr->As(); EXPECT_EQ(expr->value, 4); EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone); } diff --git a/src/tint/reader/wgsl/parser_impl_struct_member_test.cc b/src/tint/reader/wgsl/parser_impl_struct_member_test.cc index c64f7728dd..fe233fe8a4 100644 --- a/src/tint/reader/wgsl/parser_impl_struct_member_test.cc +++ b/src/tint/reader/wgsl/parser_impl_struct_member_test.cc @@ -51,9 +51,8 @@ TEST_F(ParserImplTest, StructMember_ParsesWithAlignAttribute) { EXPECT_TRUE(m->attributes[0]->Is()); auto* attr = m->attributes[0]->As(); - ASSERT_TRUE(attr->align->Is()); - - auto* expr = attr->align->As(); + ASSERT_TRUE(attr->expr->Is()); + auto* expr = attr->expr->As(); EXPECT_EQ(expr->value, 2); EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone); @@ -101,8 +100,8 @@ TEST_F(ParserImplTest, StructMember_ParsesWithMultipleattributes) { ASSERT_TRUE(m->attributes[1]->Is()); auto* attr = m->attributes[1]->As(); - ASSERT_TRUE(attr->align->Is()); - auto* expr = attr->align->As(); + ASSERT_TRUE(attr->expr->Is()); + auto* expr = attr->expr->As(); EXPECT_EQ(expr->value, 4); EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone); diff --git a/src/tint/reader/wgsl/parser_impl_variable_attribute_list_test.cc b/src/tint/reader/wgsl/parser_impl_variable_attribute_list_test.cc index 03cd016490..a814ea605f 100644 --- a/src/tint/reader/wgsl/parser_impl_variable_attribute_list_test.cc +++ b/src/tint/reader/wgsl/parser_impl_variable_attribute_list_test.cc @@ -33,9 +33,8 @@ TEST_F(ParserImplTest, AttributeList_Parses) { ASSERT_TRUE(attr_0->Is()); auto* loc = attr_0->As(); - ASSERT_TRUE(loc->value->Is()); - - auto* exp = loc->value->As(); + ASSERT_TRUE(loc->expr->Is()); + auto* exp = loc->expr->As(); EXPECT_EQ(exp->value, 4u); ASSERT_TRUE(attr_1->Is()); diff --git a/src/tint/reader/wgsl/parser_impl_variable_attribute_test.cc b/src/tint/reader/wgsl/parser_impl_variable_attribute_test.cc index 299f49ba9d..7c52838bb9 100644 --- a/src/tint/reader/wgsl/parser_impl_variable_attribute_test.cc +++ b/src/tint/reader/wgsl/parser_impl_variable_attribute_test.cc @@ -29,8 +29,8 @@ TEST_F(ParserImplTest, Attribute_Location) { ASSERT_TRUE(var_attr->Is()); auto* loc = var_attr->As(); - ASSERT_TRUE(loc->value->Is()); - auto* exp = loc->value->As(); + ASSERT_TRUE(loc->expr->Is()); + auto* exp = loc->expr->As(); EXPECT_EQ(exp->value, 4u); } @@ -46,8 +46,8 @@ TEST_F(ParserImplTest, Attribute_Location_TrailingComma) { ASSERT_TRUE(var_attr->Is()); auto* loc = var_attr->As(); - ASSERT_TRUE(loc->value->Is()); - auto* exp = loc->value->As(); + ASSERT_TRUE(loc->expr->Is()); + auto* exp = loc->expr->As(); EXPECT_EQ(exp->value, 4u); } @@ -368,9 +368,8 @@ TEST_F(ParserImplTest, Attribute_Binding) { ASSERT_TRUE(var_attr->Is()); auto* binding = var_attr->As(); - ASSERT_TRUE(binding->value->Is()); - - auto* expr = binding->value->As(); + ASSERT_TRUE(binding->expr->Is()); + auto* expr = binding->expr->As(); EXPECT_EQ(expr->value, 4); EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone); } @@ -387,9 +386,8 @@ TEST_F(ParserImplTest, Attribute_Binding_TrailingComma) { ASSERT_TRUE(var_attr->Is()); auto* binding = var_attr->As(); - ASSERT_TRUE(binding->value->Is()); - - auto* expr = binding->value->As(); + ASSERT_TRUE(binding->expr->Is()); + auto* expr = binding->expr->As(); EXPECT_EQ(expr->value, 4); EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone); } @@ -446,9 +444,8 @@ TEST_F(ParserImplTest, Attribute_group) { ASSERT_TRUE(var_attr->Is()); auto* group = var_attr->As(); - ASSERT_TRUE(group->value->Is()); - - auto* expr = group->value->As(); + ASSERT_TRUE(group->expr->Is()); + auto* expr = group->expr->As(); EXPECT_EQ(expr->value, 4); EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone); } @@ -465,9 +462,8 @@ TEST_F(ParserImplTest, Attribute_group_TrailingComma) { ASSERT_TRUE(var_attr->Is()); auto* group = var_attr->As(); - ASSERT_TRUE(group->value->Is()); - - auto* expr = group->value->As(); + ASSERT_TRUE(group->expr->Is()); + auto* expr = group->expr->As(); EXPECT_EQ(expr->value, 4); EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone); } diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index 82a047caa9..27dc2199b8 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -442,7 +442,7 @@ sem::Variable* Resolver::Override(const ast::Override* v) { sem->SetConstructor(rhs); if (auto* id_attr = ast::GetAttribute(v->attributes)) { - auto* materialize = Materialize(Expression(id_attr->value)); + auto* materialize = Materialize(Expression(id_attr->expr)); if (!materialize) { return nullptr; } @@ -607,7 +607,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) { uint32_t binding = 0; { auto* attr = ast::GetAttribute(var->attributes); - auto* materialize = Materialize(Expression(attr->value)); + auto* materialize = Materialize(Expression(attr->expr)); if (!materialize) { return nullptr; } @@ -623,7 +623,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) { uint32_t group = 0; { auto* attr = ast::GetAttribute(var->attributes); - auto* materialize = Materialize(Expression(attr->value)); + auto* materialize = Materialize(Expression(attr->expr)); if (!materialize) { return nullptr; } @@ -640,7 +640,7 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) { std::optional location; if (auto* attr = ast::GetAttribute(var->attributes)) { - auto* materialize = Materialize(Expression(attr->value)); + auto* materialize = Materialize(Expression(attr->expr)); if (!materialize) { return nullptr; } @@ -705,7 +705,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index) if (param->HasBindingPoint()) { { auto* attr = ast::GetAttribute(param->attributes); - auto* materialize = Materialize(Expression(attr->value)); + auto* materialize = Materialize(Expression(attr->expr)); if (!materialize) { return nullptr; } @@ -719,7 +719,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index) } { auto* attr = ast::GetAttribute(param->attributes); - auto* materialize = Materialize(Expression(attr->value)); + auto* materialize = Materialize(Expression(attr->expr)); if (!materialize) { return nullptr; } @@ -735,7 +735,7 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index) std::optional location; if (auto* l = ast::GetAttribute(param->attributes)) { - auto* materialize = Materialize(Expression(l->value)); + auto* materialize = Materialize(Expression(l->expr)); if (!materialize) { return nullptr; } @@ -944,7 +944,7 @@ sem::Function* Resolver::Function(const ast::Function* decl) { Mark(attr); if (auto* a = attr->As()) { - auto* materialize = Materialize(Expression(a->value)); + auto* materialize = Materialize(Expression(a->expr)); if (!materialize) { return nullptr; } @@ -2811,13 +2811,13 @@ sem::Struct* Resolver::Structure(const ast::Struct* str) { align = 1; has_offset_attr = true; } else if (auto* a = attr->As()) { - auto* materialized = Materialize(Expression(a->align)); + auto* materialized = Materialize(Expression(a->expr)); if (!materialized) { return nullptr; } auto const_value = materialized->ConstantValue(); if (!const_value) { - AddError("'align' must be constant expression", a->align->source); + AddError("'align' must be constant expression", a->expr->source); return nullptr; } auto value = const_value->As(); @@ -2838,7 +2838,7 @@ sem::Struct* Resolver::Structure(const ast::Struct* str) { size = s->size; has_size_attr = true; } else if (auto* l = attr->As()) { - auto* materialize = Materialize(Expression(l->value)); + auto* materialize = Materialize(Expression(l->expr)); if (!materialize) { return nullptr; } diff --git a/src/tint/writer/wgsl/generator_impl.cc b/src/tint/writer/wgsl/generator_impl.cc index 804d9ead88..b2fba295d3 100644 --- a/src/tint/writer/wgsl/generator_impl.cc +++ b/src/tint/writer/wgsl/generator_impl.cc @@ -741,7 +741,7 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out, }, [&](const ast::BindingAttribute* binding) { out << "binding("; - if (!EmitExpression(out, binding->value)) { + if (!EmitExpression(out, binding->expr)) { return false; } out << ")"; @@ -749,7 +749,7 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out, }, [&](const ast::GroupAttribute* group) { out << "group("; - if (!EmitExpression(out, group->value)) { + if (!EmitExpression(out, group->expr)) { return false; } out << ")"; @@ -757,7 +757,7 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out, }, [&](const ast::LocationAttribute* location) { out << "location("; - if (!EmitExpression(out, location->value)) { + if (!EmitExpression(out, location->expr)) { return false; } out << ")"; @@ -781,7 +781,7 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out, }, [&](const ast::IdAttribute* override_deco) { out << "id("; - if (!EmitExpression(out, override_deco->value)) { + if (!EmitExpression(out, override_deco->expr)) { return false; } out << ")"; @@ -793,7 +793,7 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out, }, [&](const ast::StructMemberAlignAttribute* align) { out << "align("; - if (!EmitExpression(out, align->align)) { + if (!EmitExpression(out, align->expr)) { return false; } out << ")";