diff --git a/src/validator/validator_impl.cc b/src/validator/validator_impl.cc index b817892b75..6b109219e6 100644 --- a/src/validator/validator_impl.cc +++ b/src/validator/validator_impl.cc @@ -269,29 +269,4 @@ bool ValidatorImpl::ValidateCase(const ast::CaseStatement* c) { return true; } -bool ValidatorImpl::IsStorable(type::Type* type) { - if (type == nullptr) { - return false; - } - if (type->is_scalar() || type->Is() || - type->Is()) { - return true; - } - if (type::Array* array_type = type->As()) { - return IsStorable(array_type->type()); - } - if (type::Struct* struct_type = type->As()) { - for (const auto* member : struct_type->impl()->members()) { - if (!IsStorable(member->type())) { - return false; - } - } - return true; - } - if (type::Alias* alias_type = type->As()) { - return IsStorable(alias_type->type()); - } - return false; -} - } // namespace tint diff --git a/src/validator/validator_impl.h b/src/validator/validator_impl.h index e84de4e1bd..45d92d8e85 100644 --- a/src/validator/validator_impl.h +++ b/src/validator/validator_impl.h @@ -101,11 +101,6 @@ class ValidatorImpl { /// @param funcs the functions to check /// @returns true if the valdiation was successful bool ValidateEntryPoint(const ast::FunctionList& funcs); - /// Returns true if the given type is storable. This uses and - /// updates `storable_` and `not_storable_`. - /// @param type the given type - /// @returns true if the given type is storable. - bool IsStorable(type::Type* type); /// Testing method to inserting a given variable into the current scope. /// @param var the variable to register diff --git a/src/validator/validator_test.cc b/src/validator/validator_test.cc index 1e3b5c76b6..c79eff1d75 100644 --- a/src/validator/validator_test.cc +++ b/src/validator/validator_test.cc @@ -327,125 +327,5 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) { EXPECT_TRUE(v.ValidateStatements(body)) << v.error(); } -TEST_F(ValidatorTest, IsStorable_Void) { - auto* void_ty = ty.void_(); - - ValidatorImpl& v = Build(); - - EXPECT_FALSE(v.IsStorable(void_ty)); -} - -TEST_F(ValidatorTest, IsStorable_Scalar) { - auto* bool_ = ty.bool_(); - auto* i32 = ty.i32(); - auto* u32 = ty.u32(); - auto* f32 = ty.f32(); - - ValidatorImpl& v = Build(); - - EXPECT_TRUE(v.IsStorable(bool_)); - EXPECT_TRUE(v.IsStorable(i32)); - EXPECT_TRUE(v.IsStorable(u32)); - EXPECT_TRUE(v.IsStorable(f32)); -} - -TEST_F(ValidatorTest, IsStorable_Vector) { - auto* vec2_i32 = ty.vec2(); - auto* vec3_i32 = ty.vec3(); - auto* vec4_i32 = ty.vec4(); - auto* vec2_u32 = ty.vec2(); - auto* vec3_u32 = ty.vec3(); - auto* vec4_u32 = ty.vec4(); - auto* vec2_f32 = ty.vec2(); - auto* vec3_f32 = ty.vec3(); - auto* vec4_f32 = ty.vec4(); - - ValidatorImpl& v = Build(); - - EXPECT_TRUE(v.IsStorable(vec2_i32)); - EXPECT_TRUE(v.IsStorable(vec3_i32)); - EXPECT_TRUE(v.IsStorable(vec4_i32)); - EXPECT_TRUE(v.IsStorable(vec2_u32)); - EXPECT_TRUE(v.IsStorable(vec3_u32)); - EXPECT_TRUE(v.IsStorable(vec4_u32)); - EXPECT_TRUE(v.IsStorable(vec2_f32)); - EXPECT_TRUE(v.IsStorable(vec3_f32)); - EXPECT_TRUE(v.IsStorable(vec4_f32)); -} - -TEST_F(ValidatorTest, IsStorable_Matrix) { - auto* mat2x2 = ty.mat2x2(); - auto* mat2x3 = ty.mat2x3(); - auto* mat2x4 = ty.mat2x4(); - auto* mat3x2 = ty.mat3x2(); - auto* mat3x3 = ty.mat3x3(); - auto* mat3x4 = ty.mat3x4(); - auto* mat4x2 = ty.mat4x2(); - auto* mat4x3 = ty.mat4x3(); - auto* mat4x4 = ty.mat4x4(); - - ValidatorImpl& v = Build(); - - EXPECT_TRUE(v.IsStorable(mat2x2)); - EXPECT_TRUE(v.IsStorable(mat2x3)); - EXPECT_TRUE(v.IsStorable(mat2x4)); - EXPECT_TRUE(v.IsStorable(mat3x2)); - EXPECT_TRUE(v.IsStorable(mat3x3)); - EXPECT_TRUE(v.IsStorable(mat3x4)); - EXPECT_TRUE(v.IsStorable(mat4x2)); - EXPECT_TRUE(v.IsStorable(mat4x3)); - EXPECT_TRUE(v.IsStorable(mat4x4)); -} - -TEST_F(ValidatorTest, IsStorable_Pointer) { - auto* ptr_ty = ty.pointer(ast::StorageClass::kPrivate); - - ValidatorImpl& v = Build(); - - EXPECT_FALSE(v.IsStorable(ptr_ty)); -} - -TEST_F(ValidatorTest, IsStorable_AliasVoid) { - auto* alias = ty.alias("myalias", ty.void_()); - - ValidatorImpl& v = Build(); - - EXPECT_FALSE(v.IsStorable(alias)); -} - -TEST_F(ValidatorTest, IsStorable_AliasI32) { - auto* alias = ty.alias("myalias", ty.i32()); - - ValidatorImpl& v = Build(); - - EXPECT_TRUE(v.IsStorable(alias)); -} - -TEST_F(ValidatorTest, IsStorable_ArraySizedOfStorable) { - auto* arr = ty.array(ty.i32(), 5); - - ValidatorImpl& v = Build(); - - EXPECT_TRUE(v.IsStorable(arr)); -} - -TEST_F(ValidatorTest, IsStorable_ArrayUnsizedOfStorable) { - auto* arr = ty.array(); - - ValidatorImpl& v = Build(); - - EXPECT_TRUE(v.IsStorable(arr)); -} - -TEST_F(ValidatorTest, IsStorable_Struct_AllMembersStorable) { - ast::StructMemberList members{Member("a", ty.i32()), Member("b", ty.f32())}; - auto* s = create(Source{}, members, ast::DecorationList{}); - auto* s_ty = ty.struct_("mystruct", s); - - ValidatorImpl& v = Build(); - - EXPECT_TRUE(v.IsStorable(s_ty)); -} - } // namespace } // namespace tint