diff --git a/src/tint/ast/array.cc b/src/tint/ast/array.cc index 6a898f43ed..6233381150 100644 --- a/src/tint/ast/array.cc +++ b/src/tint/ast/array.cc @@ -27,7 +27,7 @@ namespace { // Returns the string representation of an array size expression. std::string SizeExprToString(const Expression* size, const SymbolTable& symbols) { if (auto* ident = size->As()) { - return symbols.NameFor(ident->symbol); + return symbols.NameFor(ident->identifier->symbol); } if (auto* literal = size->As()) { return std::to_string(literal->value); diff --git a/src/tint/ast/identifier_expression.cc b/src/tint/ast/identifier_expression.cc index 34eadeb07b..ca4e0cb99f 100644 --- a/src/tint/ast/identifier_expression.cc +++ b/src/tint/ast/identifier_expression.cc @@ -20,10 +20,13 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IdentifierExpression); namespace tint::ast { -IdentifierExpression::IdentifierExpression(ProgramID pid, NodeID nid, const Source& src, Symbol sym) - : Base(pid, nid, src), symbol(sym) { - TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, symbol, program_id); - TINT_ASSERT(AST, symbol.IsValid()); +IdentifierExpression::IdentifierExpression(ProgramID pid, + NodeID nid, + const Source& src, + const Identifier* ident) + : Base(pid, nid, src), identifier(ident) { + TINT_ASSERT(AST, identifier != nullptr); + TINT_ASSERT_PROGRAM_IDS_EQUAL(AST, identifier, program_id); } IdentifierExpression::IdentifierExpression(IdentifierExpression&&) = default; @@ -33,8 +36,8 @@ IdentifierExpression::~IdentifierExpression() = default; const IdentifierExpression* IdentifierExpression::Clone(CloneContext* ctx) const { // Clone arguments outside of create() call to have deterministic ordering auto src = ctx->Clone(source); - auto sym = ctx->Clone(symbol); - return ctx->dst->create(src, sym); + auto ident = ctx->Clone(identifier); + return ctx->dst->create(src, ident); } } // namespace tint::ast diff --git a/src/tint/ast/identifier_expression.h b/src/tint/ast/identifier_expression.h index b583807ba2..475249c073 100644 --- a/src/tint/ast/identifier_expression.h +++ b/src/tint/ast/identifier_expression.h @@ -17,6 +17,11 @@ #include "src/tint/ast/expression.h" +// Forward declarations +namespace tint::ast { +class Identifier; +} + namespace tint::ast { /// An identifier expression @@ -26,8 +31,11 @@ class IdentifierExpression final : public Castablesymbol, Symbol(1, ID())); + EXPECT_EQ(i->identifier->symbol, Symbol(1, ID())); } TEST_F(IdentifierExpressionTest, Creation_WithSource) { - auto* i = Expr(Source{Source::Location{20, 2}}, "ident"); - EXPECT_EQ(i->symbol, Symbol(1, ID())); + auto* i = Expr(Source{{20, 2}}, "ident"); + EXPECT_EQ(i->identifier->symbol, Symbol(1, ID())); - auto src = i->source; - EXPECT_EQ(src.range.begin.line, 20u); - EXPECT_EQ(src.range.begin.column, 2u); + EXPECT_EQ(i->source.range, (Source::Range{{20, 2}})); + EXPECT_EQ(i->identifier->source.range, (Source::Range{{20, 2}})); } TEST_F(IdentifierExpressionTest, IsIdentifier) { diff --git a/src/tint/ast/workgroup_attribute_test.cc b/src/tint/ast/workgroup_attribute_test.cc index d4fb6c7580..97a034bb9b 100644 --- a/src/tint/ast/workgroup_attribute_test.cc +++ b/src/tint/ast/workgroup_attribute_test.cc @@ -73,7 +73,7 @@ TEST_F(WorkgroupAttributeTest, Creation_WithIdentifier) { auto* z_ident = As(values[2]); ASSERT_TRUE(z_ident); - EXPECT_EQ(Symbols().NameFor(z_ident->symbol), "depth"); + EXPECT_EQ(Symbols().NameFor(z_ident->identifier->symbol), "depth"); } } // namespace diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h index ce3712d406..41ec05ee5c 100644 --- a/src/tint/program_builder.h +++ b/src/tint/program_builder.h @@ -1184,52 +1184,52 @@ class ProgramBuilder { /// @param symbol the identifier symbol /// @return an ast::IdentifierExpression with the given symbol const ast::IdentifierExpression* Expr(const Source& source, Symbol symbol) { - return create(source, symbol); + return create(source, Ident(source, symbol)); } /// @param symbol the identifier symbol /// @return an ast::IdentifierExpression with the given symbol const ast::IdentifierExpression* Expr(Symbol symbol) { - return create(symbol); - } - - /// @param source the source information - /// @param variable the AST variable - /// @return an ast::IdentifierExpression with the variable's symbol - const ast::IdentifierExpression* Expr(const Source& source, const ast::Variable* variable) { - return create(source, variable->symbol); - } - - /// @param variable the AST variable - /// @return an ast::IdentifierExpression with the variable's symbol - const ast::IdentifierExpression* Expr(const ast::Variable* variable) { - return create(variable->symbol); + return create(Ident(symbol)); } /// @param source the source information /// @param name the identifier name /// @return an ast::IdentifierExpression with the given name const ast::IdentifierExpression* Expr(const Source& source, const char* name) { - return create(source, Symbols().Register(name)); + return create(source, Ident(source, name)); } /// @param name the identifier name /// @return an ast::IdentifierExpression with the given name const ast::IdentifierExpression* Expr(const char* name) { - return create(Symbols().Register(name)); + return create(Ident(name)); } /// @param source the source information /// @param name the identifier name /// @return an ast::IdentifierExpression with the given name const ast::IdentifierExpression* Expr(const Source& source, const std::string& name) { - return create(source, Symbols().Register(name)); + return create(source, Ident(source, name)); } /// @param name the identifier name /// @return an ast::IdentifierExpression with the given name const ast::IdentifierExpression* Expr(const std::string& name) { - return create(Symbols().Register(name)); + return create(Ident(name)); + } + + /// @param source the source information + /// @param variable the AST variable + /// @return an ast::IdentifierExpression with the variable's symbol + const ast::IdentifierExpression* Expr(const Source& source, const ast::Variable* variable) { + return create(source, Ident(source, variable->symbol)); + } + + /// @param variable the AST variable + /// @return an ast::IdentifierExpression with the variable's symbol + const ast::IdentifierExpression* Expr(const ast::Variable* variable) { + return create(Ident(variable->symbol)); } /// @param source the source information diff --git a/src/tint/reader/spirv/function.cc b/src/tint/reader/spirv/function.cc index f068a6291e..98151cc416 100644 --- a/src/tint/reader/spirv/function.cc +++ b/src/tint/reader/spirv/function.cc @@ -877,8 +877,7 @@ void FunctionEmitter::PushGuard(const std::string& guard_name, uint32_t end_id) // as the statement block at the top of the stack. const auto& top = statements_stack_.Back(); - auto* cond = - create(Source{}, builder_.Symbols().Register(guard_name)); + auto* cond = builder_.Expr(Source{}, guard_name); auto* builder = AddStatementBuilder(cond); PushNewStatementBlock(top.GetConstruct(), end_id, [=](const StatementList& stmts) { @@ -1314,12 +1313,7 @@ bool FunctionEmitter::EmitEntryPointAsWrapper() { } // Call the inner function. It has no parameters. - stmts.Push(create( - source, - create( - source, - create(source, builder_.Symbols().Register(ep_info_->inner_name)), - utils::Empty))); + stmts.Push(builder_.CallStmt(source, builder_.Call(source, ep_info_->inner_name))); // Pipeline outputs are mapped to the return value. if (ep_info_->outputs.IsEmpty()) { @@ -2587,8 +2581,7 @@ TypedExpression FunctionEmitter::MakeExpression(uint32_t id) { case SkipReason::kSampleMaskOutBuiltinPointer: { // The result type is always u32. auto name = namer_.Name(sample_mask_out_id); - return TypedExpression{ty_.U32(), create( - Source{}, builder_.Symbols().Register(name))}; + return TypedExpression{ty_.U32(), builder_.Expr(Source{}, name)}; } } auto type_it = identifier_types_.find(id); @@ -2597,14 +2590,12 @@ TypedExpression FunctionEmitter::MakeExpression(uint32_t id) { // declaration. auto name = namer_.Name(id); auto* type = type_it->second; - return TypedExpression{ - type, create(Source{}, builder_.Symbols().Register(name))}; + return TypedExpression{type, builder_.Expr(Source{}, name)}; } if (parser_impl_.IsScalarSpecConstant(id)) { auto name = namer_.Name(id); - return TypedExpression{ - parser_impl_.ConvertType(def_use_mgr_->GetDef(id)->type_id()), - create(Source{}, builder_.Symbols().Register(name))}; + return TypedExpression{parser_impl_.ConvertType(def_use_mgr_->GetDef(id)->type_id()), + builder_.Expr(Source{}, name)}; } if (singly_used_values_.count(id)) { auto expr = std::move(singly_used_values_[id]); @@ -2627,8 +2618,7 @@ TypedExpression FunctionEmitter::MakeExpression(uint32_t id) { // Construct the reference type, mapping storage class correctly. const auto* type = RemapPointerProperties(parser_impl_.ConvertType(inst->type_id(), PtrAs::Ref), id); - return TypedExpression{type, create( - Source{}, builder_.Symbols().Register(name))}; + return TypedExpression{type, builder_.Expr(Source{}, name)}; } case spv::Op::OpUndef: // Substitute a null value for undef. @@ -3322,11 +3312,8 @@ const ast::Statement* FunctionEmitter::MakeBranchDetailed(const BlockInfo& src_i *flow_guard_name_ptr = flow_guard; } // Signal an exit from the branch. - return create( - Source{}, - create(Source{}, - builder_.Symbols().Register(flow_guard)), - MakeFalse(Source{})); + return create(Source{}, builder_.Expr(flow_guard), + MakeFalse(Source{})); } // For an unconditional branch, the break out to an if-selection @@ -3503,10 +3490,7 @@ bool FunctionEmitter::WriteIfHoistedVar(const spvtools::opt::Instruction& inst, if (def_info && def_info->requires_hoisted_var_def) { auto name = namer_.Name(result_id); // Emit an assignment of the expression to the hoisted variable. - AddStatement(create( - Source{}, - create(Source{}, builder_.Symbols().Register(name)), - expr.expr)); + AddStatement(create(Source{}, builder_.Expr(name), expr.expr)); return true; } return false; @@ -3669,8 +3653,7 @@ bool FunctionEmitter::EmitStatement(const spvtools::opt::Instruction& inst) { return true; case SkipReason::kSampleMaskInBuiltinPointer: { auto name = namer_.Name(sample_mask_in_id); - const ast::Expression* id_expr = create( - Source{}, builder_.Symbols().Register(name)); + const ast::Expression* id_expr = builder_.Expr(Source{}, name); // SampleMask is an array in Vulkan SPIR-V. Always access the first // element. id_expr = create( @@ -3852,11 +3835,7 @@ TypedExpression FunctionEmitter::MaybeEmitCombinatorialValue( if (unary_builtin_name != nullptr) { ExpressionList params; params.Push(MakeOperand(inst, 0).expr); - return {ast_type, create( - Source{}, - create( - Source{}, builder_.Symbols().Register(unary_builtin_name)), - std::move(params))}; + return {ast_type, builder_.Call(Source{}, unary_builtin_name, std::move(params))}; } const auto builtin = GetBuiltin(op); @@ -4106,7 +4085,6 @@ TypedExpression FunctionEmitter::EmitGlslStd450ExtInst(const spvtools::opt::Inst return {}; } - auto* func = create(Source{}, builder_.Symbols().Register(name)); ExpressionList operands; const Type* first_operand_type = nullptr; // All parameters to GLSL.std.450 extended instructions are IDs. @@ -4117,7 +4095,7 @@ TypedExpression FunctionEmitter::EmitGlslStd450ExtInst(const spvtools::opt::Inst } operands.Push(operand.expr); } - auto* call = create(Source{}, func, std::move(operands)); + auto* call = builder_.Call(Source{}, name, std::move(operands)); TypedExpression call_expr{result_type, call}; return parser_impl_.RectifyForcedResultType(call_expr, inst, first_operand_type); } @@ -4312,23 +4290,23 @@ TypedExpression FunctionEmitter::EmitGlslStd450MatrixInverse( return {}; } -ast::IdentifierExpression* FunctionEmitter::Swizzle(uint32_t i) { +const ast::IdentifierExpression* FunctionEmitter::Swizzle(uint32_t i) { if (i >= kMaxVectorLen) { Fail() << "vector component index is larger than " << kMaxVectorLen - 1 << ": " << i; return nullptr; } const char* names[] = {"x", "y", "z", "w"}; - return create(Source{}, builder_.Symbols().Register(names[i & 3])); + return builder_.Expr(names[i & 3]); } -ast::IdentifierExpression* FunctionEmitter::PrefixSwizzle(uint32_t n) { +const ast::IdentifierExpression* FunctionEmitter::PrefixSwizzle(uint32_t n) { switch (n) { case 1: - return create(Source{}, builder_.Symbols().Register("x")); + return builder_.Expr("x"); case 2: - return create(Source{}, builder_.Symbols().Register("xy")); + return builder_.Expr("xy"); case 3: - return create(Source{}, builder_.Symbols().Register("xyz")); + return builder_.Expr("xyz"); default: break; } @@ -4433,8 +4411,7 @@ TypedExpression FunctionEmitter::MakeAccessChain(const spvtools::opt::Instructio ptr_ty_id = builtin_position_info.position_member_pointer_type_id; auto name = namer_.Name(base_id); - current_expr.expr = - create(Source{}, builder_.Symbols().Register(name)); + current_expr.expr = builder_.Expr(name); current_expr.type = parser_impl_.ConvertType(ptr_ty_id, PtrAs::Ref); } } @@ -4533,8 +4510,7 @@ TypedExpression FunctionEmitter::MakeAccessChain(const spvtools::opt::Instructio return {}; } auto name = namer_.GetMemberName(pointee_type_id, uint32_t(index_const_val)); - auto* member_access = - create(Source{}, builder_.Symbols().Register(name)); + auto* member_access = builder_.Expr(name); next_expr = create(Source{}, current_expr.expr, member_access); @@ -4697,8 +4673,7 @@ TypedExpression FunctionEmitter::MakeCompositeValueDecomposition( return {}; } auto name = namer_.GetMemberName(current_type_id, uint32_t(index_val)); - auto* member_access = - create(Source{}, builder_.Symbols().Register(name)); + auto* member_access = builder_.Expr(name); next_expr = create(Source{}, current_expr.expr, member_access); @@ -5390,8 +5365,7 @@ const ast::Expression* FunctionEmitter::GetImageExpression(const spvtools::opt:: return nullptr; } auto name = namer_.Name(image->result_id()); - return create(GetSourceForInst(inst), - builder_.Symbols().Register(name)); + return builder_.Expr(GetSourceForInst(inst), name); } const ast::Expression* FunctionEmitter::GetSamplerExpression( @@ -5405,8 +5379,7 @@ const ast::Expression* FunctionEmitter::GetSamplerExpression( return nullptr; } auto name = namer_.Name(image->result_id()); - return create(GetSourceForInst(inst), - builder_.Symbols().Register(name)); + return builder_.Expr(GetSourceForInst(inst), name); } bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) { @@ -5649,8 +5622,7 @@ bool FunctionEmitter::EmitImageAccess(const spvtools::opt::Instruction& inst) { return false; } - auto* ident = create(Source{}, builder_.Symbols().Register(builtin_name)); - auto* call_expr = create(Source{}, ident, std::move(args)); + auto* call_expr = builder_.Call(Source{}, builtin_name, std::move(args)); if (inst.type_id() != 0) { // It returns a value. @@ -5739,14 +5711,12 @@ bool FunctionEmitter::EmitImageQuery(const spvtools::opt::Instruction& inst) { // Invoke textureDimensions. // If the texture is arrayed, combine with the result from // textureNumLayers. - auto* dims_ident = - create(Source{}, builder_.Symbols().Register("textureDimensions")); ExpressionList dims_args{GetImageExpression(inst)}; if (op == spv::Op::OpImageQuerySizeLod) { dims_args.Push(MakeOperand(inst, 1).expr); } const ast::Expression* dims_call = - create(Source{}, dims_ident, dims_args); + builder_.Call(Source{}, "textureDimensions", std::move(dims_args)); auto dims = texture_type->dims; if ((dims == type::TextureDimension::kCube) || (dims == type::TextureDimension::kCubeArray)) { @@ -5756,10 +5726,8 @@ bool FunctionEmitter::EmitImageQuery(const spvtools::opt::Instruction& inst) { } exprs.Push(dims_call); if (ast::IsTextureArray(dims)) { - auto* layers_ident = create( - Source{}, builder_.Symbols().Register("textureNumLayers")); - auto num_layers = create( - Source{}, layers_ident, utils::Vector{GetImageExpression(inst)}); + auto num_layers = + builder_.Call(Source{}, "textureNumLayers", GetImageExpression(inst)); exprs.Push(num_layers); } auto* result_type = parser_impl_.ConvertType(inst.type_id()); @@ -5786,10 +5754,8 @@ bool FunctionEmitter::EmitImageQuery(const spvtools::opt::Instruction& inst) { case spv::Op::OpImageQuerySamples: { const auto* name = (op == spv::Op::OpImageQueryLevels) ? "textureNumLevels" : "textureNumSamples"; - auto* levels_ident = - create(Source{}, builder_.Symbols().Register(name)); - const ast::Expression* ast_expr = create( - Source{}, levels_ident, utils::Vector{GetImageExpression(inst)}); + const ast::Expression* ast_expr = + builder_.Call(Source{}, name, GetImageExpression(inst)); auto* result_type = parser_impl_.ConvertType(inst.type_id()); // The SPIR-V result type must be integer scalar. // The WGSL bulitin returns u32. @@ -6156,8 +6122,7 @@ TypedExpression FunctionEmitter::MakeArrayLength(const spvtools::opt::Instructio if (member_expr.type->Is()) { member_expr = Dereference(member_expr); } - auto* member_ident = - create(Source{}, builder_.Symbols().Register(field_name)); + auto* member_ident = builder_.Expr(field_name); auto* member_access = create(Source{}, member_expr.expr, member_ident); diff --git a/src/tint/reader/spirv/function.h b/src/tint/reader/spirv/function.h index 53afcdc41a..5ad2b1b431 100644 --- a/src/tint/reader/spirv/function.h +++ b/src/tint/reader/spirv/function.h @@ -916,14 +916,14 @@ class FunctionEmitter { /// index is out of range, i.e. 4 or higher. /// @param i index of the subcomponent /// @returns the identifier expression for the `i`'th component - ast::IdentifierExpression* Swizzle(uint32_t i); + const ast::IdentifierExpression* Swizzle(uint32_t i); /// Returns an identifier expression for the swizzle name of the first /// `n` elements of a vector. Emits an error and returns nullptr if `n` /// is out of range, i.e. 4 or higher. /// @param n the number of components in the swizzle /// @returns the swizzle identifier for the first n elements of a vector - ast::IdentifierExpression* PrefixSwizzle(uint32_t n); + const ast::IdentifierExpression* PrefixSwizzle(uint32_t n); /// Converts SPIR-V image coordinates from an image access instruction /// (e.g. OpImageSampledImplicitLod) into an expression list consisting of diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc index dd6ef911db..7a35092dc3 100644 --- a/src/tint/reader/wgsl/parser_impl.cc +++ b/src/tint/reader/wgsl/parser_impl.cc @@ -2648,13 +2648,10 @@ Maybe ParserImpl::primary_expression() { return Failure::kErrored; } - auto* ident = - create(t.source(), builder_.Symbols().Register(t.to_str())); - return create(t.source(), ident, std::move(params.value)); + return builder_.Call(t.source(), t.to_str(), std::move(params.value)); } - return create(t.source(), - builder_.Symbols().Register(t.to_str())); + return builder_.Expr(t.source(), t.to_str()); } if (t.Is(Token::Type::kParenLeft)) { @@ -2709,10 +2706,8 @@ Maybe ParserImpl::component_or_swizzle_specifier( return Failure::kErrored; } - prefix = create( - ident.source, prefix, - create(ident.source, - builder_.Symbols().Register(ident.value))); + prefix = builder_.MemberAccessor(ident.source, prefix, + builder_.Expr(ident.source, ident.value)); continue; } @@ -3267,8 +3262,7 @@ Maybe ParserImpl::core_lhs_expression() { if (t.IsIdentifier()) { next(); - return create(t.source(), - builder_.Symbols().Register(t.to_str())); + return builder_.Expr(t.source(), t.to_str()); } if (peek_is(Token::Type::kParenLeft)) { @@ -3780,10 +3774,8 @@ Expect ParserImpl::expect_diagnostic_control() { } match(Token::Type::kComma); - return create( - source, severity_control.value, - create(rule_name.source, - builder_.Symbols().Register(rule_name.value))); + return create(source, severity_control.value, + builder_.Expr(rule_name.source, rule_name.value)); }); } diff --git a/src/tint/reader/wgsl/parser_impl_additive_expression_test.cc b/src/tint/reader/wgsl/parser_impl_additive_expression_test.cc index 971c6953bb..27f44e1359 100644 --- a/src/tint/reader/wgsl/parser_impl_additive_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_additive_expression_test.cc @@ -35,12 +35,12 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_Plus) { EXPECT_EQ(ast::BinaryOp::kAdd, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, AdditiveExpression_Parses_Minus) { @@ -56,12 +56,12 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_Minus) { EXPECT_EQ(ast::BinaryOp::kSubtract, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, AdditiveExpression_Parses_MinusMinus) { @@ -77,16 +77,16 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_MinusMinus) { EXPECT_EQ(ast::BinaryOp::kSubtract, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); auto* unary = rel->rhs->As(); EXPECT_EQ(ast::UnaryOp::kNegation, unary->op); ASSERT_TRUE(unary->expr->Is()); - ident = unary->expr->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = unary->expr->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, AdditiveExpression_Parses_MultipleOps) { @@ -105,8 +105,8 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_MultipleOps) { EXPECT_EQ(ast::BinaryOp::kSubtract, rel->op); ASSERT_TRUE(rel->rhs->Is()); - auto* ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("d")); + auto* ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("d")); ASSERT_TRUE(rel->lhs->Is()); // lhs: a - b @@ -116,8 +116,8 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_MultipleOps) { EXPECT_EQ(ast::BinaryOp::kAdd, rel->op); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("c")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("c")); ASSERT_TRUE(rel->lhs->Is()); // lhs: a @@ -127,12 +127,12 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_MultipleOps) { EXPECT_EQ(ast::BinaryOp::kSubtract, rel->op); ASSERT_TRUE(rel->lhs->Is()); - ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, AdditiveExpression_Parses_MultipleOps_MixedMultiplication) { @@ -151,8 +151,8 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_MultipleOps_MixedMultiplication EXPECT_EQ(ast::BinaryOp::kSubtract, rel->op); ASSERT_TRUE(rel->rhs->Is()); - auto* ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("d")); + auto* ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("d")); ASSERT_TRUE(rel->lhs->Is()); // lhs: a @@ -162,8 +162,8 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_MultipleOps_MixedMultiplication EXPECT_EQ(ast::BinaryOp::kSubtract, rel->op); ASSERT_TRUE(rel->lhs->Is()); - ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); // lhs: b @@ -173,12 +173,12 @@ TEST_F(ParserImplTest, AdditiveExpression_Parses_MultipleOps_MixedMultiplication EXPECT_EQ(ast::BinaryOp::kMultiply, rel->op); ASSERT_TRUE(rel->lhs->Is()); - ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("c")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("c")); } TEST_F(ParserImplTest, AdditiveExpression_InvalidRHS) { diff --git a/src/tint/reader/wgsl/parser_impl_assignment_stmt_test.cc b/src/tint/reader/wgsl/parser_impl_assignment_stmt_test.cc index fd76c34fa1..e6adcb25cc 100644 --- a/src/tint/reader/wgsl/parser_impl_assignment_stmt_test.cc +++ b/src/tint/reader/wgsl/parser_impl_assignment_stmt_test.cc @@ -36,8 +36,8 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToVariable) { EXPECT_EQ(a->source.range.end.column, 4u); ASSERT_TRUE(a->lhs->Is()); - auto* ident = a->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = a->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(a->rhs->Is()); EXPECT_EQ(a->rhs->As()->value, 123); @@ -72,8 +72,8 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) { auto* mem = a->lhs->As(); ASSERT_TRUE(mem->member->Is()); - auto* ident = mem->member->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("d")); + auto* ident_expr = mem->member->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("d")); ASSERT_TRUE(mem->structure->Is()); auto* idx = mem->structure->As(); @@ -85,19 +85,19 @@ TEST_F(ParserImplTest, AssignmentStmt_Parses_ToMember) { ASSERT_TRUE(idx->object->Is()); mem = idx->object->As(); ASSERT_TRUE(mem->member->Is()); - ident = mem->member->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("c")); + ident_expr = mem->member->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("c")); ASSERT_TRUE(mem->structure->Is()); mem = mem->structure->As(); ASSERT_TRUE(mem->structure->Is()); - ident = mem->structure->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + ident_expr = mem->structure->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(mem->member->Is()); - ident = mem->member->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = mem->member->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, AssignmentStmt_Parses_ToPhony) { @@ -184,8 +184,8 @@ TEST_P(CompoundOpTest, CompoundOp) { EXPECT_EQ(a->source.range.end.column, 3u + params.str.length()); ASSERT_TRUE(a->lhs->Is()); - auto* ident = a->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = a->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(a->rhs->Is()); EXPECT_EQ(a->rhs->As()->value, 123); diff --git a/src/tint/reader/wgsl/parser_impl_bitwise_expression_test.cc b/src/tint/reader/wgsl/parser_impl_bitwise_expression_test.cc index 9e95a3c14f..fcdeeb6332 100644 --- a/src/tint/reader/wgsl/parser_impl_bitwise_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_bitwise_expression_test.cc @@ -46,8 +46,8 @@ TEST_F(ParserImplTest, BitwiseExpr_Or_Parses) { EXPECT_EQ(ast::BinaryOp::kOr, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -70,8 +70,8 @@ TEST_F(ParserImplTest, BitwiseExpr_Or_Parses_Multiple) { EXPECT_EQ(ast::BinaryOp::kOr, rel->op); ASSERT_TRUE(rel->rhs->Is()); - auto* ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + auto* ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); ASSERT_TRUE(rel->lhs->Is()); @@ -80,8 +80,8 @@ TEST_F(ParserImplTest, BitwiseExpr_Or_Parses_Multiple) { rel = rel->lhs->As(); ASSERT_TRUE(rel->lhs->Is()); - ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -117,8 +117,8 @@ TEST_F(ParserImplTest, BitwiseExpr_Xor_Parses) { EXPECT_EQ(ast::BinaryOp::kXor, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -140,8 +140,8 @@ TEST_F(ParserImplTest, BitwiseExpr_Xor_Parses_Multiple) { EXPECT_EQ(ast::BinaryOp::kXor, rel->op); ASSERT_TRUE(rel->rhs->Is()); - auto* ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + auto* ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); ASSERT_TRUE(rel->lhs->Is()); @@ -150,8 +150,8 @@ TEST_F(ParserImplTest, BitwiseExpr_Xor_Parses_Multiple) { rel = rel->lhs->As(); ASSERT_TRUE(rel->lhs->Is()); - ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -187,8 +187,8 @@ TEST_F(ParserImplTest, BitwiseExpr_And_Parses) { EXPECT_EQ(ast::BinaryOp::kAnd, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Register("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Register("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -210,8 +210,8 @@ TEST_F(ParserImplTest, BitwiseExpr_And_Parses_Multiple) { EXPECT_EQ(ast::BinaryOp::kAnd, rel->op); ASSERT_TRUE(rel->rhs->Is()); - auto* ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Register("b")); + auto* ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Register("b")); ASSERT_TRUE(rel->lhs->Is()); @@ -220,8 +220,8 @@ TEST_F(ParserImplTest, BitwiseExpr_And_Parses_Multiple) { rel = rel->lhs->As(); ASSERT_TRUE(rel->lhs->Is()); - ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Register("a")); + ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Register("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); diff --git a/src/tint/reader/wgsl/parser_impl_core_lhs_expression_test.cc b/src/tint/reader/wgsl/parser_impl_core_lhs_expression_test.cc index 81984eb41f..4264865028 100644 --- a/src/tint/reader/wgsl/parser_impl_core_lhs_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_core_lhs_expression_test.cc @@ -34,8 +34,8 @@ TEST_F(ParserImplTest, CoreLHS_Ident) { ASSERT_NE(e.value, nullptr); ASSERT_TRUE(e->Is()); - auto* ident = e->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("identifier")); + auto* ident_expr = e->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("identifier")); } TEST_F(ParserImplTest, CoreLHS_ParenStmt) { @@ -47,8 +47,8 @@ TEST_F(ParserImplTest, CoreLHS_ParenStmt) { ASSERT_NE(e.value, nullptr); ASSERT_TRUE(e->Is()); - auto* ident = e->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = e->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); } TEST_F(ParserImplTest, CoreLHS_MissingRightParen) { diff --git a/src/tint/reader/wgsl/parser_impl_diagnostic_attribute_test.cc b/src/tint/reader/wgsl/parser_impl_diagnostic_attribute_test.cc index aebd1a0d3d..5f1fe72ce6 100644 --- a/src/tint/reader/wgsl/parser_impl_diagnostic_attribute_test.cc +++ b/src/tint/reader/wgsl/parser_impl_diagnostic_attribute_test.cc @@ -29,7 +29,7 @@ TEST_F(ParserImplTest, DiagnosticAttribute_Valid) { EXPECT_EQ(d->control->severity, ast::DiagnosticSeverity::kOff); auto* r = As(d->control->rule_name); ASSERT_NE(r, nullptr); - EXPECT_EQ(p->builder().Symbols().NameFor(r->symbol), "foo"); + EXPECT_EQ(p->builder().Symbols().NameFor(r->identifier->symbol), "foo"); } } // namespace diff --git a/src/tint/reader/wgsl/parser_impl_diagnostic_control_test.cc b/src/tint/reader/wgsl/parser_impl_diagnostic_control_test.cc index 36de427a15..720340f48f 100644 --- a/src/tint/reader/wgsl/parser_impl_diagnostic_control_test.cc +++ b/src/tint/reader/wgsl/parser_impl_diagnostic_control_test.cc @@ -34,7 +34,7 @@ TEST_P(DiagnosticControlParserTest, DiagnosticControl_Valid) { auto* r = As(e->rule_name); ASSERT_NE(r, nullptr); - EXPECT_EQ(p->builder().Symbols().NameFor(r->symbol), "foo"); + EXPECT_EQ(p->builder().Symbols().NameFor(r->identifier->symbol), "foo"); } INSTANTIATE_TEST_SUITE_P(DiagnosticControlParserTest, DiagnosticControlParserTest, @@ -54,7 +54,7 @@ TEST_F(ParserImplTest, DiagnosticControl_Valid_TrailingComma) { auto* r = As(e->rule_name); ASSERT_NE(r, nullptr); - EXPECT_EQ(p->builder().Symbols().NameFor(r->symbol), "foo"); + EXPECT_EQ(p->builder().Symbols().NameFor(r->identifier->symbol), "foo"); } TEST_F(ParserImplTest, DiagnosticControl_MissingOpenParen) { diff --git a/src/tint/reader/wgsl/parser_impl_diagnostic_directive_test.cc b/src/tint/reader/wgsl/parser_impl_diagnostic_directive_test.cc index c91b7d1787..0eb5f7cf7a 100644 --- a/src/tint/reader/wgsl/parser_impl_diagnostic_directive_test.cc +++ b/src/tint/reader/wgsl/parser_impl_diagnostic_directive_test.cc @@ -32,7 +32,7 @@ TEST_F(ParserImplTest, DiagnosticDirective_Valid) { auto* r = As(control->rule_name); ASSERT_NE(r, nullptr); - EXPECT_EQ(p->builder().Symbols().NameFor(r->symbol), "foo"); + EXPECT_EQ(p->builder().Symbols().NameFor(r->identifier->symbol), "foo"); } TEST_F(ParserImplTest, DiagnosticDirective_MissingSemicolon) { diff --git a/src/tint/reader/wgsl/parser_impl_element_count_expression_test.cc b/src/tint/reader/wgsl/parser_impl_element_count_expression_test.cc index 0dd287d161..b629ef7358 100644 --- a/src/tint/reader/wgsl/parser_impl_element_count_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_element_count_expression_test.cc @@ -30,12 +30,12 @@ TEST_F(ParserImplTest, ElementCountExpression_Math) { EXPECT_EQ(ast::BinaryOp::kMultiply, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, ElementCountExpression_Bitwise) { @@ -51,8 +51,8 @@ TEST_F(ParserImplTest, ElementCountExpression_Bitwise) { EXPECT_EQ(ast::BinaryOp::kOr, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); diff --git a/src/tint/reader/wgsl/parser_impl_expression_test.cc b/src/tint/reader/wgsl/parser_impl_expression_test.cc index 9ae4591c0b..68b3be3467 100644 --- a/src/tint/reader/wgsl/parser_impl_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_expression_test.cc @@ -44,8 +44,8 @@ TEST_F(ParserImplTest, Expression_Or_Parses) { EXPECT_EQ(ast::BinaryOp::kLogicalOr, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -66,8 +66,8 @@ TEST_F(ParserImplTest, Expression_Or_Parses_Multiple) { EXPECT_EQ(ast::BinaryOp::kLogicalOr, rel->op); ASSERT_TRUE(rel->rhs->Is()); - auto* ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + auto* ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); ASSERT_TRUE(rel->lhs->Is()); // lhs: a @@ -76,8 +76,8 @@ TEST_F(ParserImplTest, Expression_Or_Parses_Multiple) { EXPECT_EQ(ast::BinaryOp::kLogicalOr, rel->op); ASSERT_TRUE(rel->lhs->Is()); - ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -111,8 +111,8 @@ TEST_F(ParserImplTest, Expression_And_Parses) { EXPECT_EQ(ast::BinaryOp::kLogicalAnd, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -133,16 +133,16 @@ TEST_F(ParserImplTest, Expression_And_Parses_Multple) { EXPECT_EQ(ast::BinaryOp::kLogicalAnd, rel->op); ASSERT_TRUE(rel->rhs->Is()); - auto* ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + auto* ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); ASSERT_TRUE(rel->lhs->Is()); // lhs: a // rhs: true rel = rel->lhs->As(); ASSERT_TRUE(rel->lhs->Is()); - ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -191,12 +191,12 @@ TEST_F(ParserImplTest, Expression_Bitwise) { EXPECT_EQ(ast::BinaryOp::kAnd, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, Expression_Relational) { @@ -212,12 +212,12 @@ TEST_F(ParserImplTest, Expression_Relational) { EXPECT_EQ(ast::BinaryOp::kLessThanEqual, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, Expression_InvalidUnary) { diff --git a/src/tint/reader/wgsl/parser_impl_function_attribute_test.cc b/src/tint/reader/wgsl/parser_impl_function_attribute_test.cc index 186c86a21b..a9b9818831 100644 --- a/src/tint/reader/wgsl/parser_impl_function_attribute_test.cc +++ b/src/tint/reader/wgsl/parser_impl_function_attribute_test.cc @@ -312,7 +312,7 @@ TEST_F(ParserImplTest, Attribute_Workgroup_WithIdent) { ASSERT_NE(values[1], nullptr); auto* y_ident = values[1]->As(); ASSERT_NE(y_ident, nullptr); - EXPECT_EQ(p->builder().Symbols().NameFor(y_ident->symbol), "height"); + EXPECT_EQ(p->builder().Symbols().NameFor(y_ident->identifier->symbol), "height"); ASSERT_EQ(values[2], nullptr); } diff --git a/src/tint/reader/wgsl/parser_impl_increment_decrement_stmt_test.cc b/src/tint/reader/wgsl/parser_impl_increment_decrement_stmt_test.cc index 79220e48e7..7b273f5ad5 100644 --- a/src/tint/reader/wgsl/parser_impl_increment_decrement_stmt_test.cc +++ b/src/tint/reader/wgsl/parser_impl_increment_decrement_stmt_test.cc @@ -30,8 +30,8 @@ TEST_F(ParserImplTest, IncrementDecrementStmt_Increment) { ASSERT_NE(i->lhs, nullptr); ASSERT_TRUE(i->lhs->Is()); - auto* ident = i->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = i->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); EXPECT_TRUE(i->increment); } @@ -49,8 +49,8 @@ TEST_F(ParserImplTest, IncrementDecrementStmt_Decrement) { ASSERT_NE(i->lhs, nullptr); ASSERT_TRUE(i->lhs->Is()); - auto* ident = i->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = i->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); EXPECT_FALSE(i->increment); } @@ -68,8 +68,8 @@ TEST_F(ParserImplTest, IncrementDecrementStmt_Parenthesized) { ASSERT_NE(i->lhs, nullptr); ASSERT_TRUE(i->lhs->Is()); - auto* ident = i->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = i->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); EXPECT_TRUE(i->increment); } @@ -91,8 +91,8 @@ TEST_F(ParserImplTest, IncrementDecrementStmt_ToMember) { auto* mem = i->lhs->As(); ASSERT_TRUE(mem->member->Is()); - auto* ident = mem->member->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("d")); + auto* ident_expr = mem->member->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("d")); ASSERT_TRUE(mem->structure->Is()); auto* idx = mem->structure->As(); @@ -104,19 +104,19 @@ TEST_F(ParserImplTest, IncrementDecrementStmt_ToMember) { ASSERT_TRUE(idx->object->Is()); mem = idx->object->As(); ASSERT_TRUE(mem->member->Is()); - ident = mem->member->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("c")); + ident_expr = mem->member->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("c")); ASSERT_TRUE(mem->structure->Is()); mem = mem->structure->As(); ASSERT_TRUE(mem->structure->Is()); - ident = mem->structure->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + ident_expr = mem->structure->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(mem->member->Is()); - ident = mem->member->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = mem->member->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, IncrementDecrementStmt_InvalidLHS) { diff --git a/src/tint/reader/wgsl/parser_impl_lhs_expression_test.cc b/src/tint/reader/wgsl/parser_impl_lhs_expression_test.cc index a8a476b48a..4801a01aae 100644 --- a/src/tint/reader/wgsl/parser_impl_lhs_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_lhs_expression_test.cc @@ -121,7 +121,7 @@ TEST_F(ParserImplTest, LHSExpression_PostfixExpression_Array) { ASSERT_TRUE(access->object->Is()); auto* obj = access->object->As(); - EXPECT_EQ(obj->symbol, p->builder().Symbols().Get("a")); + EXPECT_EQ(obj->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(access->index->Is()); auto* idx = access->index->As(); @@ -146,11 +146,11 @@ TEST_F(ParserImplTest, LHSExpression_PostfixExpression) { ASSERT_TRUE(access->structure->Is()); auto* struct_ident = access->structure->As(); - EXPECT_EQ(struct_ident->symbol, p->builder().Symbols().Get("a")); + EXPECT_EQ(struct_ident->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(access->member->Is()); auto* member_ident = access->member->As(); - EXPECT_EQ(member_ident->symbol, p->builder().Symbols().Get("foo")); + EXPECT_EQ(member_ident->identifier->symbol, p->builder().Symbols().Get("foo")); } TEST_F(ParserImplTest, LHSExpression_InvalidPostfixExpression) { diff --git a/src/tint/reader/wgsl/parser_impl_math_expression_test.cc b/src/tint/reader/wgsl/parser_impl_math_expression_test.cc index 27b5870bda..2b05500da9 100644 --- a/src/tint/reader/wgsl/parser_impl_math_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_math_expression_test.cc @@ -30,12 +30,12 @@ TEST_F(ParserImplTest, MathExpression_Parses_Multiplicative) { EXPECT_EQ(ast::BinaryOp::kMultiply, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, MathExpression_Parses_Mixed_MultiplicativeStart) { @@ -54,8 +54,8 @@ TEST_F(ParserImplTest, MathExpression_Parses_Mixed_MultiplicativeStart) { EXPECT_EQ(ast::BinaryOp::kAdd, rel->op); ASSERT_TRUE(rel->rhs->Is()); - auto* ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("c")); + auto* ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("c")); ASSERT_TRUE(rel->lhs->Is()); // lhs: a @@ -65,12 +65,12 @@ TEST_F(ParserImplTest, MathExpression_Parses_Mixed_MultiplicativeStart) { EXPECT_EQ(ast::BinaryOp::kMultiply, rel->op); ASSERT_TRUE(rel->lhs->Is()); - ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, MathExpression_Parses_Additive) { @@ -86,12 +86,12 @@ TEST_F(ParserImplTest, MathExpression_Parses_Additive) { EXPECT_EQ(ast::BinaryOp::kAdd, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, MathExpression_Parses_Mixed_AdditiveStart) { @@ -110,8 +110,8 @@ TEST_F(ParserImplTest, MathExpression_Parses_Mixed_AdditiveStart) { EXPECT_EQ(ast::BinaryOp::kAdd, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); // lhs: b @@ -121,12 +121,12 @@ TEST_F(ParserImplTest, MathExpression_Parses_Mixed_AdditiveStart) { EXPECT_EQ(ast::BinaryOp::kMultiply, rel->op); ASSERT_TRUE(rel->lhs->Is()); - ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("c")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("c")); } TEST_F(ParserImplTest, MathExpression_NoMatch_ReturnLHS) { diff --git a/src/tint/reader/wgsl/parser_impl_multiplicative_expression_test.cc b/src/tint/reader/wgsl/parser_impl_multiplicative_expression_test.cc index 941747798f..10ed0fb86e 100644 --- a/src/tint/reader/wgsl/parser_impl_multiplicative_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_multiplicative_expression_test.cc @@ -30,12 +30,12 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Multiply) { EXPECT_EQ(ast::BinaryOp::kMultiply, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Multiply_UnaryIndirect) { @@ -51,16 +51,16 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Multiply_UnaryIndirect) { EXPECT_EQ(ast::BinaryOp::kMultiply, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); auto* unary = rel->rhs->As(); EXPECT_EQ(ast::UnaryOp::kIndirection, unary->op); ASSERT_TRUE(unary->expr->Is()); - ident = unary->expr->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = unary->expr->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Divide) { @@ -76,12 +76,12 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Divide) { EXPECT_EQ(ast::BinaryOp::kDivide, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Modulo) { @@ -97,12 +97,12 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Modulo) { EXPECT_EQ(ast::BinaryOp::kModulo, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Grouping) { @@ -121,8 +121,8 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Grouping) { EXPECT_EQ(ast::BinaryOp::kMultiply, rel->op); ASSERT_TRUE(rel->rhs->Is()); - auto* ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("e")); + auto* ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("e")); ASSERT_TRUE(rel->lhs->Is()); // lhs: (a * b) / c @@ -132,8 +132,8 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Grouping) { EXPECT_EQ(ast::BinaryOp::kModulo, rel->op); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("d")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("d")); ASSERT_TRUE(rel->lhs->Is()); // lhs: a * b @@ -143,8 +143,8 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Grouping) { EXPECT_EQ(ast::BinaryOp::kDivide, rel->op); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("c")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("c")); ASSERT_TRUE(rel->lhs->Is()); // lhs: a @@ -154,12 +154,12 @@ TEST_F(ParserImplTest, MultiplicativeExpression_Parses_Grouping) { EXPECT_EQ(ast::BinaryOp::kMultiply, rel->op); ASSERT_TRUE(rel->lhs->Is()); - ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, MultiplicativeExpression_InvalidRHS) { diff --git a/src/tint/reader/wgsl/parser_impl_primary_expression_test.cc b/src/tint/reader/wgsl/parser_impl_primary_expression_test.cc index ec6561f1b5..1ced9dd083 100644 --- a/src/tint/reader/wgsl/parser_impl_primary_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_primary_expression_test.cc @@ -26,8 +26,8 @@ TEST_F(ParserImplTest, PrimaryExpression_Ident) { EXPECT_FALSE(p->has_error()) << p->error(); ASSERT_NE(e.value, nullptr); ASSERT_TRUE(e->Is()); - auto* ident = e->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = e->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); } TEST_F(ParserImplTest, PrimaryExpression_TypeDecl) { diff --git a/src/tint/reader/wgsl/parser_impl_relational_expression_test.cc b/src/tint/reader/wgsl/parser_impl_relational_expression_test.cc index ebd8ffd289..ddd275ded9 100644 --- a/src/tint/reader/wgsl/parser_impl_relational_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_relational_expression_test.cc @@ -35,8 +35,8 @@ TEST_F(ParserImplTest, RelationalExpression_PostUnary_Parses_LessThan) { EXPECT_EQ(ast::BinaryOp::kLessThan, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Register("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Register("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -60,8 +60,8 @@ TEST_F(ParserImplTest, RelationalExpression_PostUnary_Parses_GreaterThan) { EXPECT_EQ(ast::BinaryOp::kGreaterThan, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Register("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Register("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -85,8 +85,8 @@ TEST_F(ParserImplTest, RelationalExpression_PostUnary_Parses_LessThanEqual) { EXPECT_EQ(ast::BinaryOp::kLessThanEqual, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Register("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Register("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -110,8 +110,8 @@ TEST_F(ParserImplTest, RelationalExpression_PostUnary_Parses_GreaterThanEqual) { EXPECT_EQ(ast::BinaryOp::kGreaterThanEqual, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Register("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Register("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -135,8 +135,8 @@ TEST_F(ParserImplTest, RelationalExpression_PostUnary_Parses_Equal) { EXPECT_EQ(ast::BinaryOp::kEqual, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -160,8 +160,8 @@ TEST_F(ParserImplTest, RelationalExpression_PostUnary_Parses_NotEqual) { EXPECT_EQ(ast::BinaryOp::kNotEqual, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -199,8 +199,8 @@ TEST_F(ParserImplTest, RelationalExpression_Matches) { EXPECT_EQ(ast::BinaryOp::kGreaterThanEqual, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Register("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Register("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -243,8 +243,8 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_Equal) { EXPECT_EQ(ast::BinaryOp::kEqual, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -268,8 +268,8 @@ TEST_F(ParserImplTest, RelationalExpression_Parses_NotEqual) { EXPECT_EQ(ast::BinaryOp::kNotEqual, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); diff --git a/src/tint/reader/wgsl/parser_impl_shift_expression_test.cc b/src/tint/reader/wgsl/parser_impl_shift_expression_test.cc index 016f86f95d..4e5c785a13 100644 --- a/src/tint/reader/wgsl/parser_impl_shift_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_shift_expression_test.cc @@ -35,8 +35,8 @@ TEST_F(ParserImplTest, ShiftExpression_PostUnary_Parses_ShiftLeft) { EXPECT_EQ(ast::BinaryOp::kShiftLeft, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -60,8 +60,8 @@ TEST_F(ParserImplTest, ShiftExpression_PostUnary_Parses_ShiftRight) { EXPECT_EQ(ast::BinaryOp::kShiftRight, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); @@ -80,12 +80,12 @@ TEST_F(ParserImplTest, ShiftExpression_PostUnary_Parses_Additive) { EXPECT_EQ(ast::BinaryOp::kAdd, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, ShiftExpression_PostUnary_Parses_Multiplicative) { @@ -101,12 +101,12 @@ TEST_F(ParserImplTest, ShiftExpression_PostUnary_Parses_Multiplicative) { EXPECT_EQ(ast::BinaryOp::kMultiply, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); - ident = rel->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("b")); + ident_expr = rel->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, ShiftExpression_PostUnary_InvalidSpaceLeft) { @@ -160,8 +160,8 @@ TEST_F(ParserImplTest, ShiftExpression_Parses) { EXPECT_EQ(ast::BinaryOp::kShiftLeft, rel->op); ASSERT_TRUE(rel->lhs->Is()); - auto* ident = rel->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = rel->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(rel->rhs->Is()); ASSERT_TRUE(rel->rhs->As()->value); diff --git a/src/tint/reader/wgsl/parser_impl_singular_expression_test.cc b/src/tint/reader/wgsl/parser_impl_singular_expression_test.cc index a08b45a97e..3945693ee4 100644 --- a/src/tint/reader/wgsl/parser_impl_singular_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_singular_expression_test.cc @@ -29,8 +29,8 @@ TEST_F(ParserImplTest, SingularExpression_Array_ConstantIndex) { auto* idx = e->As(); ASSERT_TRUE(idx->object->Is()); - auto* ident = idx->object->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = idx->object->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(idx->index->Is()); EXPECT_EQ(idx->index->As()->value, 1); @@ -50,8 +50,8 @@ TEST_F(ParserImplTest, SingularExpression_Array_ExpressionIndex) { auto* idx = e->As(); ASSERT_TRUE(idx->object->Is()); - auto* ident = idx->object->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = idx->object->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(idx->index->Is()); } @@ -164,11 +164,10 @@ TEST_F(ParserImplTest, SingularExpression_MemberAccessor) { auto* m = e->As(); ASSERT_TRUE(m->structure->Is()); - EXPECT_EQ(m->structure->As()->symbol, + EXPECT_EQ(m->structure->As()->identifier->symbol, p->builder().Symbols().Get("a")); - ASSERT_TRUE(m->member->Is()); - EXPECT_EQ(m->member->As()->symbol, p->builder().Symbols().Get("b")); + EXPECT_EQ(m->member->identifier->symbol, p->builder().Symbols().Get("b")); } TEST_F(ParserImplTest, SingularExpression_MemberAccesssor_InvalidIdent) { @@ -214,18 +213,18 @@ TEST_F(ParserImplTest, SingularExpression_Array_NestedIndexAccessor) { const auto* outer_object = outer_accessor->object->As(); ASSERT_TRUE(outer_object); - EXPECT_EQ(outer_object->symbol, p->builder().Symbols().Get("a")); + EXPECT_EQ(outer_object->identifier->symbol, p->builder().Symbols().Get("a")); const auto* inner_accessor = outer_accessor->index->As(); ASSERT_TRUE(inner_accessor); const auto* inner_object = inner_accessor->object->As(); ASSERT_TRUE(inner_object); - EXPECT_EQ(inner_object->symbol, p->builder().Symbols().Get("b")); + EXPECT_EQ(inner_object->identifier->symbol, p->builder().Symbols().Get("b")); const auto* index_expr = inner_accessor->index->As(); ASSERT_TRUE(index_expr); - EXPECT_EQ(index_expr->symbol, p->builder().Symbols().Get("c")); + EXPECT_EQ(index_expr->identifier->symbol, p->builder().Symbols().Get("c")); } } // namespace diff --git a/src/tint/reader/wgsl/parser_impl_type_decl_test.cc b/src/tint/reader/wgsl/parser_impl_type_decl_test.cc index 0a4198ebef..0195d9b834 100644 --- a/src/tint/reader/wgsl/parser_impl_type_decl_test.cc +++ b/src/tint/reader/wgsl/parser_impl_type_decl_test.cc @@ -473,7 +473,7 @@ TEST_F(ParserImplTest, TypeDecl_Array_ConstantSize) { auto* count_expr = a->count->As(); ASSERT_NE(count_expr, nullptr); - EXPECT_EQ(p->builder().Symbols().NameFor(count_expr->symbol), "size"); + EXPECT_EQ(p->builder().Symbols().NameFor(count_expr->identifier->symbol), "size"); } TEST_F(ParserImplTest, TypeDecl_Array_ExpressionSize) { @@ -495,8 +495,8 @@ TEST_F(ParserImplTest, TypeDecl_Array_ExpressionSize) { EXPECT_EQ(ast::BinaryOp::kAdd, count_expr->op); ASSERT_TRUE(count_expr->lhs->Is()); - auto* ident = count_expr->lhs->As(); - EXPECT_EQ(p->builder().Symbols().NameFor(ident->symbol), "size"); + auto* ident_expr = count_expr->lhs->As(); + EXPECT_EQ(p->builder().Symbols().NameFor(ident_expr->identifier->symbol), "size"); ASSERT_TRUE(count_expr->rhs->Is()); auto* val = count_expr->rhs->As(); diff --git a/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc b/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc index 409062a84b..0c9eb6e24f 100644 --- a/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc +++ b/src/tint/reader/wgsl/parser_impl_type_decl_without_ident_test.cc @@ -464,7 +464,7 @@ TEST_F(ParserImplTest, TypeDeclWithoutIdent_Array_ConstantSize) { auto* count_expr = a->count->As(); ASSERT_NE(count_expr, nullptr); - EXPECT_EQ(p->builder().Symbols().NameFor(count_expr->symbol), "size"); + EXPECT_EQ(p->builder().Symbols().NameFor(count_expr->identifier->symbol), "size"); } TEST_F(ParserImplTest, TypeDeclWithoutIdent_Array_ExpressionSize) { @@ -487,7 +487,7 @@ TEST_F(ParserImplTest, TypeDeclWithoutIdent_Array_ExpressionSize) { ASSERT_TRUE(count_expr->lhs->Is()); auto* ident = count_expr->lhs->As(); - EXPECT_EQ(p->builder().Symbols().NameFor(ident->symbol), "size"); + EXPECT_EQ(p->builder().Symbols().NameFor(ident->identifier->symbol), "size"); ASSERT_TRUE(count_expr->rhs->Is()); auto* val = count_expr->rhs->As(); diff --git a/src/tint/reader/wgsl/parser_impl_unary_expression_test.cc b/src/tint/reader/wgsl/parser_impl_unary_expression_test.cc index 29598d9dbe..7d117f558d 100644 --- a/src/tint/reader/wgsl/parser_impl_unary_expression_test.cc +++ b/src/tint/reader/wgsl/parser_impl_unary_expression_test.cc @@ -29,8 +29,8 @@ TEST_F(ParserImplTest, UnaryExpression_Postix) { ASSERT_TRUE(e->Is()); auto* idx = e->As(); ASSERT_TRUE(idx->object->Is()); - auto* ident = idx->object->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("a")); + auto* ident_expr = idx->object->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("a")); ASSERT_TRUE(idx->index->Is()); ASSERT_EQ(idx->index->As()->value, 2); diff --git a/src/tint/reader/wgsl/parser_impl_variable_stmt_test.cc b/src/tint/reader/wgsl/parser_impl_variable_stmt_test.cc index 05f2976bf7..58d9a58eae 100644 --- a/src/tint/reader/wgsl/parser_impl_variable_stmt_test.cc +++ b/src/tint/reader/wgsl/parser_impl_variable_stmt_test.cc @@ -171,12 +171,12 @@ TEST_F(ParserImplTest, VariableStmt_Let_ComplexExpression) { EXPECT_EQ(expr->op, ast::BinaryOp::kAdd); ASSERT_TRUE(expr->lhs->Is()); - auto* ident = expr->lhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("collide")); + auto* ident_expr = expr->lhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("collide")); ASSERT_TRUE(expr->rhs->Is()); - ident = expr->rhs->As(); - EXPECT_EQ(ident->symbol, p->builder().Symbols().Get("collide_1")); + ident_expr = expr->rhs->As(); + EXPECT_EQ(ident_expr->identifier->symbol, p->builder().Symbols().Get("collide_1")); } TEST_F(ParserImplTest, VariableStmt_Let_MissingEqual) { diff --git a/src/tint/resolver/dependency_graph.cc b/src/tint/resolver/dependency_graph.cc index 5da6303ef0..c6e4e5bea2 100644 --- a/src/tint/resolver/dependency_graph.cc +++ b/src/tint/resolver/dependency_graph.cc @@ -354,7 +354,7 @@ class DependencyScanner { Switch( expr, [&](const ast::IdentifierExpression* ident) { - AddDependency(ident, ident->symbol, "identifier", "references"); + AddDependency(ident, ident->identifier->symbol, "identifier", "references"); }, [&](const ast::CallExpression* call) { if (call->target.name) { diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index ac45aacaf5..69a0df039e 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -2660,7 +2660,8 @@ sem::Expression* Resolver::Literal(const ast::LiteralExpression* literal) { } sem::Expression* Resolver::Identifier(const ast::IdentifierExpression* expr) { - auto symbol = expr->symbol; + Mark(expr->identifier); + auto symbol = expr->identifier->symbol; auto* sem_resolved = sem_.ResolvedSymbol(expr); if (auto* variable = As(sem_resolved)) { auto* user = builder_->create(expr, current_statement_, variable); @@ -2765,11 +2766,13 @@ sem::Expression* Resolver::MemberAccessor(const ast::MemberAccessorExpression* e // Object may be a side-effecting expression (e.g. function call). bool has_side_effects = object && object->HasSideEffects(); + Mark(expr->member); + Mark(expr->member->identifier); + return Switch( storage_ty, // [&](const sem::Struct* str) -> sem::Expression* { - Mark(expr->member); - auto symbol = expr->member->symbol; + auto symbol = expr->member->identifier->symbol; const sem::StructMember* member = nullptr; for (auto* m : str->Members()) { @@ -2802,8 +2805,7 @@ sem::Expression* Resolver::MemberAccessor(const ast::MemberAccessorExpression* e }, [&](const type::Vector* vec) -> sem::Expression* { - Mark(expr->member); - std::string s = builder_->Symbols().NameFor(expr->member->symbol); + std::string s = builder_->Symbols().NameFor(expr->member->identifier->symbol); auto size = s.size(); utils::Vector swizzle; swizzle.Reserve(s.size()); @@ -3059,7 +3061,9 @@ sem::Expression* Resolver::UnaryOp(const ast::UnaryOpExpression* unary) { bool Resolver::DiagnosticControl(const ast::DiagnosticControl* control) { Mark(control->rule_name); - auto rule_name = builder_->Symbols().NameFor(control->rule_name->symbol); + Mark(control->rule_name->identifier); + + auto rule_name = builder_->Symbols().NameFor(control->rule_name->identifier->symbol); auto rule = ast::ParseDiagnosticRule(rule_name); if (rule != ast::DiagnosticRule::kUndefined) { validator_.DiagnosticFilters().Set(rule, control->severity); diff --git a/src/tint/resolver/resolver_test.cc b/src/tint/resolver/resolver_test.cc index 0c0a344f29..32ec3c3503 100644 --- a/src/tint/resolver/resolver_test.cc +++ b/src/tint/resolver/resolver_test.cc @@ -2074,11 +2074,11 @@ TEST_F(ResolverTest, ASTNodeNotReached) { EXPECT_FATAL_FAILURE( { ProgramBuilder b; - b.Expr("expr"); + b.Ident("ident"); Resolver(&b).Resolve(); }, - "internal compiler error: AST node 'tint::ast::IdentifierExpression' was not reached by " - "the resolver"); + "internal compiler error: AST node 'tint::ast::Identifier' was not reached by the " + "resolver"); } TEST_F(ResolverTest, ASTNodeReachedTwice) { diff --git a/src/tint/resolver/uniformity.cc b/src/tint/resolver/uniformity.cc index f5463a1198..61cc7264c9 100644 --- a/src/tint/resolver/uniformity.cc +++ b/src/tint/resolver/uniformity.cc @@ -1144,7 +1144,7 @@ class UniformityGraph { auto* var_user = sem_.Get(ident)->Unwrap()->As(); auto* sem = var_user->Variable(); - auto* node = CreateNode({NameFor(ident), "_ident_expr"}, ident); + auto* node = CreateNode({NameFor(ident->identifier), "_ident_expr"}, ident); return Switch( sem, @@ -1365,7 +1365,7 @@ class UniformityGraph { return std::make_pair(cf, current_function_->may_be_non_uniform); } else if (auto* local = sem->Variable()->As()) { // Create a new value node for this variable. - auto* value = CreateNode({NameFor(i), "_lvalue"}); + auto* value = CreateNode({NameFor(i->identifier), "_lvalue"}); auto* old_value = current_function_->variables.Set(local, value); // If i is part of an expression that is a partial reference to a variable (e.g. @@ -1769,10 +1769,10 @@ class UniformityGraph { std::ostringstream ss; if (auto* param = var->As()) { auto* func = param->Owner()->As(); - ss << param_type(param) << "'" << NameFor(ident) << "' of '" + ss << param_type(param) << "'" << NameFor(ident->identifier) << "' of '" << NameFor(func->Declaration()) << "' may be non-uniform"; } else { - ss << "reading from " << var_type(var) << "'" << NameFor(ident) + ss << "reading from " << var_type(var) << "'" << NameFor(ident->identifier) << "' may result in a non-uniform value"; } diagnostics_.add_note(diag::System::Resolver, ss.str(), ident->source); diff --git a/src/tint/resolver/validator.cc b/src/tint/resolver/validator.cc index bba2f37b7b..eeeab83e35 100644 --- a/src/tint/resolver/validator.cc +++ b/src/tint/resolver/validator.cc @@ -2452,7 +2452,7 @@ bool Validator::DiagnosticControls(utils::VectorRef diagnostics; for (auto* dc : controls) { - auto diag_added = diagnostics.Add(dc->rule_name->symbol, dc); + auto diag_added = diagnostics.Add(dc->rule_name->identifier->symbol, dc); if (!diag_added && (*diag_added.value)->severity != dc->severity) { { std::ostringstream ss; @@ -2461,8 +2461,8 @@ bool Validator::DiagnosticControls(utils::VectorRefrule_name->symbol) << "' set to '" - << dc->severity << "' here"; + ss << "severity of '" << symbols_.NameFor(dc->rule_name->identifier->symbol) + << "' set to '" << dc->severity << "' here"; AddNote(ss.str(), (*diag_added.value)->source); } return false; diff --git a/src/tint/transform/decompose_memory_access.cc b/src/tint/transform/decompose_memory_access.cc index abb78b2f78..fdad12aa72 100644 --- a/src/tint/transform/decompose_memory_access.cc +++ b/src/tint/transform/decompose_memory_access.cc @@ -915,7 +915,7 @@ Transform::ApplyResult DecomposeMemoryAccess::Apply(const Program* src, } else { if (auto access = state.TakeAccess(accessor->structure)) { auto* str_ty = access.type->As(); - auto* member = str_ty->FindMember(accessor->member->symbol); + auto* member = str_ty->FindMember(accessor->member->identifier->symbol); auto offset = member->Offset(); state.AddAccess(accessor, { access.var, diff --git a/src/tint/transform/num_workgroups_from_uniform.cc b/src/tint/transform/num_workgroups_from_uniform.cc index 47f4ad107f..7fc9361906 100644 --- a/src/tint/transform/num_workgroups_from_uniform.cc +++ b/src/tint/transform/num_workgroups_from_uniform.cc @@ -177,7 +177,7 @@ Transform::ApplyResult NumWorkgroupsFromUniform::Apply(const Program* src, continue; } - if (to_replace.count({ident->symbol, accessor->member->symbol})) { + if (to_replace.count({ident->identifier->symbol, accessor->member->identifier->symbol})) { ctx.Replace(accessor, b.MemberAccessor(get_ubo()->symbol, kNumWorkgroupsMemberName)); } } diff --git a/src/tint/transform/renamer.cc b/src/tint/transform/renamer.cc index 325d3ace11..a25b67b8ee 100644 --- a/src/tint/transform/renamer.cc +++ b/src/tint/transform/renamer.cc @@ -1263,8 +1263,6 @@ Transform::ApplyResult Renamer::Apply(const Program* src, // Identifiers that need to keep their symbols preserved. utils::Hashset preserved_identifiers; - // Identifiers expressions that need to keep their symbols preserved. - utils::Hashset preserved_identifiers_expressions; // Type names that need to keep their symbols preserved. utils::Hashset preserved_type_names; @@ -1289,11 +1287,11 @@ Transform::ApplyResult Renamer::Apply(const Program* src, [&](const ast::MemberAccessorExpression* accessor) { auto* sem = src->Sem().Get(accessor)->UnwrapLoad(); if (sem->Is()) { - preserved_identifiers_expressions.Add(accessor->member); + preserved_identifiers.Add(accessor->member->identifier); } else if (auto* str_expr = src->Sem().Get(accessor->structure)) { if (auto* ty = str_expr->Type()->UnwrapRef()->As()) { if (ty->Declaration() == nullptr) { // Builtin structure - preserved_identifiers_expressions.Add(accessor->member); + preserved_identifiers.Add(accessor->member->identifier); } } } @@ -1316,7 +1314,7 @@ Transform::ApplyResult Renamer::Apply(const Program* src, } }, [&](const ast::DiagnosticControl* diagnostic) { - preserved_identifiers_expressions.Add(diagnostic->rule_name); + preserved_identifiers.Add(diagnostic->rule_name->identifier); }, [&](const ast::TypeName* type_name) { if (is_type_short_name(type_name->name)) { @@ -1388,16 +1386,6 @@ Transform::ApplyResult Renamer::Apply(const Program* src, return nullptr; // Clone ident. Uses the symbol remapping above. }); - ctx.ReplaceAll([&](const ast::IdentifierExpression* ident) -> const ast::IdentifierExpression* { - if (preserved_identifiers_expressions.Contains(ident)) { - auto sym_in = ident->symbol; - auto str = src->Symbols().NameFor(sym_in); - auto sym_out = b.Symbols().Register(str); - return ctx.dst->create(ctx.Clone(ident->source), sym_out); - } - return nullptr; // Clone ident. Uses the symbol remapping above. - }); - ctx.ReplaceAll([&](const ast::TypeName* type_name) -> const ast::TypeName* { if (preserved_type_names.Contains(type_name)) { auto sym_in = type_name->name; diff --git a/src/tint/writer/glsl/generator_impl.cc b/src/tint/writer/glsl/generator_impl.cc index df496944a4..d28c900181 100644 --- a/src/tint/writer/glsl/generator_impl.cc +++ b/src/tint/writer/glsl/generator_impl.cc @@ -1837,7 +1837,7 @@ bool GeneratorImpl::EmitExpression(std::ostream& out, const ast::Expression* exp } bool GeneratorImpl::EmitIdentifier(std::ostream& out, const ast::IdentifierExpression* expr) { - out << builder_.Symbols().NameFor(expr->symbol); + out << builder_.Symbols().NameFor(expr->identifier->symbol); return true; } @@ -2731,7 +2731,7 @@ bool GeneratorImpl::EmitMemberAccessor(std::ostream& out, sem, [&](const sem::Swizzle*) { // Swizzles output the name directly - out << builder_.Symbols().NameFor(expr->member->symbol); + out << builder_.Symbols().NameFor(expr->member->identifier->symbol); return true; }, [&](const sem::StructMemberAccess* member_access) { diff --git a/src/tint/writer/hlsl/generator_impl.cc b/src/tint/writer/hlsl/generator_impl.cc index d49bcc92e6..df50d73aca 100644 --- a/src/tint/writer/hlsl/generator_impl.cc +++ b/src/tint/writer/hlsl/generator_impl.cc @@ -2816,7 +2816,7 @@ bool GeneratorImpl::EmitExpression(std::ostream& out, const ast::Expression* exp } bool GeneratorImpl::EmitIdentifier(std::ostream& out, const ast::IdentifierExpression* expr) { - out << builder_.Symbols().NameFor(expr->symbol); + out << builder_.Symbols().NameFor(expr->identifier->symbol); return true; } @@ -3753,7 +3753,7 @@ bool GeneratorImpl::EmitMemberAccessor(std::ostream& out, sem, [&](const sem::Swizzle*) { // Swizzles output the name directly - out << builder_.Symbols().NameFor(expr->member->symbol); + out << builder_.Symbols().NameFor(expr->member->identifier->symbol); return true; }, [&](const sem::StructMemberAccess* member_access) { diff --git a/src/tint/writer/msl/generator_impl.cc b/src/tint/writer/msl/generator_impl.cc index 29ce69fd5f..208c433e63 100644 --- a/src/tint/writer/msl/generator_impl.cc +++ b/src/tint/writer/msl/generator_impl.cc @@ -2101,7 +2101,7 @@ bool GeneratorImpl::EmitEntryPointFunction(const ast::Function* func) { } bool GeneratorImpl::EmitIdentifier(std::ostream& out, const ast::IdentifierExpression* expr) { - out << program_->Symbols().NameFor(expr->symbol); + out << program_->Symbols().NameFor(expr->identifier->symbol); return true; } @@ -2369,7 +2369,7 @@ bool GeneratorImpl::EmitMemberAccessor(std::ostream& out, if (!write_lhs()) { return false; } - out << ")." << program_->Symbols().NameFor(expr->member->symbol); + out << ")." << program_->Symbols().NameFor(expr->member->identifier->symbol); } return true; }, diff --git a/src/tint/writer/spirv/builder.cc b/src/tint/writer/spirv/builder.cc index bab1f23cfb..fab7744649 100644 --- a/src/tint/writer/spirv/builder.cc +++ b/src/tint/writer/spirv/builder.cc @@ -1153,7 +1153,7 @@ uint32_t Builder::GenerateIdentifierExpression(const ast::IdentifierExpression* return LookupVariableID(user->Variable()); } } - error_ = "identifier '" + builder_.Symbols().NameFor(expr->symbol) + + error_ = "identifier '" + builder_.Symbols().NameFor(expr->identifier->symbol) + "' does not resolve to a variable"; return 0; } diff --git a/src/tint/writer/wgsl/generator_impl.cc b/src/tint/writer/wgsl/generator_impl.cc index 3619c57bda..10a5399f2b 100644 --- a/src/tint/writer/wgsl/generator_impl.cc +++ b/src/tint/writer/wgsl/generator_impl.cc @@ -110,7 +110,7 @@ bool GeneratorImpl::Generate() { bool GeneratorImpl::EmitDiagnosticControl(std::ostream& out, const ast::DiagnosticControl* diagnostic) { out << "diagnostic(" << diagnostic->severity << ", " - << program_->Symbols().NameFor(diagnostic->rule_name->symbol) << ")"; + << program_->Symbols().NameFor(diagnostic->rule_name->identifier->symbol) << ")"; return true; } @@ -298,7 +298,7 @@ bool GeneratorImpl::EmitLiteral(std::ostream& out, const ast::LiteralExpression* } bool GeneratorImpl::EmitIdentifier(std::ostream& out, const ast::IdentifierExpression* expr) { - out << program_->Symbols().NameFor(expr->symbol); + out << program_->Symbols().NameFor(expr->identifier->symbol); return true; }