diff --git a/src/ast/struct.cc b/src/ast/struct.cc index 525afe41b5..5825dca1cb 100644 --- a/src/ast/struct.cc +++ b/src/ast/struct.cc @@ -14,6 +14,8 @@ #include "src/ast/struct.h" +#include "src/ast/struct_block_decoration.h" + namespace tint { namespace ast { @@ -52,7 +54,7 @@ StructMember* Struct::get_member(const std::string& name) const { bool Struct::IsBlockDecorated() const { for (auto* deco : decorations_) { - if (deco->IsBlock()) { + if (deco->Is()) { return true; } } diff --git a/src/ast/struct_block_decoration.cc b/src/ast/struct_block_decoration.cc index 33fa124519..90fb248e41 100644 --- a/src/ast/struct_block_decoration.cc +++ b/src/ast/struct_block_decoration.cc @@ -22,10 +22,6 @@ StructBlockDecoration::StructBlockDecoration(const Source& source) StructBlockDecoration::~StructBlockDecoration() = default; -bool StructBlockDecoration::IsBlock() const { - return true; -} - void StructBlockDecoration::to_str(std::ostream& out, size_t indent) const { make_indent(out, indent); out << "block"; diff --git a/src/ast/struct_block_decoration.h b/src/ast/struct_block_decoration.h index 9c062554a8..6f55984777 100644 --- a/src/ast/struct_block_decoration.h +++ b/src/ast/struct_block_decoration.h @@ -33,9 +33,6 @@ class StructBlockDecoration explicit StructBlockDecoration(const Source& source); ~StructBlockDecoration() override; - /// @returns true if this is a block struct - bool IsBlock() const override; - /// Outputs the decoration to the given stream /// @param out the stream to write to /// @param indent number of spaces to indent the node when writing diff --git a/src/ast/struct_decoration.h b/src/ast/struct_decoration.h index bba2162d2a..c8af9e712a 100644 --- a/src/ast/struct_decoration.h +++ b/src/ast/struct_decoration.h @@ -35,9 +35,6 @@ class StructDecoration : public Castable { /// @return the decoration kind DecorationKind GetKind() const override; - /// @returns true if this is a block struct - virtual bool IsBlock() const = 0; - protected: /// Constructor /// @param source the source of this decoration diff --git a/src/ast/struct_test.cc b/src/ast/struct_test.cc index 016166ec44..33f0697083 100644 --- a/src/ast/struct_test.cc +++ b/src/ast/struct_test.cc @@ -57,7 +57,7 @@ TEST_F(StructTest, Creation_WithDecorations) { Struct s{decos, members}; EXPECT_EQ(s.members().size(), 1u); ASSERT_EQ(s.decorations().size(), 1u); - EXPECT_TRUE(s.decorations()[0]->IsBlock()); + EXPECT_TRUE(s.decorations()[0]->Is()); EXPECT_EQ(s.source().range.begin.line, 0u); EXPECT_EQ(s.source().range.begin.column, 0u); EXPECT_EQ(s.source().range.end.line, 0u); @@ -79,7 +79,7 @@ TEST_F(StructTest, CreationWithSourceAndDecorations) { decos, members}; EXPECT_EQ(s.members().size(), 1u); ASSERT_EQ(s.decorations().size(), 1u); - EXPECT_TRUE(s.decorations()[0]->IsBlock()); + EXPECT_TRUE(s.decorations()[0]->Is()); EXPECT_EQ(s.source().range.begin.line, 27u); EXPECT_EQ(s.source().range.begin.column, 4u); EXPECT_EQ(s.source().range.end.line, 27u); diff --git a/src/reader/wgsl/parser_impl_struct_decl_test.cc b/src/reader/wgsl/parser_impl_struct_decl_test.cc index 87e40e59f5..e1557a78f1 100644 --- a/src/reader/wgsl/parser_impl_struct_decl_test.cc +++ b/src/reader/wgsl/parser_impl_struct_decl_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "gtest/gtest.h" +#include "src/ast/struct_block_decoration.h" #include "src/ast/type/struct_type.h" #include "src/reader/wgsl/parser_impl.h" #include "src/reader/wgsl/parser_impl_test_helper.h" @@ -65,7 +66,7 @@ TEST_F(ParserImplTest, StructDecl_ParsesWithDecoration) { EXPECT_EQ(s->impl()->members()[0]->name(), "a"); EXPECT_EQ(s->impl()->members()[1]->name(), "b"); ASSERT_EQ(s->impl()->decorations().size(), 1u); - EXPECT_TRUE(s->impl()->decorations()[0]->IsBlock()); + EXPECT_TRUE(s->impl()->decorations()[0]->Is()); } TEST_F(ParserImplTest, StructDecl_ParsesWithMultipleDecoration) { @@ -90,8 +91,8 @@ TEST_F(ParserImplTest, StructDecl_ParsesWithMultipleDecoration) { EXPECT_EQ(s->impl()->members()[0]->name(), "a"); EXPECT_EQ(s->impl()->members()[1]->name(), "b"); ASSERT_EQ(s->impl()->decorations().size(), 2u); - EXPECT_TRUE(s->impl()->decorations()[0]->IsBlock()); - EXPECT_TRUE(s->impl()->decorations()[1]->IsBlock()); + EXPECT_TRUE(s->impl()->decorations()[0]->Is()); + EXPECT_TRUE(s->impl()->decorations()[1]->Is()); } TEST_F(ParserImplTest, StructDecl_EmptyMembers) { diff --git a/src/reader/wgsl/parser_impl_struct_decoration_decl_test.cc b/src/reader/wgsl/parser_impl_struct_decoration_decl_test.cc index 3cfa9dc1e2..5ef5f82964 100644 --- a/src/reader/wgsl/parser_impl_struct_decoration_decl_test.cc +++ b/src/reader/wgsl/parser_impl_struct_decoration_decl_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "gtest/gtest.h" +#include "src/ast/struct_block_decoration.h" #include "src/reader/wgsl/parser_impl.h" #include "src/reader/wgsl/parser_impl_test_helper.h" @@ -29,7 +30,7 @@ TEST_F(ParserImplTest, StructDecorationDecl_Parses) { EXPECT_TRUE(decos.matched); ASSERT_EQ(decos.value.size(), 1u); auto* struct_deco = decos.value[0]->As(); - EXPECT_TRUE(struct_deco->IsBlock()); + EXPECT_TRUE(struct_deco->Is()); } TEST_F(ParserImplTest, StructDecorationDecl_MissingAttrRight) { diff --git a/src/reader/wgsl/parser_impl_struct_decoration_test.cc b/src/reader/wgsl/parser_impl_struct_decoration_test.cc index 181045115c..e6e2cf63e7 100644 --- a/src/reader/wgsl/parser_impl_struct_decoration_test.cc +++ b/src/reader/wgsl/parser_impl_struct_decoration_test.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "gtest/gtest.h" +#include "src/ast/struct_block_decoration.h" #include "src/ast/struct_decoration.h" #include "src/reader/wgsl/parser_impl.h" #include "src/reader/wgsl/parser_impl_test_helper.h" @@ -45,7 +46,7 @@ TEST_P(StructDecorationTest, Parses) { ASSERT_NE(deco.value, nullptr); auto* struct_deco = deco.value->As(); ASSERT_NE(struct_deco, nullptr); - EXPECT_EQ(struct_deco->IsBlock(), params.is_block); + EXPECT_EQ(struct_deco->Is(), params.is_block); } INSTANTIATE_TEST_SUITE_P(ParserImplTest, StructDecorationTest,