diff --git a/src/tint/ast/binary_expression.h b/src/tint/ast/binary_expression.h index 323ab4840f..35ca308221 100644 --- a/src/tint/ast/binary_expression.h +++ b/src/tint/ast/binary_expression.h @@ -127,11 +127,11 @@ class BinaryExpression final : public Castable { /// @returns true if the op is an arithmetic operation inline bool IsArithmetic(BinaryOp op) { switch (op) { - case ast::BinaryOp::kAdd: - case ast::BinaryOp::kSubtract: - case ast::BinaryOp::kMultiply: - case ast::BinaryOp::kDivide: - case ast::BinaryOp::kModulo: + case BinaryOp::kAdd: + case BinaryOp::kSubtract: + case BinaryOp::kMultiply: + case BinaryOp::kDivide: + case BinaryOp::kModulo: return true; default: return false; @@ -142,12 +142,12 @@ inline bool IsArithmetic(BinaryOp op) { /// @returns true if the op is a comparison operation inline bool IsComparison(BinaryOp op) { switch (op) { - case ast::BinaryOp::kEqual: - case ast::BinaryOp::kNotEqual: - case ast::BinaryOp::kLessThan: - case ast::BinaryOp::kLessThanEqual: - case ast::BinaryOp::kGreaterThan: - case ast::BinaryOp::kGreaterThanEqual: + case BinaryOp::kEqual: + case BinaryOp::kNotEqual: + case BinaryOp::kLessThan: + case BinaryOp::kLessThanEqual: + case BinaryOp::kGreaterThan: + case BinaryOp::kGreaterThanEqual: return true; default: return false; @@ -158,9 +158,9 @@ inline bool IsComparison(BinaryOp op) { /// @returns true if the op is a bitwise operation inline bool IsBitwise(BinaryOp op) { switch (op) { - case ast::BinaryOp::kAnd: - case ast::BinaryOp::kOr: - case ast::BinaryOp::kXor: + case BinaryOp::kAnd: + case BinaryOp::kOr: + case BinaryOp::kXor: return true; default: return false; @@ -171,8 +171,8 @@ inline bool IsBitwise(BinaryOp op) { /// @returns true if the op is a bit shift operation inline bool IsBitshift(BinaryOp op) { switch (op) { - case ast::BinaryOp::kShiftLeft: - case ast::BinaryOp::kShiftRight: + case BinaryOp::kShiftLeft: + case BinaryOp::kShiftRight: return true; default: return false; @@ -181,8 +181,8 @@ inline bool IsBitshift(BinaryOp op) { inline bool BinaryExpression::IsLogical() const { switch (op) { - case ast::BinaryOp::kLogicalAnd: - case ast::BinaryOp::kLogicalOr: + case BinaryOp::kLogicalAnd: + case BinaryOp::kLogicalOr: return true; default: return false; diff --git a/src/tint/ast/binding_attribute.cc b/src/tint/ast/binding_attribute.cc index 38f1d0f889..1b08b28692 100644 --- a/src/tint/ast/binding_attribute.cc +++ b/src/tint/ast/binding_attribute.cc @@ -25,7 +25,7 @@ namespace tint::ast { BindingAttribute::BindingAttribute(ProgramID pid, NodeID nid, const Source& src, - const ast::Expression* exp) + const Expression* exp) : Base(pid, nid, src), expr(exp) {} BindingAttribute::~BindingAttribute() = default; diff --git a/src/tint/ast/binding_attribute.h b/src/tint/ast/binding_attribute.h index 7bb7add6a2..3ff7c97d35 100644 --- a/src/tint/ast/binding_attribute.h +++ b/src/tint/ast/binding_attribute.h @@ -30,7 +30,7 @@ class BindingAttribute final : public Castable { /// @param nid the unique node identifier /// @param src the source of this node /// @param expr the binding expression - BindingAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* expr); + BindingAttribute(ProgramID pid, NodeID nid, const Source& src, const Expression* expr); ~BindingAttribute() override; /// @returns the WGSL name for the attribute @@ -43,7 +43,7 @@ class BindingAttribute final : public Castable { const BindingAttribute* Clone(CloneContext* ctx) const override; /// the binding expression - const ast::Expression* const expr; + const Expression* const expr; }; } // namespace tint::ast diff --git a/src/tint/ast/block_statement_test.cc b/src/tint/ast/block_statement_test.cc index 5b2819c1a1..3037508698 100644 --- a/src/tint/ast/block_statement_test.cc +++ b/src/tint/ast/block_statement_test.cc @@ -63,8 +63,7 @@ TEST_F(BlockStatementTest, Assert_Null_Statement) { EXPECT_FATAL_FAILURE( { ProgramBuilder b; - b.create(utils::Vector{nullptr}, - utils::Empty); + b.create(utils::Vector{nullptr}, utils::Empty); }, "internal compiler error"); } diff --git a/src/tint/ast/builtin_texture_helper_test.cc b/src/tint/ast/builtin_texture_helper_test.cc index c4aefcf9b0..77db002dd1 100644 --- a/src/tint/ast/builtin_texture_helper_test.cc +++ b/src/tint/ast/builtin_texture_helper_test.cc @@ -128,13 +128,13 @@ std::ostream& operator<<(std::ostream& out, const TextureOverloadCase& data) { return out; } -ast::Type TextureOverloadCase::BuildResultVectorComponentType(ProgramBuilder* b) const { +Type TextureOverloadCase::BuildResultVectorComponentType(ProgramBuilder* b) const { switch (texture_data_type) { - case ast::builtin::test::TextureDataType::kF32: + case builtin::test::TextureDataType::kF32: return b->ty.f32(); - case ast::builtin::test::TextureDataType::kU32: + case builtin::test::TextureDataType::kU32: return b->ty.u32(); - case ast::builtin::test::TextureDataType::kI32: + case builtin::test::TextureDataType::kI32: return b->ty.i32(); } @@ -142,31 +142,31 @@ ast::Type TextureOverloadCase::BuildResultVectorComponentType(ProgramBuilder* b) return {}; } -const ast::Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b) const { +const Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b) const { utils::Vector attrs{ b->Group(0_u), b->Binding(0_a), }; switch (texture_kind) { - case ast::builtin::test::TextureKind::kRegular: + case builtin::test::TextureKind::kRegular: return b->GlobalVar( kTextureName, b->ty.sampled_texture(texture_dimension, BuildResultVectorComponentType(b)), attrs); - case ast::builtin::test::TextureKind::kDepth: + case builtin::test::TextureKind::kDepth: return b->GlobalVar(kTextureName, b->ty.depth_texture(texture_dimension), attrs); - case ast::builtin::test::TextureKind::kDepthMultisampled: + case builtin::test::TextureKind::kDepthMultisampled: return b->GlobalVar(kTextureName, b->ty.depth_multisampled_texture(texture_dimension), attrs); - case ast::builtin::test::TextureKind::kMultisampled: + case builtin::test::TextureKind::kMultisampled: return b->GlobalVar( kTextureName, b->ty.multisampled_texture(texture_dimension, BuildResultVectorComponentType(b)), attrs); - case ast::builtin::test::TextureKind::kStorage: { + case builtin::test::TextureKind::kStorage: { auto st = b->ty.storage_texture(texture_dimension, texel_format, access); return b->GlobalVar(kTextureName, st, attrs); } @@ -176,7 +176,7 @@ const ast::Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b return nullptr; } -const ast::Variable* TextureOverloadCase::BuildSamplerVariable(ProgramBuilder* b) const { +const Variable* TextureOverloadCase::BuildSamplerVariable(ProgramBuilder* b) const { utils::Vector attrs = {b->Group(0_a), b->Binding(1_a)}; return b->GlobalVar(kSamplerName, b->ty.sampler(sampler_kind), attrs); } diff --git a/src/tint/ast/builtin_texture_helper_test.h b/src/tint/ast/builtin_texture_helper_test.h index 609928a855..8bcb1a9fba 100644 --- a/src/tint/ast/builtin_texture_helper_test.h +++ b/src/tint/ast/builtin_texture_helper_test.h @@ -185,8 +185,8 @@ bool ReturnsVoid(ValidTextureOverload texture_overload); /// Describes a texture builtin overload struct TextureOverloadCase { - /// Args is a list of ast::Expression used as arguments to the texture overload case. - using Args = utils::Vector; + /// Args is a list of Expression used as arguments to the texture overload case. + using Args = utils::Vector; /// Constructor for textureSample...() functions TextureOverloadCase(ValidTextureOverload, @@ -225,15 +225,15 @@ struct TextureOverloadCase { /// @param builder the AST builder used for the test /// @returns the vector component type of the texture function return value - ast::Type BuildResultVectorComponentType(ProgramBuilder* builder) const; + Type BuildResultVectorComponentType(ProgramBuilder* builder) const; /// @param builder the AST builder used for the test /// @returns a variable holding the test texture, automatically registered as /// a global variable. - const ast::Variable* BuildTextureVariable(ProgramBuilder* builder) const; + const Variable* BuildTextureVariable(ProgramBuilder* builder) const; /// @param builder the AST builder used for the test /// @returns a Variable holding the test sampler, automatically registered as /// a global variable. - const ast::Variable* BuildSamplerVariable(ProgramBuilder* builder) const; + const Variable* BuildSamplerVariable(ProgramBuilder* builder) const; /// The enumerator for this overload const ValidTextureOverload overload; diff --git a/src/tint/ast/case_selector.cc b/src/tint/ast/case_selector.cc index 8622d3a105..7419fe524d 100644 --- a/src/tint/ast/case_selector.cc +++ b/src/tint/ast/case_selector.cc @@ -22,7 +22,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::CaseSelector); namespace tint::ast { -CaseSelector::CaseSelector(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* e) +CaseSelector::CaseSelector(ProgramID pid, NodeID nid, const Source& src, const Expression* e) : Base(pid, nid, src), expr(e) {} CaseSelector::CaseSelector(CaseSelector&&) = default; diff --git a/src/tint/ast/diagnostic_attribute.cc b/src/tint/ast/diagnostic_attribute.cc index 32e83d8dad..d93cc3a407 100644 --- a/src/tint/ast/diagnostic_attribute.cc +++ b/src/tint/ast/diagnostic_attribute.cc @@ -26,7 +26,7 @@ namespace tint::ast { DiagnosticAttribute::DiagnosticAttribute(ProgramID pid, NodeID nid, const Source& src, - ast::DiagnosticControl&& dc) + DiagnosticControl&& dc) : Base(pid, nid, src), control(std::move(dc)) {} DiagnosticAttribute::~DiagnosticAttribute() = default; diff --git a/src/tint/ast/diagnostic_attribute.h b/src/tint/ast/diagnostic_attribute.h index 2b8cb9fd42..ef1fa02fd6 100644 --- a/src/tint/ast/diagnostic_attribute.h +++ b/src/tint/ast/diagnostic_attribute.h @@ -30,7 +30,7 @@ class DiagnosticAttribute final : public Castable(Source{{{10, 5}, {10, 15}}}, std::move(control)); + auto* diag = DiagnosticDirective(Source{{{10, 5}, {10, 15}}}, + builtin::DiagnosticSeverity::kWarning, "foo"); EXPECT_EQ(diag->source.range.begin.line, 10u); EXPECT_EQ(diag->source.range.begin.column, 5u); EXPECT_EQ(diag->source.range.end.line, 10u); EXPECT_EQ(diag->source.range.end.column, 15u); EXPECT_EQ(diag->control.severity, builtin::DiagnosticSeverity::kWarning); - EXPECT_EQ(diag->control.rule_name, name); + CheckIdentifier(Symbols(), diag->control.rule_name, "foo"); } } // namespace diff --git a/src/tint/ast/enable_test.cc b/src/tint/ast/enable_test.cc index 921501866e..5622207383 100644 --- a/src/tint/ast/enable_test.cc +++ b/src/tint/ast/enable_test.cc @@ -22,7 +22,7 @@ namespace { using EnableTest = TestHelper; TEST_F(EnableTest, Creation) { - auto* ext = create(Source{{{20, 2}, {20, 5}}}, builtin::Extension::kF16); + auto* ext = Enable(Source{{{20, 2}, {20, 5}}}, builtin::Extension::kF16); EXPECT_EQ(ext->source.range.begin.line, 20u); EXPECT_EQ(ext->source.range.begin.column, 2u); EXPECT_EQ(ext->source.range.end.line, 20u); diff --git a/src/tint/ast/function.h b/src/tint/ast/function.h index 802f46dbbc..dc8cc70316 100644 --- a/src/tint/ast/function.h +++ b/src/tint/ast/function.h @@ -68,7 +68,7 @@ class Function final : public Castable { ast::PipelineStage PipelineStage() const; /// @returns true if this function is an entry point - bool IsEntryPoint() const { return PipelineStage() != PipelineStage::kNone; } + bool IsEntryPoint() const { return PipelineStage() != ast::PipelineStage::kNone; } /// Clones this node and all transitive child nodes using the `CloneContext` /// `ctx`. @@ -111,12 +111,12 @@ class FunctionList : public utils::Vector { /// @param sym the function symbol to search for /// @param stage the pipeline stage /// @returns the associated function or nullptr if none exists - const Function* Find(Symbol sym, PipelineStage stage) const; + const Function* Find(Symbol sym, ast::PipelineStage stage) const; /// @param stage the pipeline stage /// @returns true if the Builder contains an entrypoint function with /// the given stage - bool HasStage(PipelineStage stage) const; + bool HasStage(ast::PipelineStage stage) const; }; } // namespace tint::ast diff --git a/src/tint/ast/function_test.cc b/src/tint/ast/function_test.cc index a9b327e666..1af27a692c 100644 --- a/src/tint/ast/function_test.cc +++ b/src/tint/ast/function_test.cc @@ -65,23 +65,23 @@ TEST_F(FunctionTest, Creation_Body_Vector) { auto* f = Func("func", utils::Empty, ty.void_(), utils::Vector{Discard(), Return()}); ASSERT_NE(f->body, nullptr); ASSERT_EQ(f->body->statements.Length(), 2u); - EXPECT_TRUE(f->body->statements[0]->Is()); - EXPECT_TRUE(f->body->statements[1]->Is()); + EXPECT_TRUE(f->body->statements[0]->Is()); + EXPECT_TRUE(f->body->statements[1]->Is()); } TEST_F(FunctionTest, Creation_Body_Block) { auto* f = Func("func", utils::Empty, ty.void_(), Block(Discard(), Return())); ASSERT_NE(f->body, nullptr); ASSERT_EQ(f->body->statements.Length(), 2u); - EXPECT_TRUE(f->body->statements[0]->Is()); - EXPECT_TRUE(f->body->statements[1]->Is()); + EXPECT_TRUE(f->body->statements[0]->Is()); + EXPECT_TRUE(f->body->statements[1]->Is()); } TEST_F(FunctionTest, Creation_Body_Stmt) { auto* f = Func("func", utils::Empty, ty.void_(), Return()); ASSERT_NE(f->body, nullptr); ASSERT_EQ(f->body->statements.Length(), 1u); - EXPECT_TRUE(f->body->statements[0]->Is()); + EXPECT_TRUE(f->body->statements[0]->Is()); } TEST_F(FunctionTest, Creation_Body_Nullptr) { @@ -117,7 +117,7 @@ TEST_F(FunctionTest, Assert_TemplatedName) { } TEST_F(FunctionTest, Assert_NullParam) { - using ParamList = utils::Vector; + using ParamList = utils::Vector; EXPECT_FATAL_FAILURE( { ProgramBuilder b; diff --git a/src/tint/ast/group_attribute.cc b/src/tint/ast/group_attribute.cc index ff60bd573a..9c1952c459 100644 --- a/src/tint/ast/group_attribute.cc +++ b/src/tint/ast/group_attribute.cc @@ -22,10 +22,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::GroupAttribute); namespace tint::ast { -GroupAttribute::GroupAttribute(ProgramID pid, - NodeID nid, - const Source& src, - const ast::Expression* exp) +GroupAttribute::GroupAttribute(ProgramID pid, NodeID nid, const Source& src, const Expression* exp) : Base(pid, nid, src), expr(exp) {} GroupAttribute::~GroupAttribute() = default; diff --git a/src/tint/ast/group_attribute.h b/src/tint/ast/group_attribute.h index 552a69f6a4..af57eb5539 100644 --- a/src/tint/ast/group_attribute.h +++ b/src/tint/ast/group_attribute.h @@ -30,7 +30,7 @@ class GroupAttribute final : public Castable { /// @param nid the unique node identifier /// @param src the source of this node /// @param expr the group expression - GroupAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* expr); + GroupAttribute(ProgramID pid, NodeID nid, const Source& src, const Expression* expr); ~GroupAttribute() override; /// @returns the WGSL name for the attribute @@ -43,7 +43,7 @@ class GroupAttribute final : public Castable { const GroupAttribute* Clone(CloneContext* ctx) const override; /// The group expression - const ast::Expression* const expr; + const Expression* const expr; }; } // namespace tint::ast diff --git a/src/tint/ast/id_attribute.cc b/src/tint/ast/id_attribute.cc index 0515f01caf..b0567738ea 100644 --- a/src/tint/ast/id_attribute.cc +++ b/src/tint/ast/id_attribute.cc @@ -22,7 +22,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::IdAttribute); namespace tint::ast { -IdAttribute::IdAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* exp) +IdAttribute::IdAttribute(ProgramID pid, NodeID nid, const Source& src, const Expression* exp) : Base(pid, nid, src), expr(exp) {} IdAttribute::~IdAttribute() = default; diff --git a/src/tint/ast/id_attribute.h b/src/tint/ast/id_attribute.h index f683080d95..5557a062b8 100644 --- a/src/tint/ast/id_attribute.h +++ b/src/tint/ast/id_attribute.h @@ -30,7 +30,7 @@ class IdAttribute final : public Castable { /// @param nid the unique node identifier /// @param src the source of this node /// @param expr the numeric id expression - IdAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* expr); + IdAttribute(ProgramID pid, NodeID nid, const Source& src, const Expression* expr); ~IdAttribute() override; /// @returns the WGSL name for the attribute @@ -43,7 +43,7 @@ class IdAttribute final : public Castable { const IdAttribute* Clone(CloneContext* ctx) const override; /// The id expression - const ast::Expression* const expr; + const 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 eeef23b0bb..7541a1d954 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->expr->Is()); + EXPECT_TRUE(d->expr->Is()); } } // namespace diff --git a/src/tint/ast/identifier.h b/src/tint/ast/identifier.h index 0d99b00012..71601735b4 100644 --- a/src/tint/ast/identifier.h +++ b/src/tint/ast/identifier.h @@ -20,7 +20,7 @@ namespace tint::ast { /// An identifier -class Identifier : public Castable { +class Identifier : public Castable { public: /// Constructor /// @param pid the identifier of the program that owns this node diff --git a/src/tint/ast/identifier_expression_test.cc b/src/tint/ast/identifier_expression_test.cc index e31b654ab5..0e0e7c0a5b 100644 --- a/src/tint/ast/identifier_expression_test.cc +++ b/src/tint/ast/identifier_expression_test.cc @@ -30,10 +30,10 @@ TEST_F(IdentifierExpressionTest, Creation) { TEST_F(IdentifierExpressionTest, CreationTemplated) { auto* i = Expr(Ident("ident", true)); EXPECT_EQ(i->identifier->symbol, Symbol(1, ID())); - auto* tmpl_ident = i->identifier->As(); + auto* tmpl_ident = i->identifier->As(); ASSERT_NE(tmpl_ident, nullptr); EXPECT_EQ(tmpl_ident->arguments.Length(), 1_u); - EXPECT_TRUE(tmpl_ident->arguments[0]->Is()); + EXPECT_TRUE(tmpl_ident->arguments[0]->Is()); } TEST_F(IdentifierExpressionTest, Creation_WithSource) { diff --git a/src/tint/ast/if_statement.cc b/src/tint/ast/if_statement.cc index 5f7f1a7148..fdea1daf95 100644 --- a/src/tint/ast/if_statement.cc +++ b/src/tint/ast/if_statement.cc @@ -33,7 +33,7 @@ IfStatement::IfStatement(ProgramID pid, TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, body, program_id); if (else_statement) { TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, else_statement, program_id); - TINT_ASSERT(AST, (else_statement->IsAnyOf())); + TINT_ASSERT(AST, (else_statement->IsAnyOf())); } } diff --git a/src/tint/ast/location_attribute.cc b/src/tint/ast/location_attribute.cc index 4f34144b0a..b9b3f121e0 100644 --- a/src/tint/ast/location_attribute.cc +++ b/src/tint/ast/location_attribute.cc @@ -25,7 +25,7 @@ namespace tint::ast { LocationAttribute::LocationAttribute(ProgramID pid, NodeID nid, const Source& src, - const ast::Expression* exp) + const Expression* exp) : Base(pid, nid, src), expr(exp) {} LocationAttribute::~LocationAttribute() = default; diff --git a/src/tint/ast/location_attribute.h b/src/tint/ast/location_attribute.h index 43d5edf15e..a41e943c3a 100644 --- a/src/tint/ast/location_attribute.h +++ b/src/tint/ast/location_attribute.h @@ -30,7 +30,7 @@ class LocationAttribute final : public Castable { /// @param nid the unique node identifier /// @param src the source of this node /// @param expr the location expression - LocationAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* expr); + LocationAttribute(ProgramID pid, NodeID nid, const Source& src, const Expression* expr); ~LocationAttribute() override; /// @returns the WGSL name for the attribute @@ -43,7 +43,7 @@ class LocationAttribute final : public Castable { const LocationAttribute* Clone(CloneContext* ctx) const override; /// The location expression - const ast::Expression* const expr; + const Expression* const expr; }; } // namespace tint::ast diff --git a/src/tint/ast/module.cc b/src/tint/ast/module.cc index cbebab4cba..32dafe8c6f 100644 --- a/src/tint/ast/module.cc +++ b/src/tint/ast/module.cc @@ -28,7 +28,7 @@ Module::Module(ProgramID pid, NodeID nid, const Source& src) : Base(pid, nid, sr Module::Module(ProgramID pid, NodeID nid, const Source& src, - utils::VectorRef global_decls) + utils::VectorRef global_decls) : Base(pid, nid, src), global_declarations_(std::move(global_decls)) { for (auto* decl : global_declarations_) { if (decl == nullptr) { @@ -41,7 +41,7 @@ Module::Module(ProgramID pid, Module::~Module() = default; -const ast::TypeDecl* Module::LookupType(Symbol name) const { +const TypeDecl* Module::LookupType(Symbol name) const { for (auto* ty : TypeDecls()) { if (ty->name->symbol == name) { return ty; @@ -59,7 +59,7 @@ void Module::AddGlobalDeclaration(const tint::ast::Node* decl) { void Module::BinGlobalDeclaration(const tint::ast::Node* decl, diag::List& diags) { Switch( decl, // - [&](const ast::TypeDecl* type) { + [&](const TypeDecl* type) { TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, type, program_id); type_decls_.Push(type); }, @@ -86,21 +86,21 @@ void Module::BinGlobalDeclaration(const tint::ast::Node* decl, diag::List& diags [&](Default) { TINT_ICE(AST, diags) << "Unknown global declaration type"; }); } -void Module::AddDiagnosticDirective(const ast::DiagnosticDirective* directive) { +void Module::AddDiagnosticDirective(const DiagnosticDirective* directive) { TINT_ASSERT(AST, directive); TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, directive, program_id); global_declarations_.Push(directive); diagnostic_directives_.Push(directive); } -void Module::AddEnable(const ast::Enable* enable) { +void Module::AddEnable(const Enable* enable) { TINT_ASSERT(AST, enable); TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, enable, program_id); global_declarations_.Push(enable); enables_.Push(enable); } -void Module::AddGlobalVariable(const ast::Variable* var) { +void Module::AddGlobalVariable(const Variable* var) { TINT_ASSERT(AST, var); TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, var, program_id); global_variables_.Push(var); @@ -114,14 +114,14 @@ void Module::AddConstAssert(const ConstAssert* assertion) { global_declarations_.Push(assertion); } -void Module::AddTypeDecl(const ast::TypeDecl* type) { +void Module::AddTypeDecl(const TypeDecl* type) { TINT_ASSERT(AST, type); TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, type, program_id); type_decls_.Push(type); global_declarations_.Push(type); } -void Module::AddFunction(const ast::Function* func) { +void Module::AddFunction(const Function* func) { TINT_ASSERT(AST, func); TINT_ASSERT_PROGRAM_IDS_EQUAL_IF_VALID(AST, func, program_id); functions_.Push(func); diff --git a/src/tint/ast/module.h b/src/tint/ast/module.h index a19f2bd626..948f894e69 100644 --- a/src/tint/ast/module.h +++ b/src/tint/ast/module.h @@ -46,7 +46,7 @@ class Module final : public Castable { Module(ProgramID pid, NodeID nid, const Source& src, - utils::VectorRef global_decls); + utils::VectorRef global_decls); /// Destructor ~Module() override; @@ -80,7 +80,7 @@ class Module final : public Castable { auto& GlobalVariables() { return global_variables_; } /// @returns the global variable declarations of kind 'T' for the module - template > + template > auto Globals() const { utils::Vector out; out.Reserve(global_variables_.Length()); diff --git a/src/tint/ast/module_clone_test.cc b/src/tint/ast/module_clone_test.cc index 8657980d6c..eb7f775776 100644 --- a/src/tint/ast/module_clone_test.cc +++ b/src/tint/ast/module_clone_test.cc @@ -135,7 +135,7 @@ const declaration_order_check_4 : i32 = 1; EXPECT_EQ(Program::printer(&src), Program::printer(&dst)); // Check that none of the AST nodes or type pointers in dst are found in src - std::unordered_set src_nodes; + std::unordered_set src_nodes; for (auto* src_node : src.ASTNodes().Objects()) { src_nodes.emplace(src_node); } diff --git a/src/tint/ast/module_test.cc b/src/tint/ast/module_test.cc index 35c1b94d3d..c0255ffdee 100644 --- a/src/tint/ast/module_test.cc +++ b/src/tint/ast/module_test.cc @@ -61,9 +61,8 @@ TEST_F(ModuleTest, Assert_DifferentProgramID_Function) { { ProgramBuilder b1; ProgramBuilder b2; - b1.AST().AddFunction(b2.create(b2.Ident("func"), utils::Empty, - b2.ty.f32(), b2.Block(), utils::Empty, - utils::Empty)); + b1.AST().AddFunction(b2.create(b2.Ident("func"), utils::Empty, b2.ty.f32(), + b2.Block(), utils::Empty, utils::Empty)); }, "internal compiler error"); } @@ -102,7 +101,7 @@ TEST_F(ModuleTest, CloneOrder) { // declaration that triggered the ReplaceAll(). ProgramBuilder cloned; CloneContext ctx(&cloned, &p); - ctx.ReplaceAll([&](const ast::Function*) -> const ast::Function* { + ctx.ReplaceAll([&](const Function*) -> const Function* { ctx.dst->Alias("inserted_before_F", cloned.ty.u32()); return nullptr; }); @@ -110,7 +109,7 @@ TEST_F(ModuleTest, CloneOrder) { ctx.dst->Alias("inserted_before_A", cloned.ty.u32()); return nullptr; }); - ctx.ReplaceAll([&](const ast::Variable*) -> const ast::Variable* { + ctx.ReplaceAll([&](const Variable*) -> const Variable* { ctx.dst->Alias("inserted_before_V", cloned.ty.u32()); return nullptr; }); @@ -118,9 +117,9 @@ TEST_F(ModuleTest, CloneOrder) { auto& decls = cloned.AST().GlobalDeclarations(); ASSERT_EQ(decls.Length(), 6u); - EXPECT_TRUE(decls[1]->Is()); + EXPECT_TRUE(decls[1]->Is()); EXPECT_TRUE(decls[3]->Is()); - EXPECT_TRUE(decls[5]->Is()); + EXPECT_TRUE(decls[5]->Is()); ASSERT_TRUE(decls[0]->Is()); ASSERT_TRUE(decls[2]->Is()); diff --git a/src/tint/ast/struct.cc b/src/tint/ast/struct.cc index 2757c4e17e..96daeff838 100644 --- a/src/tint/ast/struct.cc +++ b/src/tint/ast/struct.cc @@ -26,8 +26,8 @@ Struct::Struct(ProgramID pid, NodeID nid, const Source& src, const Identifier* n, - utils::VectorRef m, - utils::VectorRef attrs) + utils::VectorRef m, + utils::VectorRef attrs) : Base(pid, nid, src, n), members(std::move(m)), attributes(std::move(attrs)) { for (auto* mem : members) { TINT_ASSERT(AST, mem); diff --git a/src/tint/ast/struct.h b/src/tint/ast/struct.h index 9668db1180..36ad08095d 100644 --- a/src/tint/ast/struct.h +++ b/src/tint/ast/struct.h @@ -39,8 +39,8 @@ class Struct final : public Castable { NodeID nid, const Source& src, const Identifier* name, - utils::VectorRef members, - utils::VectorRef attributes); + utils::VectorRef members, + utils::VectorRef attributes); /// Move constructor Struct(Struct&&); @@ -53,10 +53,10 @@ class Struct final : public Castable { const Struct* Clone(CloneContext* ctx) const override; /// The members - const utils::Vector members; + const utils::Vector members; /// The struct attributes - const utils::Vector attributes; + const utils::Vector attributes; }; } // namespace tint::ast diff --git a/src/tint/ast/struct_member_align_attribute.cc b/src/tint/ast/struct_member_align_attribute.cc index 2a213623e5..a7d69dae74 100644 --- a/src/tint/ast/struct_member_align_attribute.cc +++ b/src/tint/ast/struct_member_align_attribute.cc @@ -26,7 +26,7 @@ namespace tint::ast { StructMemberAlignAttribute::StructMemberAlignAttribute(ProgramID pid, NodeID nid, const Source& src, - const ast::Expression* a) + const Expression* a) : Base(pid, nid, src), expr(a) {} StructMemberAlignAttribute::~StructMemberAlignAttribute() = default; diff --git a/src/tint/ast/struct_member_align_attribute.h b/src/tint/ast/struct_member_align_attribute.h index 6da1894072..1649ae6786 100644 --- a/src/tint/ast/struct_member_align_attribute.h +++ b/src/tint/ast/struct_member_align_attribute.h @@ -34,7 +34,7 @@ class StructMemberAlignAttribute final : public Castableexpr->Is()); - EXPECT_EQ(2u, d->expr->As()->value); + ASSERT_TRUE(d->expr->Is()); + EXPECT_EQ(2u, d->expr->As()->value); } } // namespace diff --git a/src/tint/ast/struct_member_size_attribute.cc b/src/tint/ast/struct_member_size_attribute.cc index 833896decd..8d08ca86f5 100644 --- a/src/tint/ast/struct_member_size_attribute.cc +++ b/src/tint/ast/struct_member_size_attribute.cc @@ -26,7 +26,7 @@ namespace tint::ast { StructMemberSizeAttribute::StructMemberSizeAttribute(ProgramID pid, NodeID nid, const Source& src, - const ast::Expression* exp) + const Expression* exp) : Base(pid, nid, src), expr(exp) {} StructMemberSizeAttribute::~StructMemberSizeAttribute() = default; diff --git a/src/tint/ast/struct_member_size_attribute.h b/src/tint/ast/struct_member_size_attribute.h index c048b1fd1a..2a0c71fb70 100644 --- a/src/tint/ast/struct_member_size_attribute.h +++ b/src/tint/ast/struct_member_size_attribute.h @@ -31,10 +31,7 @@ class StructMemberSizeAttribute final : public Castableexpr->Is()); - EXPECT_EQ(2u, d->expr->As()->value); + ASSERT_TRUE(d->expr->Is()); + EXPECT_EQ(2u, d->expr->As()->value); } } // namespace diff --git a/src/tint/ast/struct_member_test.cc b/src/tint/ast/struct_member_test.cc index 94a072ff47..59eb30f4ec 100644 --- a/src/tint/ast/struct_member_test.cc +++ b/src/tint/ast/struct_member_test.cc @@ -23,8 +23,8 @@ using StructMemberTest = TestHelper; TEST_F(StructMemberTest, Creation) { auto* st = Member("a", ty.i32(), utils::Vector{MemberSize(4_a)}); - ast::CheckIdentifier(Symbols(), st->name, "a"); - ast::CheckIdentifier(Symbols(), st->type, "i32"); + CheckIdentifier(Symbols(), st->name, "a"); + CheckIdentifier(Symbols(), st->type, "i32"); EXPECT_EQ(st->attributes.Length(), 1u); EXPECT_TRUE(st->attributes[0]->Is()); EXPECT_EQ(st->source.range.begin.line, 0u); @@ -36,8 +36,8 @@ TEST_F(StructMemberTest, Creation) { TEST_F(StructMemberTest, CreationWithSource) { auto* st = Member(Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 8}}}, "a", ty.i32()); - ast::CheckIdentifier(Symbols(), st->name, "a"); - ast::CheckIdentifier(Symbols(), st->type, "i32"); + CheckIdentifier(Symbols(), st->name, "a"); + CheckIdentifier(Symbols(), st->type, "i32"); EXPECT_EQ(st->attributes.Length(), 0u); EXPECT_EQ(st->source.range.begin.line, 27u); EXPECT_EQ(st->source.range.begin.column, 4u); @@ -58,7 +58,7 @@ TEST_F(StructMemberTest, Assert_Null_Type) { EXPECT_FATAL_FAILURE( { ProgramBuilder b; - b.Member("a", ast::Type{}); + b.Member("a", Type{}); }, "internal compiler error"); } diff --git a/src/tint/ast/struct_test.cc b/src/tint/ast/struct_test.cc index cfb41819e9..1d147161c5 100644 --- a/src/tint/ast/struct_test.cc +++ b/src/tint/ast/struct_test.cc @@ -83,7 +83,7 @@ TEST_F(AstStructTest, Assert_Null_Attribute) { { ProgramBuilder b; b.Structure(b.Sym("S"), utils::Vector{b.Member("a", b.ty.i32())}, - utils::Vector{nullptr}); + utils::Vector{nullptr}); }, "internal compiler error"); } diff --git a/src/tint/ast/switch_statement_test.cc b/src/tint/ast/switch_statement_test.cc index 00c515ea3d..e6101c81a8 100644 --- a/src/tint/ast/switch_statement_test.cc +++ b/src/tint/ast/switch_statement_test.cc @@ -53,7 +53,7 @@ TEST_F(SwitchStatementTest, IsSwitch) { } TEST_F(SwitchStatementTest, Assert_Null_Condition) { - using CaseStatementList = utils::Vector; + using CaseStatementList = utils::Vector; EXPECT_FATAL_FAILURE( { ProgramBuilder b; @@ -66,7 +66,7 @@ TEST_F(SwitchStatementTest, Assert_Null_Condition) { } TEST_F(SwitchStatementTest, Assert_Null_CaseStatement) { - using CaseStatementList = utils::Vector; + using CaseStatementList = utils::Vector; EXPECT_FATAL_FAILURE( { ProgramBuilder b; diff --git a/src/tint/ast/traverse_expressions.h b/src/tint/ast/traverse_expressions.h index 629e010756..fb8aad1e93 100644 --- a/src/tint/ast/traverse_expressions.h +++ b/src/tint/ast/traverse_expressions.h @@ -57,24 +57,22 @@ enum class TraverseOrder { /// @param diags the diagnostics used for error messages /// @param callback the callback function. Must be of the signature: /// `TraverseAction(const T* expr)` or `TraverseAction(const T* expr, size_t depth)` where T -/// is an ast::Expression type. +/// is an Expression type. /// @return true on success, false on error template -bool TraverseExpressions(const ast::Expression* root, diag::List& diags, CALLBACK&& callback) { +bool TraverseExpressions(const Expression* root, diag::List& diags, CALLBACK&& callback) { using EXPR_TYPE = std::remove_pointer_t>; constexpr static bool kHasDepthArg = traits::SignatureOfT::parameter_count == 2; struct Pending { - const ast::Expression* expr; + const Expression* expr; size_t depth; }; utils::Vector to_visit{{root, 0}}; - auto push_single = [&](const ast::Expression* expr, size_t depth) { - to_visit.Push({expr, depth}); - }; - auto push_pair = [&](const ast::Expression* left, const ast::Expression* right, size_t depth) { + auto push_single = [&](const Expression* expr, size_t depth) { to_visit.Push({expr, depth}); }; + auto push_pair = [&](const Expression* left, const Expression* right, size_t depth) { if (ORDER == TraverseOrder::LeftToRight) { to_visit.Push({right, depth}); to_visit.Push({left, depth}); @@ -83,7 +81,7 @@ bool TraverseExpressions(const ast::Expression* root, diag::List& diags, CALLBAC to_visit.Push({right, depth}); } }; - auto push_list = [&](utils::VectorRef exprs, size_t depth) { + auto push_list = [&](utils::VectorRef exprs, size_t depth) { if (ORDER == TraverseOrder::LeftToRight) { for (auto* expr : utils::Reverse(exprs)) { to_visit.Push({expr, depth}); @@ -97,7 +95,7 @@ bool TraverseExpressions(const ast::Expression* root, diag::List& diags, CALLBAC while (!to_visit.IsEmpty()) { auto p = to_visit.Pop(); - const ast::Expression* expr = p.expr; + const Expression* expr = p.expr; if (auto* filtered = expr->template As()) { TraverseAction result; diff --git a/src/tint/ast/traverse_expressions_test.cc b/src/tint/ast/traverse_expressions_test.cc index f0226aa4a5..0db73c2b57 100644 --- a/src/tint/ast/traverse_expressions_test.cc +++ b/src/tint/ast/traverse_expressions_test.cc @@ -26,66 +26,66 @@ namespace { using TraverseExpressionsTest = TestHelper; TEST_F(TraverseExpressionsTest, DescendIndexAccessor) { - std::vector e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; - std::vector i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])}; + std::vector e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; + std::vector i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])}; auto* root = IndexAccessor(i[0], i[1]); { - std::vector l2r; + std::vector l2r; TraverseExpressions(root, Diagnostics(), - [&](const ast::Expression* expr) { + [&](const Expression* expr) { l2r.push_back(expr); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); EXPECT_THAT(l2r, ElementsAre(root, i[0], e[0], e[1], i[1], e[2], e[3])); } { - std::vector r2l; + std::vector r2l; TraverseExpressions(root, Diagnostics(), - [&](const ast::Expression* expr) { + [&](const Expression* expr) { r2l.push_back(expr); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); EXPECT_THAT(r2l, ElementsAre(root, i[1], e[3], e[2], i[0], e[1], e[0])); } } TEST_F(TraverseExpressionsTest, DescendBinaryExpression) { - std::vector e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; - std::vector i = {Add(e[0], e[1]), Sub(e[2], e[3])}; + std::vector e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; + std::vector i = {Add(e[0], e[1]), Sub(e[2], e[3])}; auto* root = Mul(i[0], i[1]); { - std::vector l2r; + std::vector l2r; TraverseExpressions(root, Diagnostics(), - [&](const ast::Expression* expr) { + [&](const Expression* expr) { l2r.push_back(expr); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); EXPECT_THAT(l2r, ElementsAre(root, i[0], e[0], e[1], i[1], e[2], e[3])); } { - std::vector r2l; + std::vector r2l; TraverseExpressions(root, Diagnostics(), - [&](const ast::Expression* expr) { + [&](const Expression* expr) { r2l.push_back(expr); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); EXPECT_THAT(r2l, ElementsAre(root, i[1], e[3], e[2], i[0], e[1], e[0])); } } TEST_F(TraverseExpressionsTest, Depth) { - std::vector e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; - std::vector i = {Add(e[0], e[1]), Sub(e[2], e[3])}; + std::vector e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; + std::vector i = {Add(e[0], e[1]), Sub(e[2], e[3])}; auto* root = Mul(i[0], i[1]); size_t j = 0; size_t depths[] = {0, 1, 2, 2, 1, 2, 2}; { TraverseExpressions( // - root, Diagnostics(), [&](const ast::Expression* expr, size_t depth) { + root, Diagnostics(), [&](const Expression* expr, size_t depth) { (void)expr; EXPECT_THAT(depth, depths[j++]); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); } } @@ -97,20 +97,20 @@ TEST_F(TraverseExpressionsTest, DescendBitcastExpression) { auto* b2 = Bitcast(b1); auto* root = Bitcast(b2); { - utils::Vector l2r; + utils::Vector l2r; TraverseExpressions(root, Diagnostics(), - [&](const ast::Expression* expr) { + [&](const Expression* expr) { l2r.Push(expr); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); EXPECT_THAT(l2r, ElementsAre(root, b2, b1, b0, e)); } { - utils::Vector r2l; + utils::Vector r2l; TraverseExpressions(root, Diagnostics(), - [&](const ast::Expression* expr) { + [&](const Expression* expr) { r2l.Push(expr); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); EXPECT_THAT(r2l, ElementsAre(root, b2, b1, b0, e)); } @@ -121,20 +121,20 @@ TEST_F(TraverseExpressionsTest, DescendCallExpression) { utils::Vector c{Call("a", e[0], e[1]), Call("b", e[2], e[3])}; auto* root = Call("c", c[0], c[1]); { - utils::Vector l2r; + utils::Vector l2r; TraverseExpressions(root, Diagnostics(), - [&](const ast::Expression* expr) { + [&](const Expression* expr) { l2r.Push(expr); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); EXPECT_THAT(l2r, ElementsAre(root, c[0], e[0], e[1], c[1], e[2], e[3])); } { - utils::Vector r2l; + utils::Vector r2l; TraverseExpressions(root, Diagnostics(), - [&](const ast::Expression* expr) { + [&](const Expression* expr) { r2l.Push(expr); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); EXPECT_THAT(r2l, ElementsAre(root, c[1], e[3], e[2], c[0], e[1], e[0])); } @@ -145,20 +145,20 @@ TEST_F(TraverseExpressionsTest, DescendMemberAccessorExpression) { auto* m = MemberAccessor(e, "a"); auto* root = MemberAccessor(m, "b"); { - std::vector l2r; + std::vector l2r; TraverseExpressions(root, Diagnostics(), - [&](const ast::Expression* expr) { + [&](const Expression* expr) { l2r.push_back(expr); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); EXPECT_THAT(l2r, ElementsAre(root, m, e)); } { - std::vector r2l; + std::vector r2l; TraverseExpressions(root, Diagnostics(), - [&](const ast::Expression* expr) { + [&](const Expression* expr) { r2l.push_back(expr); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); EXPECT_THAT(r2l, ElementsAre(root, m, e)); } @@ -173,20 +173,20 @@ TEST_F(TraverseExpressionsTest, DescendMemberIndexExpression) { auto* f = IndexAccessor(d, e); auto* root = IndexAccessor(c, f); { - std::vector l2r; + std::vector l2r; TraverseExpressions(root, Diagnostics(), - [&](const ast::Expression* expr) { + [&](const Expression* expr) { l2r.push_back(expr); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); EXPECT_THAT(l2r, ElementsAre(root, c, a, b, f, d, e)); } { - std::vector r2l; + std::vector r2l; TraverseExpressions(root, Diagnostics(), - [&](const ast::Expression* expr) { + [&](const Expression* expr) { r2l.push_back(expr); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); EXPECT_THAT(r2l, ElementsAre(root, f, e, d, c, b, a)); } @@ -199,47 +199,47 @@ TEST_F(TraverseExpressionsTest, DescendUnaryExpression) { auto* u2 = AddressOf(u1); auto* root = Deref(u2); { - std::vector l2r; + std::vector l2r; TraverseExpressions(root, Diagnostics(), - [&](const ast::Expression* expr) { + [&](const Expression* expr) { l2r.push_back(expr); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); EXPECT_THAT(l2r, ElementsAre(root, u2, u1, u0, e)); } { - std::vector r2l; + std::vector r2l; TraverseExpressions(root, Diagnostics(), - [&](const ast::Expression* expr) { + [&](const Expression* expr) { r2l.push_back(expr); - return ast::TraverseAction::Descend; + return TraverseAction::Descend; }); EXPECT_THAT(r2l, ElementsAre(root, u2, u1, u0, e)); } } TEST_F(TraverseExpressionsTest, Skip) { - std::vector e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; - std::vector i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])}; + std::vector e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; + std::vector i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])}; auto* root = IndexAccessor(i[0], i[1]); - std::vector order; + std::vector order; TraverseExpressions( - root, Diagnostics(), [&](const ast::Expression* expr) { + root, Diagnostics(), [&](const Expression* expr) { order.push_back(expr); - return expr == i[0] ? ast::TraverseAction::Skip : ast::TraverseAction::Descend; + return expr == i[0] ? TraverseAction::Skip : TraverseAction::Descend; }); EXPECT_THAT(order, ElementsAre(root, i[0], i[1], e[2], e[3])); } TEST_F(TraverseExpressionsTest, Stop) { - std::vector e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; - std::vector i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])}; + std::vector e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; + std::vector i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])}; auto* root = IndexAccessor(i[0], i[1]); - std::vector order; + std::vector order; TraverseExpressions( - root, Diagnostics(), [&](const ast::Expression* expr) { + root, Diagnostics(), [&](const Expression* expr) { order.push_back(expr); - return expr == i[0] ? ast::TraverseAction::Stop : ast::TraverseAction::Descend; + return expr == i[0] ? TraverseAction::Stop : TraverseAction::Descend; }); EXPECT_THAT(order, ElementsAre(root, i[0])); } diff --git a/src/tint/ast/variable.h b/src/tint/ast/variable.h index f8a17a3dcc..70e5116c97 100644 --- a/src/tint/ast/variable.h +++ b/src/tint/ast/variable.h @@ -66,8 +66,8 @@ class Variable : public Castable { /// @returns true if the variable has both group and binding attributes bool HasBindingPoint() const { - return ast::GetAttribute(attributes) != nullptr && - ast::GetAttribute(attributes) != nullptr; + return HasAttribute(attributes) && + HasAttribute(attributes); } /// @returns the kind of the variable, which can be used in diagnostics diff --git a/src/tint/ast/variable_test.cc b/src/tint/ast/variable_test.cc index 0b4602611c..6fbc42005a 100644 --- a/src/tint/ast/variable_test.cc +++ b/src/tint/ast/variable_test.cc @@ -98,14 +98,14 @@ TEST_F(VariableTest, WithAttributes) { Builtin(builtin::BuiltinValue::kPosition), Id(1200_u)); auto& attributes = var->attributes; - EXPECT_TRUE(ast::HasAttribute(attributes)); - EXPECT_TRUE(ast::HasAttribute(attributes)); - EXPECT_TRUE(ast::HasAttribute(attributes)); + EXPECT_TRUE(ast::HasAttribute(attributes)); + EXPECT_TRUE(ast::HasAttribute(attributes)); + EXPECT_TRUE(ast::HasAttribute(attributes)); - auto* location = ast::GetAttribute(attributes); + auto* location = GetAttribute(attributes); ASSERT_NE(nullptr, location); ASSERT_NE(nullptr, location->expr); - EXPECT_TRUE(location->expr->Is()); + EXPECT_TRUE(location->expr->Is()); } TEST_F(VariableTest, HasBindingPoint_BothProvided) { diff --git a/src/tint/ast/workgroup_attribute.cc b/src/tint/ast/workgroup_attribute.cc index 7cb67dc586..3167f5921e 100644 --- a/src/tint/ast/workgroup_attribute.cc +++ b/src/tint/ast/workgroup_attribute.cc @@ -25,9 +25,9 @@ namespace tint::ast { WorkgroupAttribute::WorkgroupAttribute(ProgramID pid, NodeID nid, const Source& src, - const ast::Expression* x_, - const ast::Expression* y_, - const ast::Expression* z_) + const Expression* x_, + const Expression* y_, + const Expression* z_) : Base(pid, nid, src), x(x_), y(y_), z(z_) {} WorkgroupAttribute::~WorkgroupAttribute() = default; diff --git a/src/tint/ast/workgroup_attribute.h b/src/tint/ast/workgroup_attribute.h index e27e77e900..05cbb89cd3 100644 --- a/src/tint/ast/workgroup_attribute.h +++ b/src/tint/ast/workgroup_attribute.h @@ -40,14 +40,14 @@ class WorkgroupAttribute final : public Castable WorkgroupAttribute(ProgramID pid, NodeID nid, const Source& src, - const ast::Expression* x, - const ast::Expression* y = nullptr, - const ast::Expression* z = nullptr); + const Expression* x, + const Expression* y = nullptr, + const Expression* z = nullptr); ~WorkgroupAttribute() override; /// @returns the workgroup dimensions - std::array Values() const { return {x, y, z}; } + std::array Values() const { return {x, y, z}; } /// @returns the WGSL name for the attribute std::string Name() const override; @@ -59,11 +59,11 @@ class WorkgroupAttribute final : public Castable const WorkgroupAttribute* Clone(CloneContext* ctx) const override; /// The workgroup x dimension. - const ast::Expression* const x; + const Expression* const x; /// The optional workgroup y dimension. May be null. - const ast::Expression* const y = nullptr; + const Expression* const y = nullptr; /// The optional workgroup z dimension. May be null. - const ast::Expression* const z = nullptr; + const Expression* const z = nullptr; }; } // namespace tint::ast diff --git a/src/tint/ast/workgroup_attribute_test.cc b/src/tint/ast/workgroup_attribute_test.cc index 97a034bb9b..3363e52eb0 100644 --- a/src/tint/ast/workgroup_attribute_test.cc +++ b/src/tint/ast/workgroup_attribute_test.cc @@ -28,8 +28,8 @@ TEST_F(WorkgroupAttributeTest, Creation_1param) { auto* d = WorkgroupSize(2_i); auto values = d->Values(); - ASSERT_TRUE(values[0]->Is()); - EXPECT_EQ(values[0]->As()->value, 2); + ASSERT_TRUE(values[0]->Is()); + EXPECT_EQ(values[0]->As()->value, 2); EXPECT_EQ(values[1], nullptr); EXPECT_EQ(values[2], nullptr); @@ -38,11 +38,11 @@ TEST_F(WorkgroupAttributeTest, Creation_2param) { auto* d = WorkgroupSize(2_i, 4_i); auto values = d->Values(); - ASSERT_TRUE(values[0]->Is()); - EXPECT_EQ(values[0]->As()->value, 2); + ASSERT_TRUE(values[0]->Is()); + EXPECT_EQ(values[0]->As()->value, 2); - ASSERT_TRUE(values[1]->Is()); - EXPECT_EQ(values[1]->As()->value, 4); + ASSERT_TRUE(values[1]->Is()); + EXPECT_EQ(values[1]->As()->value, 4); EXPECT_EQ(values[2], nullptr); } @@ -51,27 +51,27 @@ TEST_F(WorkgroupAttributeTest, Creation_3param) { auto* d = WorkgroupSize(2_i, 4_i, 6_i); auto values = d->Values(); - ASSERT_TRUE(values[0]->Is()); - EXPECT_EQ(values[0]->As()->value, 2); + ASSERT_TRUE(values[0]->Is()); + EXPECT_EQ(values[0]->As()->value, 2); - ASSERT_TRUE(values[1]->Is()); - EXPECT_EQ(values[1]->As()->value, 4); + ASSERT_TRUE(values[1]->Is()); + EXPECT_EQ(values[1]->As()->value, 4); - ASSERT_TRUE(values[2]->Is()); - EXPECT_EQ(values[2]->As()->value, 6); + ASSERT_TRUE(values[2]->Is()); + EXPECT_EQ(values[2]->As()->value, 6); } TEST_F(WorkgroupAttributeTest, Creation_WithIdentifier) { auto* d = WorkgroupSize(2_i, 4_i, "depth"); auto values = d->Values(); - ASSERT_TRUE(values[0]->Is()); - EXPECT_EQ(values[0]->As()->value, 2); + ASSERT_TRUE(values[0]->Is()); + EXPECT_EQ(values[0]->As()->value, 2); - ASSERT_TRUE(values[1]->Is()); - EXPECT_EQ(values[1]->As()->value, 4); + ASSERT_TRUE(values[1]->Is()); + EXPECT_EQ(values[1]->As()->value, 4); - auto* z_ident = As(values[2]); + auto* z_ident = As(values[2]); ASSERT_TRUE(z_ident); EXPECT_EQ(Symbols().NameFor(z_ident->identifier->symbol), "depth"); }