diff --git a/src/ast/binding_decoration_test.cc b/src/ast/binding_decoration_test.cc index 411165392e..54e6f7494b 100644 --- a/src/ast/binding_decoration_test.cc +++ b/src/ast/binding_decoration_test.cc @@ -35,7 +35,7 @@ TEST_F(BindingDecorationTest, Is) { EXPECT_FALSE(d->Is()); EXPECT_FALSE(d->Is()); EXPECT_FALSE(d->Is()); - EXPECT_FALSE(bd.IsSet()); + EXPECT_FALSE(d->Is()); } TEST_F(BindingDecorationTest, ToStr) { diff --git a/src/ast/builtin_decoration_test.cc b/src/ast/builtin_decoration_test.cc index 11e1b2d76a..3122651ff9 100644 --- a/src/ast/builtin_decoration_test.cc +++ b/src/ast/builtin_decoration_test.cc @@ -35,7 +35,7 @@ TEST_F(BuiltinDecorationTest, Is) { EXPECT_TRUE(d->Is()); EXPECT_FALSE(d->Is()); EXPECT_FALSE(d->Is()); - EXPECT_FALSE(bd.IsSet()); + EXPECT_FALSE(d->Is()); } TEST_F(BuiltinDecorationTest, ToStr) { diff --git a/src/ast/constant_id_decoration_test.cc b/src/ast/constant_id_decoration_test.cc index ece2385932..28f77ee8cf 100644 --- a/src/ast/constant_id_decoration_test.cc +++ b/src/ast/constant_id_decoration_test.cc @@ -34,7 +34,7 @@ TEST_F(ConstantIdDecorationTest, Is) { EXPECT_FALSE(d->Is()); EXPECT_TRUE(d->Is()); EXPECT_FALSE(d->Is()); - EXPECT_FALSE(cd.IsSet()); + EXPECT_FALSE(d->Is()); } TEST_F(ConstantIdDecorationTest, ToStr) { diff --git a/src/ast/location_decoration_test.cc b/src/ast/location_decoration_test.cc index f8ffff866c..f402abe1fb 100644 --- a/src/ast/location_decoration_test.cc +++ b/src/ast/location_decoration_test.cc @@ -37,7 +37,7 @@ TEST_F(LocationDecorationTest, Is) { EXPECT_FALSE(d->Is()); EXPECT_FALSE(d->Is()); EXPECT_TRUE(d->Is()); - EXPECT_FALSE(ld.IsSet()); + EXPECT_FALSE(d->Is()); } TEST_F(LocationDecorationTest, ToStr) { diff --git a/src/ast/set_decoration.cc b/src/ast/set_decoration.cc index 4178e4d270..4d6a776a51 100644 --- a/src/ast/set_decoration.cc +++ b/src/ast/set_decoration.cc @@ -22,10 +22,6 @@ SetDecoration::SetDecoration(uint32_t val, const Source& source) SetDecoration::~SetDecoration() = default; -bool SetDecoration::IsSet() const { - return true; -} - void SetDecoration::to_str(std::ostream& out, size_t indent) const { make_indent(out, indent); out << "SetDecoration{" << value_ << "}" << std::endl; diff --git a/src/ast/set_decoration.h b/src/ast/set_decoration.h index 73469c43ab..9706f86322 100644 --- a/src/ast/set_decoration.h +++ b/src/ast/set_decoration.h @@ -31,9 +31,6 @@ class SetDecoration : public Castable { SetDecoration(uint32_t value, const Source& source); ~SetDecoration() override; - /// @returns true if this is a set decoration - bool IsSet() const override; - /// @returns the set value uint32_t value() const { return value_; } diff --git a/src/ast/set_decoration_test.cc b/src/ast/set_decoration_test.cc index d9b9e798df..088f3f078a 100644 --- a/src/ast/set_decoration_test.cc +++ b/src/ast/set_decoration_test.cc @@ -35,7 +35,7 @@ TEST_F(SetDecorationTest, Is) { EXPECT_FALSE(d->Is()); EXPECT_FALSE(d->Is()); EXPECT_FALSE(d->Is()); - EXPECT_TRUE(sd.IsSet()); + EXPECT_TRUE(d->Is()); } TEST_F(SetDecorationTest, ToStr) { diff --git a/src/ast/variable_decoration.cc b/src/ast/variable_decoration.cc index 287300ce9e..ea8d2681aa 100644 --- a/src/ast/variable_decoration.cc +++ b/src/ast/variable_decoration.cc @@ -16,8 +16,6 @@ #include -#include "src/ast/set_decoration.h" - namespace tint { namespace ast { @@ -31,14 +29,5 @@ DecorationKind VariableDecoration::GetKind() const { return Kind; } -bool VariableDecoration::IsSet() const { - return false; -} - -SetDecoration* VariableDecoration::AsSet() { - assert(IsSet()); - return static_cast(this); -} - } // namespace ast } // namespace tint diff --git a/src/ast/variable_decoration.h b/src/ast/variable_decoration.h index 39206fbca2..72e18ad8df 100644 --- a/src/ast/variable_decoration.h +++ b/src/ast/variable_decoration.h @@ -25,8 +25,6 @@ namespace tint { namespace ast { -class SetDecoration; - /// A decoration attached to a variable class VariableDecoration : public Castable { public: @@ -38,12 +36,6 @@ class VariableDecoration : public Castable { /// @return the decoration kind DecorationKind GetKind() const override; - /// @returns true if this is a set decoration - virtual bool IsSet() const; - - /// @returns the decoration as a set decoration - SetDecoration* AsSet(); - protected: /// Constructor /// @param source the source of this decoration diff --git a/src/reader/wgsl/parser_impl_global_variable_decl_test.cc b/src/reader/wgsl/parser_impl_global_variable_decl_test.cc index 8e8ddc3d2f..80a5d30ec5 100644 --- a/src/reader/wgsl/parser_impl_global_variable_decl_test.cc +++ b/src/reader/wgsl/parser_impl_global_variable_decl_test.cc @@ -105,7 +105,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration) { auto& decorations = v->decorations(); ASSERT_EQ(decorations.size(), 2u); ASSERT_TRUE(decorations[0]->Is()); - ASSERT_TRUE(decorations[1]->IsSet()); + ASSERT_TRUE(decorations[1]->Is()); } TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration_MulitpleGroups) { @@ -139,7 +139,7 @@ TEST_F(ParserImplTest, GlobalVariableDecl_WithDecoration_MulitpleGroups) { auto& decorations = v->decorations(); ASSERT_EQ(decorations.size(), 2u); ASSERT_TRUE(decorations[0]->Is()); - ASSERT_TRUE(decorations[1]->IsSet()); + ASSERT_TRUE(decorations[1]->Is()); } TEST_F(ParserImplTest, GlobalVariableDecl_InvalidDecoration) { diff --git a/src/reader/wgsl/parser_impl_variable_decoration_test.cc b/src/reader/wgsl/parser_impl_variable_decoration_test.cc index 60f1977789..d6b9ac59bd 100644 --- a/src/reader/wgsl/parser_impl_variable_decoration_test.cc +++ b/src/reader/wgsl/parser_impl_variable_decoration_test.cc @@ -240,9 +240,9 @@ TEST_F(ParserImplTest, VariableDecoration_set) { auto* var_deco = deco.value->As(); ASSERT_FALSE(p->has_error()); ASSERT_NE(var_deco, nullptr); - ASSERT_TRUE(var_deco->IsSet()); + ASSERT_TRUE(var_deco->Is()); - auto* set = var_deco->AsSet(); + auto* set = var_deco->As(); EXPECT_EQ(set->value(), 4u); } diff --git a/src/writer/spirv/builder.cc b/src/writer/spirv/builder.cc index 5b800a4e81..0c1c1d5688 100644 --- a/src/writer/spirv/builder.cc +++ b/src/writer/spirv/builder.cc @@ -792,11 +792,11 @@ bool Builder::GenerateGlobalVariable(ast::Variable* var) { push_annot(spv::Op::OpDecorate, {Operand::Int(var_id), Operand::Int(SpvDecorationBinding), Operand::Int(binding->value())}); - } else if (deco->IsSet()) { + } else if (auto* set = deco->As()) { push_annot( spv::Op::OpDecorate, {Operand::Int(var_id), Operand::Int(SpvDecorationDescriptorSet), - Operand::Int(deco->AsSet()->value())}); + Operand::Int(set->value())}); } else if (deco->Is()) { // Spec constants are handled elsewhere } else { diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc index 95a227f62f..e713aa6580 100644 --- a/src/writer/wgsl/generator_impl.cc +++ b/src/writer/wgsl/generator_impl.cc @@ -643,8 +643,8 @@ bool GeneratorImpl::EmitVariableDecorations(ast::DecoratedVariable* var) { if (auto* binding = deco->As()) { out_ << "binding(" << binding->value() << ")"; - } else if (deco->IsSet()) { - out_ << "set(" << deco->AsSet()->value() << ")"; + } else if (auto* set = deco->As()) { + out_ << "set(" << set->value() << ")"; } else if (auto* location = deco->As()) { out_ << "location(" << location->value() << ")"; } else if (auto* builtin = deco->As()) {