tint/ast: Remove unnecessary ast:: prefixes These uses are already in the ast namespace, so do not need the extra qualification. Change-Id: I5e66048c9485c55b72e61ffa5b85b17ba1c780d0 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/120761 Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com> Commit-Queue: Ben Clayton <bclayton@chromium.org>
diff --git a/src/tint/ast/binary_expression.h b/src/tint/ast/binary_expression.h index 323ab48..35ca308 100644 --- a/src/tint/ast/binary_expression.h +++ b/src/tint/ast/binary_expression.h
@@ -127,11 +127,11 @@ /// @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 @@ /// @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 @@ /// @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 @@ /// @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 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 38f1d0f..1b08b28 100644 --- a/src/tint/ast/binding_attribute.cc +++ b/src/tint/ast/binding_attribute.cc
@@ -25,7 +25,7 @@ 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 7bb7add..3ff7c97 100644 --- a/src/tint/ast/binding_attribute.h +++ b/src/tint/ast/binding_attribute.h
@@ -30,7 +30,7 @@ /// @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 @@ 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 5b2819c..3037508 100644 --- a/src/tint/ast/block_statement_test.cc +++ b/src/tint/ast/block_statement_test.cc
@@ -63,8 +63,7 @@ EXPECT_FATAL_FAILURE( { ProgramBuilder b; - b.create<BlockStatement>(utils::Vector<const ast::Statement*, 1>{nullptr}, - utils::Empty); + b.create<BlockStatement>(utils::Vector<const Statement*, 1>{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 c4aefcf..77db002d 100644 --- a/src/tint/ast/builtin_texture_helper_test.cc +++ b/src/tint/ast/builtin_texture_helper_test.cc
@@ -128,13 +128,13 @@ 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 @@ 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 @@ 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 609928a..8bcb1a9 100644 --- a/src/tint/ast/builtin_texture_helper_test.h +++ b/src/tint/ast/builtin_texture_helper_test.h
@@ -185,8 +185,8 @@ /// 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<const ast::Expression*, 8>; + /// Args is a list of Expression used as arguments to the texture overload case. + using Args = utils::Vector<const Expression*, 8>; /// Constructor for textureSample...() functions TextureOverloadCase(ValidTextureOverload, @@ -225,15 +225,15 @@ /// @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 8622d3a..7419fe5 100644 --- a/src/tint/ast/case_selector.cc +++ b/src/tint/ast/case_selector.cc
@@ -22,7 +22,7 @@ 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 32e83d8..d93cc3a 100644 --- a/src/tint/ast/diagnostic_attribute.cc +++ b/src/tint/ast/diagnostic_attribute.cc
@@ -26,7 +26,7 @@ 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 2b8cb9f..ef1fa02 100644 --- a/src/tint/ast/diagnostic_attribute.h +++ b/src/tint/ast/diagnostic_attribute.h
@@ -30,7 +30,7 @@ /// @param nid the unique node identifier /// @param src the source of this node /// @param dc the diagnostic control - DiagnosticAttribute(ProgramID pid, NodeID nid, const Source& src, ast::DiagnosticControl&& dc); + DiagnosticAttribute(ProgramID pid, NodeID nid, const Source& src, DiagnosticControl&& dc); ~DiagnosticAttribute() override; /// @returns the WGSL name for the attribute @@ -42,7 +42,7 @@ const DiagnosticAttribute* Clone(CloneContext* ctx) const override; /// The diagnostic control. - const ast::DiagnosticControl control; + const DiagnosticControl control; }; } // namespace tint::ast
diff --git a/src/tint/ast/diagnostic_control_test.cc b/src/tint/ast/diagnostic_control_test.cc index 73dd2ea..53afe53 100644 --- a/src/tint/ast/diagnostic_control_test.cc +++ b/src/tint/ast/diagnostic_control_test.cc
@@ -28,8 +28,8 @@ EXPECT_FATAL_FAILURE( { ProgramBuilder b; - ast::DiagnosticControl control(builtin::DiagnosticSeverity::kWarning, - b.Ident("name", "a", "b", "c")); + DiagnosticControl control(builtin::DiagnosticSeverity::kWarning, + b.Ident("name", "a", "b", "c")); }, "internal compiler error"); }
diff --git a/src/tint/ast/diagnostic_directive_test.cc b/src/tint/ast/diagnostic_directive_test.cc index fe8fc5c..3e23d6a 100644 --- a/src/tint/ast/diagnostic_directive_test.cc +++ b/src/tint/ast/diagnostic_directive_test.cc
@@ -22,15 +22,14 @@ using DiagnosticDirectiveTest = TestHelper; TEST_F(DiagnosticDirectiveTest, Creation) { - auto* name = Ident("foo"); - DiagnosticControl control(builtin::DiagnosticSeverity::kWarning, name); - auto* diag = create<ast::DiagnosticDirective>(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 9215018..5622207 100644 --- a/src/tint/ast/enable_test.cc +++ b/src/tint/ast/enable_test.cc
@@ -22,7 +22,7 @@ using EnableTest = TestHelper; TEST_F(EnableTest, Creation) { - auto* ext = create<ast::Enable>(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 802f46d..dc8cc70 100644 --- a/src/tint/ast/function.h +++ b/src/tint/ast/function.h
@@ -68,7 +68,7 @@ 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 @@ /// @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 a9b327e..1af27a6 100644 --- a/src/tint/ast/function_test.cc +++ b/src/tint/ast/function_test.cc
@@ -65,23 +65,23 @@ 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<ast::DiscardStatement>()); - EXPECT_TRUE(f->body->statements[1]->Is<ast::ReturnStatement>()); + EXPECT_TRUE(f->body->statements[0]->Is<DiscardStatement>()); + EXPECT_TRUE(f->body->statements[1]->Is<ReturnStatement>()); } 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<ast::DiscardStatement>()); - EXPECT_TRUE(f->body->statements[1]->Is<ast::ReturnStatement>()); + EXPECT_TRUE(f->body->statements[0]->Is<DiscardStatement>()); + EXPECT_TRUE(f->body->statements[1]->Is<ReturnStatement>()); } 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<ast::ReturnStatement>()); + EXPECT_TRUE(f->body->statements[0]->Is<ReturnStatement>()); } TEST_F(FunctionTest, Creation_Body_Nullptr) { @@ -117,7 +117,7 @@ } TEST_F(FunctionTest, Assert_NullParam) { - using ParamList = utils::Vector<const ast::Parameter*, 2>; + using ParamList = utils::Vector<const Parameter*, 2>; EXPECT_FATAL_FAILURE( { ProgramBuilder b;
diff --git a/src/tint/ast/group_attribute.cc b/src/tint/ast/group_attribute.cc index ff60bd5..9c1952c 100644 --- a/src/tint/ast/group_attribute.cc +++ b/src/tint/ast/group_attribute.cc
@@ -22,10 +22,7 @@ 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 552a69f..af57eb5 100644 --- a/src/tint/ast/group_attribute.h +++ b/src/tint/ast/group_attribute.h
@@ -30,7 +30,7 @@ /// @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 @@ 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 0515f01..b056773 100644 --- a/src/tint/ast/id_attribute.cc +++ b/src/tint/ast/id_attribute.cc
@@ -22,7 +22,7 @@ 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 f683080..5557a06 100644 --- a/src/tint/ast/id_attribute.h +++ b/src/tint/ast/id_attribute.h
@@ -30,7 +30,7 @@ /// @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 @@ 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 eeef23b..7541a1d 100644 --- a/src/tint/ast/id_attribute_test.cc +++ b/src/tint/ast/id_attribute_test.cc
@@ -24,7 +24,7 @@ TEST_F(IdAttributeTest, Creation) { auto* d = Id(12_a); - EXPECT_TRUE(d->expr->Is<ast::IntLiteralExpression>()); + EXPECT_TRUE(d->expr->Is<IntLiteralExpression>()); } } // namespace
diff --git a/src/tint/ast/identifier.h b/src/tint/ast/identifier.h index 0d99b00..7160173 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<Identifier, ast::Node> { +class Identifier : public Castable<Identifier, Node> { 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 e31b654..0e0e7c0 100644 --- a/src/tint/ast/identifier_expression_test.cc +++ b/src/tint/ast/identifier_expression_test.cc
@@ -30,10 +30,10 @@ TEST_F(IdentifierExpressionTest, CreationTemplated) { auto* i = Expr(Ident("ident", true)); EXPECT_EQ(i->identifier->symbol, Symbol(1, ID())); - auto* tmpl_ident = i->identifier->As<ast::TemplatedIdentifier>(); + auto* tmpl_ident = i->identifier->As<TemplatedIdentifier>(); ASSERT_NE(tmpl_ident, nullptr); EXPECT_EQ(tmpl_ident->arguments.Length(), 1_u); - EXPECT_TRUE(tmpl_ident->arguments[0]->Is<ast::BoolLiteralExpression>()); + EXPECT_TRUE(tmpl_ident->arguments[0]->Is<BoolLiteralExpression>()); } TEST_F(IdentifierExpressionTest, Creation_WithSource) {
diff --git a/src/tint/ast/if_statement.cc b/src/tint/ast/if_statement.cc index 5f7f1a7..fdea1da 100644 --- a/src/tint/ast/if_statement.cc +++ b/src/tint/ast/if_statement.cc
@@ -33,7 +33,7 @@ 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<ast::IfStatement, ast::BlockStatement>())); + TINT_ASSERT(AST, (else_statement->IsAnyOf<IfStatement, BlockStatement>())); } }
diff --git a/src/tint/ast/location_attribute.cc b/src/tint/ast/location_attribute.cc index 4f34144..b9b3f12 100644 --- a/src/tint/ast/location_attribute.cc +++ b/src/tint/ast/location_attribute.cc
@@ -25,7 +25,7 @@ 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 43d5edf..a41e943 100644 --- a/src/tint/ast/location_attribute.h +++ b/src/tint/ast/location_attribute.h
@@ -30,7 +30,7 @@ /// @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 @@ 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 cbebab4..32dafe8 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, - utils::VectorRef<const ast::Node*> global_decls) + utils::VectorRef<const Node*> 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() = 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::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 @@ [&](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 @@ 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 a19f2bd..948f894 100644 --- a/src/tint/ast/module.h +++ b/src/tint/ast/module.h
@@ -46,7 +46,7 @@ Module(ProgramID pid, NodeID nid, const Source& src, - utils::VectorRef<const ast::Node*> global_decls); + utils::VectorRef<const Node*> global_decls); /// Destructor ~Module() override; @@ -80,7 +80,7 @@ auto& GlobalVariables() { return global_variables_; } /// @returns the global variable declarations of kind 'T' for the module - template <typename T, typename = traits::EnableIfIsType<T, ast::Variable>> + template <typename T, typename = traits::EnableIfIsType<T, Variable>> auto Globals() const { utils::Vector<const T*, 32> 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 8657980..eb7f775 100644 --- a/src/tint/ast/module_clone_test.cc +++ b/src/tint/ast/module_clone_test.cc
@@ -135,7 +135,7 @@ 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<const ast::Node*> src_nodes; + std::unordered_set<const Node*> 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 35c1b94..c0255ff 100644 --- a/src/tint/ast/module_test.cc +++ b/src/tint/ast/module_test.cc
@@ -61,9 +61,8 @@ { ProgramBuilder b1; ProgramBuilder b2; - b1.AST().AddFunction(b2.create<ast::Function>(b2.Ident("func"), utils::Empty, - b2.ty.f32(), b2.Block(), utils::Empty, - utils::Empty)); + b1.AST().AddFunction(b2.create<Function>(b2.Ident("func"), utils::Empty, b2.ty.f32(), + b2.Block(), utils::Empty, utils::Empty)); }, "internal compiler error"); } @@ -102,7 +101,7 @@ // 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 @@ 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 @@ auto& decls = cloned.AST().GlobalDeclarations(); ASSERT_EQ(decls.Length(), 6u); - EXPECT_TRUE(decls[1]->Is<ast::Function>()); + EXPECT_TRUE(decls[1]->Is<Function>()); EXPECT_TRUE(decls[3]->Is<ast::Alias>()); - EXPECT_TRUE(decls[5]->Is<ast::Variable>()); + EXPECT_TRUE(decls[5]->Is<Variable>()); ASSERT_TRUE(decls[0]->Is<ast::Alias>()); ASSERT_TRUE(decls[2]->Is<ast::Alias>());
diff --git a/src/tint/ast/struct.cc b/src/tint/ast/struct.cc index 2757c4e..96daeff 100644 --- a/src/tint/ast/struct.cc +++ b/src/tint/ast/struct.cc
@@ -26,8 +26,8 @@ NodeID nid, const Source& src, const Identifier* n, - utils::VectorRef<const ast::StructMember*> m, - utils::VectorRef<const ast::Attribute*> attrs) + utils::VectorRef<const StructMember*> m, + utils::VectorRef<const Attribute*> 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 9668db1..36ad080 100644 --- a/src/tint/ast/struct.h +++ b/src/tint/ast/struct.h
@@ -39,8 +39,8 @@ NodeID nid, const Source& src, const Identifier* name, - utils::VectorRef<const ast::StructMember*> members, - utils::VectorRef<const ast::Attribute*> attributes); + utils::VectorRef<const StructMember*> members, + utils::VectorRef<const Attribute*> attributes); /// Move constructor Struct(Struct&&); @@ -53,10 +53,10 @@ const Struct* Clone(CloneContext* ctx) const override; /// The members - const utils::Vector<const ast::StructMember*, 8> members; + const utils::Vector<const StructMember*, 8> members; /// The struct attributes - const utils::Vector<const ast::Attribute*, 4> attributes; + const utils::Vector<const Attribute*, 4> 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 2a21362..a7d69da 100644 --- a/src/tint/ast/struct_member_align_attribute.cc +++ b/src/tint/ast/struct_member_align_attribute.cc
@@ -26,7 +26,7 @@ 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 6da1894..1649ae6 100644 --- a/src/tint/ast/struct_member_align_attribute.h +++ b/src/tint/ast/struct_member_align_attribute.h
@@ -34,7 +34,7 @@ StructMemberAlignAttribute(ProgramID pid, NodeID nid, const Source& src, - const ast::Expression* align); + const Expression* align); ~StructMemberAlignAttribute() override; /// @returns the WGSL name for the attribute @@ -47,7 +47,7 @@ const StructMemberAlignAttribute* Clone(CloneContext* ctx) const override; /// The align expression - const ast::Expression* const expr; + const Expression* const expr; }; } // namespace tint::ast
diff --git a/src/tint/ast/struct_member_offset_attribute.cc b/src/tint/ast/struct_member_offset_attribute.cc index 8b9faab..ee6f458 100644 --- a/src/tint/ast/struct_member_offset_attribute.cc +++ b/src/tint/ast/struct_member_offset_attribute.cc
@@ -25,7 +25,7 @@ StructMemberOffsetAttribute::StructMemberOffsetAttribute(ProgramID pid, NodeID nid, const Source& src, - const ast::Expression* exp) + const Expression* exp) : Base(pid, nid, src), expr(exp) {} StructMemberOffsetAttribute::~StructMemberOffsetAttribute() = default;
diff --git a/src/tint/ast/struct_member_offset_attribute.h b/src/tint/ast/struct_member_offset_attribute.h index 632d71a..ed74397 100644 --- a/src/tint/ast/struct_member_offset_attribute.h +++ b/src/tint/ast/struct_member_offset_attribute.h
@@ -42,7 +42,7 @@ StructMemberOffsetAttribute(ProgramID pid, NodeID nid, const Source& src, - const ast::Expression* expr); + const Expression* expr); ~StructMemberOffsetAttribute() override; /// @returns the WGSL name for the attribute @@ -55,7 +55,7 @@ const StructMemberOffsetAttribute* Clone(CloneContext* ctx) const override; /// The offset expression - const ast::Expression* const expr; + const Expression* const expr; }; } // namespace tint::ast
diff --git a/src/tint/ast/struct_member_offset_attribute_test.cc b/src/tint/ast/struct_member_offset_attribute_test.cc index 23dd697..6a7e4c9 100644 --- a/src/tint/ast/struct_member_offset_attribute_test.cc +++ b/src/tint/ast/struct_member_offset_attribute_test.cc
@@ -22,8 +22,8 @@ TEST_F(StructMemberOffsetAttributeTest, Creation) { auto* d = MemberOffset(2_u); - ASSERT_TRUE(d->expr->Is<ast::IntLiteralExpression>()); - EXPECT_EQ(2u, d->expr->As<ast::IntLiteralExpression>()->value); + ASSERT_TRUE(d->expr->Is<IntLiteralExpression>()); + EXPECT_EQ(2u, d->expr->As<IntLiteralExpression>()->value); } } // namespace
diff --git a/src/tint/ast/struct_member_size_attribute.cc b/src/tint/ast/struct_member_size_attribute.cc index 833896d..8d08ca8 100644 --- a/src/tint/ast/struct_member_size_attribute.cc +++ b/src/tint/ast/struct_member_size_attribute.cc
@@ -26,7 +26,7 @@ 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 c048b1f..2a0c71f 100644 --- a/src/tint/ast/struct_member_size_attribute.h +++ b/src/tint/ast/struct_member_size_attribute.h
@@ -31,10 +31,7 @@ /// @param nid the unique node identifier /// @param src the source of this node /// @param expr the size expression - StructMemberSizeAttribute(ProgramID pid, - NodeID nid, - const Source& src, - const ast::Expression* expr); + StructMemberSizeAttribute(ProgramID pid, NodeID nid, const Source& src, const Expression* expr); ~StructMemberSizeAttribute() override; /// @returns the WGSL name for the attribute @@ -47,7 +44,7 @@ const StructMemberSizeAttribute* Clone(CloneContext* ctx) const override; /// The size expression - const ast::Expression* const expr; + const Expression* const expr; }; } // namespace tint::ast
diff --git a/src/tint/ast/struct_member_size_attribute_test.cc b/src/tint/ast/struct_member_size_attribute_test.cc index 9f6b49b..17e4ae6 100644 --- a/src/tint/ast/struct_member_size_attribute_test.cc +++ b/src/tint/ast/struct_member_size_attribute_test.cc
@@ -24,8 +24,8 @@ TEST_F(StructMemberSizeAttributeTest, Creation) { auto* d = MemberSize(2_u); - ASSERT_TRUE(d->expr->Is<ast::IntLiteralExpression>()); - EXPECT_EQ(2u, d->expr->As<ast::IntLiteralExpression>()->value); + ASSERT_TRUE(d->expr->Is<IntLiteralExpression>()); + EXPECT_EQ(2u, d->expr->As<IntLiteralExpression>()->value); } } // namespace
diff --git a/src/tint/ast/struct_member_test.cc b/src/tint/ast/struct_member_test.cc index 94a072f..59eb30f 100644 --- a/src/tint/ast/struct_member_test.cc +++ b/src/tint/ast/struct_member_test.cc
@@ -23,8 +23,8 @@ 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<StructMemberSizeAttribute>()); EXPECT_EQ(st->source.range.begin.line, 0u); @@ -36,8 +36,8 @@ 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 @@ 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 cfb4181..1d14716 100644 --- a/src/tint/ast/struct_test.cc +++ b/src/tint/ast/struct_test.cc
@@ -83,7 +83,7 @@ { ProgramBuilder b; b.Structure(b.Sym("S"), utils::Vector{b.Member("a", b.ty.i32())}, - utils::Vector<const ast::Attribute*, 1>{nullptr}); + utils::Vector<const Attribute*, 1>{nullptr}); }, "internal compiler error"); }
diff --git a/src/tint/ast/switch_statement_test.cc b/src/tint/ast/switch_statement_test.cc index 00c515e..e6101c8 100644 --- a/src/tint/ast/switch_statement_test.cc +++ b/src/tint/ast/switch_statement_test.cc
@@ -53,7 +53,7 @@ } TEST_F(SwitchStatementTest, Assert_Null_Condition) { - using CaseStatementList = utils::Vector<const ast::CaseStatement*, 2>; + using CaseStatementList = utils::Vector<const CaseStatement*, 2>; EXPECT_FATAL_FAILURE( { ProgramBuilder b; @@ -66,7 +66,7 @@ } TEST_F(SwitchStatementTest, Assert_Null_CaseStatement) { - using CaseStatementList = utils::Vector<const ast::CaseStatement*, 2>; + using CaseStatementList = utils::Vector<const CaseStatement*, 2>; EXPECT_FATAL_FAILURE( { ProgramBuilder b;
diff --git a/src/tint/ast/traverse_expressions.h b/src/tint/ast/traverse_expressions.h index 629e010..fb8aad1 100644 --- a/src/tint/ast/traverse_expressions.h +++ b/src/tint/ast/traverse_expressions.h
@@ -57,24 +57,22 @@ /// @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 <TraverseOrder ORDER = TraverseOrder::LeftToRight, typename CALLBACK> -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<traits::ParameterType<CALLBACK, 0>>; constexpr static bool kHasDepthArg = traits::SignatureOfT<CALLBACK>::parameter_count == 2; struct Pending { - const ast::Expression* expr; + const Expression* expr; size_t depth; }; utils::Vector<Pending, 32> 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 @@ to_visit.Push({right, depth}); } }; - auto push_list = [&](utils::VectorRef<const ast::Expression*> exprs, size_t depth) { + auto push_list = [&](utils::VectorRef<const Expression*> exprs, size_t depth) { if (ORDER == TraverseOrder::LeftToRight) { for (auto* expr : utils::Reverse(exprs)) { to_visit.Push({expr, depth}); @@ -97,7 +95,7 @@ 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<EXPR_TYPE>()) { TraverseAction result;
diff --git a/src/tint/ast/traverse_expressions_test.cc b/src/tint/ast/traverse_expressions_test.cc index f0226aa..0db73c2 100644 --- a/src/tint/ast/traverse_expressions_test.cc +++ b/src/tint/ast/traverse_expressions_test.cc
@@ -26,66 +26,66 @@ using TraverseExpressionsTest = TestHelper; TEST_F(TraverseExpressionsTest, DescendIndexAccessor) { - std::vector<const ast::Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; - std::vector<const ast::Expression*> i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])}; + std::vector<const Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; + std::vector<const Expression*> i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])}; auto* root = IndexAccessor(i[0], i[1]); { - std::vector<const ast::Expression*> l2r; + std::vector<const Expression*> l2r; TraverseExpressions<TraverseOrder::LeftToRight>(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<const ast::Expression*> r2l; + std::vector<const Expression*> r2l; TraverseExpressions<TraverseOrder::RightToLeft>(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<const ast::Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; - std::vector<const ast::Expression*> i = {Add(e[0], e[1]), Sub(e[2], e[3])}; + std::vector<const Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; + std::vector<const Expression*> i = {Add(e[0], e[1]), Sub(e[2], e[3])}; auto* root = Mul(i[0], i[1]); { - std::vector<const ast::Expression*> l2r; + std::vector<const Expression*> l2r; TraverseExpressions<TraverseOrder::LeftToRight>(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<const ast::Expression*> r2l; + std::vector<const Expression*> r2l; TraverseExpressions<TraverseOrder::RightToLeft>(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<const ast::Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; - std::vector<const ast::Expression*> i = {Add(e[0], e[1]), Sub(e[2], e[3])}; + std::vector<const Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; + std::vector<const Expression*> 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<TraverseOrder::LeftToRight>( // - 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 @@ auto* b2 = Bitcast<i32>(b1); auto* root = Bitcast<i32>(b2); { - utils::Vector<const ast::Expression*, 8> l2r; + utils::Vector<const Expression*, 8> l2r; TraverseExpressions<TraverseOrder::LeftToRight>(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<const ast::Expression*, 8> r2l; + utils::Vector<const Expression*, 8> r2l; TraverseExpressions<TraverseOrder::RightToLeft>(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 @@ 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<const ast::Expression*, 8> l2r; + utils::Vector<const Expression*, 8> l2r; TraverseExpressions<TraverseOrder::LeftToRight>(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<const ast::Expression*, 8> r2l; + utils::Vector<const Expression*, 8> r2l; TraverseExpressions<TraverseOrder::RightToLeft>(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 @@ auto* m = MemberAccessor(e, "a"); auto* root = MemberAccessor(m, "b"); { - std::vector<const ast::Expression*> l2r; + std::vector<const Expression*> l2r; TraverseExpressions<TraverseOrder::LeftToRight>(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<const ast::Expression*> r2l; + std::vector<const Expression*> r2l; TraverseExpressions<TraverseOrder::RightToLeft>(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 @@ auto* f = IndexAccessor(d, e); auto* root = IndexAccessor(c, f); { - std::vector<const ast::Expression*> l2r; + std::vector<const Expression*> l2r; TraverseExpressions<TraverseOrder::LeftToRight>(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<const ast::Expression*> r2l; + std::vector<const Expression*> r2l; TraverseExpressions<TraverseOrder::RightToLeft>(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 @@ auto* u2 = AddressOf(u1); auto* root = Deref(u2); { - std::vector<const ast::Expression*> l2r; + std::vector<const Expression*> l2r; TraverseExpressions<TraverseOrder::LeftToRight>(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<const ast::Expression*> r2l; + std::vector<const Expression*> r2l; TraverseExpressions<TraverseOrder::RightToLeft>(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<const ast::Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; - std::vector<const ast::Expression*> i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])}; + std::vector<const Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; + std::vector<const Expression*> i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])}; auto* root = IndexAccessor(i[0], i[1]); - std::vector<const ast::Expression*> order; + std::vector<const Expression*> order; TraverseExpressions<TraverseOrder::LeftToRight>( - 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<const ast::Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; - std::vector<const ast::Expression*> i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])}; + std::vector<const Expression*> e = {Expr(1_i), Expr(1_i), Expr(1_i), Expr(1_i)}; + std::vector<const Expression*> i = {IndexAccessor(e[0], e[1]), IndexAccessor(e[2], e[3])}; auto* root = IndexAccessor(i[0], i[1]); - std::vector<const ast::Expression*> order; + std::vector<const Expression*> order; TraverseExpressions<TraverseOrder::LeftToRight>( - 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 f8a17a3..70e5116 100644 --- a/src/tint/ast/variable.h +++ b/src/tint/ast/variable.h
@@ -66,8 +66,8 @@ /// @returns true if the variable has both group and binding attributes bool HasBindingPoint() const { - return ast::GetAttribute<ast::BindingAttribute>(attributes) != nullptr && - ast::GetAttribute<ast::GroupAttribute>(attributes) != nullptr; + return HasAttribute<BindingAttribute>(attributes) && + HasAttribute<GroupAttribute>(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 0b46026..6fbc420 100644 --- a/src/tint/ast/variable_test.cc +++ b/src/tint/ast/variable_test.cc
@@ -98,14 +98,14 @@ Builtin(builtin::BuiltinValue::kPosition), Id(1200_u)); auto& attributes = var->attributes; - EXPECT_TRUE(ast::HasAttribute<ast::LocationAttribute>(attributes)); - EXPECT_TRUE(ast::HasAttribute<ast::BuiltinAttribute>(attributes)); - EXPECT_TRUE(ast::HasAttribute<ast::IdAttribute>(attributes)); + EXPECT_TRUE(ast::HasAttribute<LocationAttribute>(attributes)); + EXPECT_TRUE(ast::HasAttribute<BuiltinAttribute>(attributes)); + EXPECT_TRUE(ast::HasAttribute<IdAttribute>(attributes)); - auto* location = ast::GetAttribute<ast::LocationAttribute>(attributes); + auto* location = GetAttribute<LocationAttribute>(attributes); ASSERT_NE(nullptr, location); ASSERT_NE(nullptr, location->expr); - EXPECT_TRUE(location->expr->Is<ast::IntLiteralExpression>()); + EXPECT_TRUE(location->expr->Is<IntLiteralExpression>()); } TEST_F(VariableTest, HasBindingPoint_BothProvided) {
diff --git a/src/tint/ast/workgroup_attribute.cc b/src/tint/ast/workgroup_attribute.cc index 7cb67dc..3167f59 100644 --- a/src/tint/ast/workgroup_attribute.cc +++ b/src/tint/ast/workgroup_attribute.cc
@@ -25,9 +25,9 @@ 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 e27e77e..05cbb89 100644 --- a/src/tint/ast/workgroup_attribute.h +++ b/src/tint/ast/workgroup_attribute.h
@@ -40,14 +40,14 @@ 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<const ast::Expression*, 3> Values() const { return {x, y, z}; } + std::array<const Expression*, 3> Values() const { return {x, y, z}; } /// @returns the WGSL name for the attribute std::string Name() const override; @@ -59,11 +59,11 @@ 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 97a034b..3363e52 100644 --- a/src/tint/ast/workgroup_attribute_test.cc +++ b/src/tint/ast/workgroup_attribute_test.cc
@@ -28,8 +28,8 @@ auto* d = WorkgroupSize(2_i); auto values = d->Values(); - ASSERT_TRUE(values[0]->Is<ast::IntLiteralExpression>()); - EXPECT_EQ(values[0]->As<ast::IntLiteralExpression>()->value, 2); + ASSERT_TRUE(values[0]->Is<IntLiteralExpression>()); + EXPECT_EQ(values[0]->As<IntLiteralExpression>()->value, 2); EXPECT_EQ(values[1], nullptr); EXPECT_EQ(values[2], nullptr); @@ -38,11 +38,11 @@ auto* d = WorkgroupSize(2_i, 4_i); auto values = d->Values(); - ASSERT_TRUE(values[0]->Is<ast::IntLiteralExpression>()); - EXPECT_EQ(values[0]->As<ast::IntLiteralExpression>()->value, 2); + ASSERT_TRUE(values[0]->Is<IntLiteralExpression>()); + EXPECT_EQ(values[0]->As<IntLiteralExpression>()->value, 2); - ASSERT_TRUE(values[1]->Is<ast::IntLiteralExpression>()); - EXPECT_EQ(values[1]->As<ast::IntLiteralExpression>()->value, 4); + ASSERT_TRUE(values[1]->Is<IntLiteralExpression>()); + EXPECT_EQ(values[1]->As<IntLiteralExpression>()->value, 4); EXPECT_EQ(values[2], nullptr); } @@ -51,27 +51,27 @@ auto* d = WorkgroupSize(2_i, 4_i, 6_i); auto values = d->Values(); - ASSERT_TRUE(values[0]->Is<ast::IntLiteralExpression>()); - EXPECT_EQ(values[0]->As<ast::IntLiteralExpression>()->value, 2); + ASSERT_TRUE(values[0]->Is<IntLiteralExpression>()); + EXPECT_EQ(values[0]->As<IntLiteralExpression>()->value, 2); - ASSERT_TRUE(values[1]->Is<ast::IntLiteralExpression>()); - EXPECT_EQ(values[1]->As<ast::IntLiteralExpression>()->value, 4); + ASSERT_TRUE(values[1]->Is<IntLiteralExpression>()); + EXPECT_EQ(values[1]->As<IntLiteralExpression>()->value, 4); - ASSERT_TRUE(values[2]->Is<ast::IntLiteralExpression>()); - EXPECT_EQ(values[2]->As<ast::IntLiteralExpression>()->value, 6); + ASSERT_TRUE(values[2]->Is<IntLiteralExpression>()); + EXPECT_EQ(values[2]->As<IntLiteralExpression>()->value, 6); } TEST_F(WorkgroupAttributeTest, Creation_WithIdentifier) { auto* d = WorkgroupSize(2_i, 4_i, "depth"); auto values = d->Values(); - ASSERT_TRUE(values[0]->Is<ast::IntLiteralExpression>()); - EXPECT_EQ(values[0]->As<ast::IntLiteralExpression>()->value, 2); + ASSERT_TRUE(values[0]->Is<IntLiteralExpression>()); + EXPECT_EQ(values[0]->As<IntLiteralExpression>()->value, 2); - ASSERT_TRUE(values[1]->Is<ast::IntLiteralExpression>()); - EXPECT_EQ(values[1]->As<ast::IntLiteralExpression>()->value, 4); + ASSERT_TRUE(values[1]->Is<IntLiteralExpression>()); + EXPECT_EQ(values[1]->As<IntLiteralExpression>()->value, 4); - auto* z_ident = As<ast::IdentifierExpression>(values[2]); + auto* z_ident = As<IdentifierExpression>(values[2]); ASSERT_TRUE(z_ident); EXPECT_EQ(Symbols().NameFor(z_ident->identifier->symbol), "depth"); }