Program: Remove deprecated constructed-type methods
Fixup all usages
Bug: tint:390
Change-Id: I739a7625cd385cb889369ab7c766462fbcd7cf12
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38546
Reviewed-by: dan sinclair <dsinclair@chromium.org>
diff --git a/src/program.h b/src/program.h
index 691bc0c..a77de88 100644
--- a/src/program.h
+++ b/src/program.h
@@ -118,18 +118,6 @@
return types_.Get<T>(std::forward<ARGS>(args)...);
}
- /// Adds a constructed type to the program.
- /// The type must be an alias or a struct.
- /// [DEPRECATED]: Use AST().AddConstructedType(type)
- /// @param type the constructed type to add
- void AddConstructedType(type::Type* type) { AST().AddConstructedType(type); }
-
- /// @returns the constructed types in the program
- /// [DEPRECATED]: Use AST().ConstructedTypes()
- const std::vector<type::Type*>& constructed_types() const {
- return AST().ConstructedTypes();
- }
-
/// @returns the functions declared in the translation unit
/// [DEPRECATED]: Use AST().Functions()
const ast::FunctionList& Functions() const { return AST().Functions(); }
diff --git a/src/program_test.cc b/src/program_test.cc
index 477d852..dd97ca9 100644
--- a/src/program_test.cc
+++ b/src/program_test.cc
@@ -63,26 +63,26 @@
TEST_F(ProgramTest, IsValid_Alias) {
auto* alias = ty.alias("alias", ty.f32);
- mod->AddConstructedType(alias);
+ mod->AST().AddConstructedType(alias);
EXPECT_TRUE(mod->IsValid());
}
TEST_F(ProgramTest, IsValid_Null_Alias) {
- mod->AddConstructedType(nullptr);
+ mod->AST().AddConstructedType(nullptr);
EXPECT_FALSE(mod->IsValid());
}
TEST_F(ProgramTest, IsValid_Struct) {
auto* st = ty.struct_("name", {});
auto* alias = ty.alias("name", st);
- mod->AddConstructedType(alias);
+ mod->AST().AddConstructedType(alias);
EXPECT_TRUE(mod->IsValid());
}
TEST_F(ProgramTest, IsValid_Struct_EmptyName) {
auto* st = ty.struct_("", {});
auto* alias = ty.alias("name", st);
- mod->AddConstructedType(alias);
+ mod->AST().AddConstructedType(alias);
EXPECT_FALSE(mod->IsValid());
}
diff --git a/src/reader/spirv/parser_impl.cc b/src/reader/spirv/parser_impl.cc
index 0ade652..e49152c 100644
--- a/src/reader/spirv/parser_impl.cc
+++ b/src/reader/spirv/parser_impl.cc
@@ -969,7 +969,7 @@
if (num_non_writable_members == members.size()) {
read_only_struct_types_.insert(result);
}
- program_.AddConstructedType(result);
+ program_.AST().AddConstructedType(result);
return result;
}
@@ -1133,7 +1133,7 @@
program_.RegisterSymbol(name), ast_underlying_type);
// Record this new alias as the AST type for this SPIR-V ID.
id_to_type_[type_id] = ast_alias_type;
- program_.AddConstructedType(ast_alias_type);
+ program_.AST().AddConstructedType(ast_alias_type);
}
bool ParserImpl::EmitModuleScopeVariables() {
diff --git a/src/reader/wgsl/parser_impl.cc b/src/reader/wgsl/parser_impl.cc
index fd40f32..27c496d 100644
--- a/src/reader/wgsl/parser_impl.cc
+++ b/src/reader/wgsl/parser_impl.cc
@@ -347,7 +347,7 @@
if (!expect("type alias", Token::Type::kSemicolon))
return Failure::kErrored;
- program_.AddConstructedType(ta.value);
+ program_.AST().AddConstructedType(ta.value);
return true;
}
@@ -362,7 +362,7 @@
auto* type = str.value;
register_constructed(
program_.SymbolToName(type->As<type::Struct>()->symbol()), type);
- program_.AddConstructedType(type);
+ program_.AST().AddConstructedType(type);
return true;
}
diff --git a/src/reader/wgsl/parser_impl_global_decl_test.cc b/src/reader/wgsl/parser_impl_global_decl_test.cc
index 9a56928..c9ab075 100644
--- a/src/reader/wgsl/parser_impl_global_decl_test.cc
+++ b/src/reader/wgsl/parser_impl_global_decl_test.cc
@@ -87,11 +87,11 @@
ASSERT_FALSE(p->has_error()) << p->error();
auto& m = p->get_program();
- ASSERT_EQ(m.constructed_types().size(), 1u);
- ASSERT_TRUE(m.constructed_types()[0]->Is<type::Alias>());
- EXPECT_EQ(
- m.SymbolToName(m.constructed_types()[0]->As<type::Alias>()->symbol()),
- "A");
+ ASSERT_EQ(m.AST().ConstructedTypes().size(), 1u);
+ ASSERT_TRUE(m.AST().ConstructedTypes()[0]->Is<type::Alias>());
+ EXPECT_EQ(m.SymbolToName(
+ m.AST().ConstructedTypes()[0]->As<type::Alias>()->symbol()),
+ "A");
}
TEST_F(ParserImplTest, GlobalDecl_TypeAlias_StructIdent) {
@@ -104,13 +104,13 @@
ASSERT_FALSE(p->has_error()) << p->error();
auto& m = p->get_program();
- ASSERT_EQ(m.constructed_types().size(), 2u);
- ASSERT_TRUE(m.constructed_types()[0]->Is<type::Struct>());
- auto* str = m.constructed_types()[0]->As<type::Struct>();
+ ASSERT_EQ(m.AST().ConstructedTypes().size(), 2u);
+ ASSERT_TRUE(m.AST().ConstructedTypes()[0]->Is<type::Struct>());
+ auto* str = m.AST().ConstructedTypes()[0]->As<type::Struct>();
EXPECT_EQ(str->symbol(), p->get_program().RegisterSymbol("A"));
- ASSERT_TRUE(m.constructed_types()[1]->Is<type::Alias>());
- auto* alias = m.constructed_types()[1]->As<type::Alias>();
+ ASSERT_TRUE(m.AST().ConstructedTypes()[1]->Is<type::Alias>());
+ auto* alias = m.AST().ConstructedTypes()[1]->As<type::Alias>();
EXPECT_EQ(alias->symbol(), p->get_program().RegisterSymbol("B"));
EXPECT_EQ(alias->type(), str);
}
@@ -162,9 +162,9 @@
ASSERT_FALSE(p->has_error()) << p->error();
auto& m = p->get_program();
- ASSERT_EQ(m.constructed_types().size(), 1u);
+ ASSERT_EQ(m.AST().ConstructedTypes().size(), 1u);
- auto* t = m.constructed_types()[0];
+ auto* t = m.AST().ConstructedTypes()[0];
ASSERT_NE(t, nullptr);
ASSERT_TRUE(t->Is<type::Struct>());
@@ -181,9 +181,9 @@
ASSERT_FALSE(p->has_error()) << p->error();
auto& m = p->get_program();
- ASSERT_EQ(m.constructed_types().size(), 1u);
+ ASSERT_EQ(m.AST().ConstructedTypes().size(), 1u);
- auto* t = m.constructed_types()[0];
+ auto* t = m.AST().ConstructedTypes()[0];
ASSERT_NE(t, nullptr);
ASSERT_TRUE(t->Is<type::Struct>());
@@ -205,9 +205,9 @@
ASSERT_FALSE(p->has_error()) << p->error();
auto& m = p->get_program();
- ASSERT_EQ(m.constructed_types().size(), 1u);
+ ASSERT_EQ(m.AST().ConstructedTypes().size(), 1u);
- auto* t = m.constructed_types()[0];
+ auto* t = m.AST().ConstructedTypes()[0];
ASSERT_NE(t, nullptr);
ASSERT_TRUE(t->Is<type::Struct>());
diff --git a/src/transform/first_index_offset.cc b/src/transform/first_index_offset.cc
index ba7183f..b2d83a5 100644
--- a/src/transform/first_index_offset.cc
+++ b/src/transform/first_index_offset.cc
@@ -242,7 +242,7 @@
dst->AST().AddGlobalVariable(idx_var);
- dst->AddConstructedType(struct_type);
+ dst->AST().AddConstructedType(struct_type);
return idx_var;
}
diff --git a/src/transform/vertex_pulling.cc b/src/transform/vertex_pulling.cc
index 54a662f..32c7575 100644
--- a/src/transform/vertex_pulling.cc
+++ b/src/transform/vertex_pulling.cc
@@ -301,7 +301,7 @@
});
out->AST().AddGlobalVariable(var);
}
- out->AddConstructedType(struct_type);
+ out->AST().AddConstructedType(struct_type);
}
ast::BlockStatement* VertexPulling::State::CreateVertexPullingPreamble() const {
diff --git a/src/validator/validator_control_block_test.cc b/src/validator/validator_control_block_test.cc
index 3bfc754..34fb904 100644
--- a/src/validator/validator_control_block_test.cc
+++ b/src/validator/validator_control_block_test.cc
@@ -375,7 +375,7 @@
create<ast::VariableDeclStatement>(var),
create<ast::SwitchStatement>(Expr("a"), body),
});
- mod->AddConstructedType(my_int);
+ mod->AST().AddConstructedType(my_int);
EXPECT_TRUE(td()->DetermineStatements(block)) << td()->error();
diff --git a/src/validator/validator_impl.cc b/src/validator/validator_impl.cc
index 0168b97..83b444c 100644
--- a/src/validator/validator_impl.cc
+++ b/src/validator/validator_impl.cc
@@ -68,7 +68,7 @@
if (!ValidateGlobalVariables(program_->AST().GlobalVariables())) {
return false;
}
- if (!ValidateConstructedTypes(program_->constructed_types())) {
+ if (!ValidateConstructedTypes(program_->AST().ConstructedTypes())) {
return false;
}
if (!ValidateFunctions(program_->Functions())) {
diff --git a/src/validator/validator_type_test.cc b/src/validator/validator_type_test.cc
index 30dcad6..191c008 100644
--- a/src/validator/validator_type_test.cc
+++ b/src/validator/validator_type_test.cc
@@ -51,11 +51,11 @@
auto* struct_type = ty.struct_("Foo", st);
- mod->AddConstructedType(struct_type);
+ mod->AST().AddConstructedType(struct_type);
ValidatorImpl& v = Build();
- EXPECT_TRUE(v.ValidateConstructedTypes(mod->constructed_types()));
+ EXPECT_TRUE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes()));
}
TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) {
@@ -71,11 +71,11 @@
decos);
auto* struct_type = ty.struct_("Foo", st);
- mod->AddConstructedType(struct_type);
+ mod->AST().AddConstructedType(struct_type);
ValidatorImpl& v = Build();
- EXPECT_FALSE(v.ValidateConstructedTypes(mod->constructed_types()));
+ EXPECT_FALSE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes()));
EXPECT_EQ(v.error(),
"v-0031: a struct containing a runtime-sized array must be "
"in the 'storage' storage class: 'Foo'");
@@ -99,11 +99,11 @@
auto* struct_type = ty.struct_("Foo", st);
- mod->AddConstructedType(struct_type);
+ mod->AST().AddConstructedType(struct_type);
ValidatorImpl& v = Build();
- EXPECT_FALSE(v.ValidateConstructedTypes(mod->constructed_types()));
+ EXPECT_FALSE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes()));
EXPECT_EQ(v.error(),
"12:34 v-0015: runtime arrays may only appear as the last member "
"of a struct");
@@ -125,11 +125,11 @@
ast::StructMemberList{Member("b", alias), Member("a", ty.u32)}, decos);
auto* struct_type = ty.struct_("s", st);
- mod->AddConstructedType(struct_type);
+ mod->AST().AddConstructedType(struct_type);
ValidatorImpl& v = Build();
- EXPECT_FALSE(v.ValidateConstructedTypes(mod->constructed_types()));
+ EXPECT_FALSE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes()));
EXPECT_EQ(v.error(),
"v-0015: runtime arrays may only appear as the last member "
"of a struct");
@@ -151,11 +151,11 @@
ast::StructMemberList{Member("a", ty.u32), Member("b", alias)}, decos);
auto* struct_type = ty.struct_("s", st);
- mod->AddConstructedType(struct_type);
+ mod->AST().AddConstructedType(struct_type);
ValidatorImpl& v = Build();
- EXPECT_TRUE(v.ValidateConstructedTypes(mod->constructed_types()));
+ EXPECT_TRUE(v.ValidateConstructedTypes(mod->AST().ConstructedTypes()));
}
TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) {
diff --git a/src/writer/hlsl/generator_impl.cc b/src/writer/hlsl/generator_impl.cc
index 0330e29..533b95d 100644
--- a/src/writer/hlsl/generator_impl.cc
+++ b/src/writer/hlsl/generator_impl.cc
@@ -140,12 +140,12 @@
register_global(global);
}
- for (auto* const ty : program_->constructed_types()) {
+ for (auto* const ty : program_->AST().ConstructedTypes()) {
if (!EmitConstructedType(out, ty)) {
return false;
}
}
- if (!program_->constructed_types().empty()) {
+ if (!program_->AST().ConstructedTypes().empty()) {
out << std::endl;
}
diff --git a/src/writer/hlsl/generator_impl_function_test.cc b/src/writer/hlsl/generator_impl_function_test.cc
index d9aeacb..b2fa845 100644
--- a/src/writer/hlsl/generator_impl_function_test.cc
+++ b/src/writer/hlsl/generator_impl_function_test.cc
@@ -358,7 +358,7 @@
create<ast::GroupDecoration>(1),
});
- mod->AddConstructedType(s);
+ mod->AST().AddConstructedType(s);
td.RegisterVariableForTesting(coord_var);
mod->AST().AddGlobalVariable(coord_var);
@@ -1053,7 +1053,7 @@
create<ast::GroupDecoration>(0),
});
- mod->AddConstructedType(s);
+ mod->AST().AddConstructedType(s);
td.RegisterVariableForTesting(data_var);
mod->AST().AddGlobalVariable(data_var);
diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc
index 0114d69..b83519c 100644
--- a/src/writer/msl/generator_impl.cc
+++ b/src/writer/msl/generator_impl.cc
@@ -119,12 +119,12 @@
global_variables_.set(global->symbol(), global);
}
- for (auto* const ty : program_->constructed_types()) {
+ for (auto* const ty : program_->AST().ConstructedTypes()) {
if (!EmitConstructedType(ty)) {
return false;
}
}
- if (!program_->constructed_types().empty()) {
+ if (!program_->AST().ConstructedTypes().empty()) {
out_ << std::endl;
}
diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc
index 36d47f0..1b99314 100644
--- a/src/writer/msl/generator_impl_function_test.cc
+++ b/src/writer/msl/generator_impl_function_test.cc
@@ -350,7 +350,7 @@
auto* s = ty.struct_("Data", str);
type::AccessControl ac(ast::AccessControl::kReadWrite, s);
- mod->AddConstructedType(s);
+ mod->AST().AddConstructedType(s);
auto* coord_var =
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
@@ -405,7 +405,7 @@
auto* s = ty.struct_("Data", str);
type::AccessControl ac(ast::AccessControl::kReadOnly, s);
- mod->AddConstructedType(s);
+ mod->AST().AddConstructedType(s);
auto* coord_var =
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
@@ -722,7 +722,7 @@
auto* s = ty.struct_("Data", str);
type::AccessControl ac(ast::AccessControl::kReadWrite, s);
- mod->AddConstructedType(s);
+ mod->AST().AddConstructedType(s);
auto* coord_var =
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
@@ -791,7 +791,7 @@
auto* s = ty.struct_("Data", str);
type::AccessControl ac(ast::AccessControl::kReadOnly, s);
- mod->AddConstructedType(s);
+ mod->AST().AddConstructedType(s);
auto* coord_var =
Var("coord", ast::StorageClass::kStorage, &ac, nullptr,
@@ -986,7 +986,7 @@
ast::VariableDecorationList{create<ast::BindingDecoration>(0),
create<ast::GroupDecoration>(0)});
- mod->AddConstructedType(s);
+ mod->AST().AddConstructedType(s);
td.RegisterVariableForTesting(data_var);
mod->AST().AddGlobalVariable(data_var);
diff --git a/src/writer/spirv/builder_function_test.cc b/src/writer/spirv/builder_function_test.cc
index 861fd56..0666848 100644
--- a/src/writer/spirv/builder_function_test.cc
+++ b/src/writer/spirv/builder_function_test.cc
@@ -242,7 +242,7 @@
create<ast::GroupDecoration>(0),
});
- mod->AddConstructedType(s);
+ mod->AST().AddConstructedType(s);
td.RegisterVariableForTesting(data_var);
mod->AST().AddGlobalVariable(data_var);
diff --git a/src/writer/wgsl/generator_impl.cc b/src/writer/wgsl/generator_impl.cc
index 4ae3b1d..0e23380 100644
--- a/src/writer/wgsl/generator_impl.cc
+++ b/src/writer/wgsl/generator_impl.cc
@@ -84,12 +84,12 @@
GeneratorImpl::~GeneratorImpl() = default;
bool GeneratorImpl::Generate() {
- for (auto* const ty : program_->constructed_types()) {
+ for (auto* const ty : program_->AST().ConstructedTypes()) {
if (!EmitConstructedType(ty)) {
return false;
}
}
- if (!program_->constructed_types().empty())
+ if (!program_->AST().ConstructedTypes().empty())
out_ << std::endl;
for (auto* var : program_->AST().GlobalVariables()) {
@@ -121,12 +121,12 @@
// TODO(dsinclair): We always emit constructed types even if they aren't
// strictly needed
- for (auto* const ty : program_->constructed_types()) {
+ for (auto* const ty : program_->AST().ConstructedTypes()) {
if (!EmitConstructedType(ty)) {
return false;
}
}
- if (!program_->constructed_types().empty()) {
+ if (!program_->AST().ConstructedTypes().empty()) {
out_ << std::endl;
}
diff --git a/src/writer/wgsl/generator_impl_function_test.cc b/src/writer/wgsl/generator_impl_function_test.cc
index ed32778..f82c2b1 100644
--- a/src/writer/wgsl/generator_impl_function_test.cc
+++ b/src/writer/wgsl/generator_impl_function_test.cc
@@ -191,7 +191,7 @@
create<ast::GroupDecoration>(0),
});
- mod->AddConstructedType(s);
+ mod->AST().AddConstructedType(s);
td.RegisterVariableForTesting(data_var);
mod->AST().AddGlobalVariable(data_var);