Remove StructType::name()

This CL removes the name accessor from the StructType. All usages are
updated to use the symbol.

Change-Id: I65d793e9609a1663facce955bdb89e60f11f382a
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/36800
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
dan sinclair
2021-01-11 16:24:32 +00:00
committed by dan sinclair
parent 1d967e3228
commit e76a86a22c
12 changed files with 27 additions and 26 deletions

View File

@@ -40,7 +40,8 @@ TEST_F(SpvParserTest, NamedTypes_AnonStruct) {
%s = OpTypeStruct %uint %uint
)"));
EXPECT_TRUE(p->BuildAndParseInternalModule());
EXPECT_THAT(p->module().to_str(), HasSubstr("S Struct"));
EXPECT_THAT(Demangler().Demangle(p->get_module(), p->get_module().to_str()),
HasSubstr("S Struct"));
}
TEST_F(SpvParserTest, NamedTypes_NamedStruct) {
@@ -50,7 +51,8 @@ TEST_F(SpvParserTest, NamedTypes_NamedStruct) {
%s = OpTypeStruct %uint %uint
)"));
EXPECT_TRUE(p->BuildAndParseInternalModule());
EXPECT_THAT(p->module().to_str(), HasSubstr("mystruct Struct"));
EXPECT_THAT(Demangler().Demangle(p->get_module(), p->get_module().to_str()),
HasSubstr("mystruct Struct"));
}
TEST_F(SpvParserTest, NamedTypes_Dup_EmitBoth) {

View File

@@ -357,7 +357,8 @@ Expect<bool> ParserImpl::expect_global_decl() {
return Failure::kErrored;
auto* type = module_.unique_type(std::move(str.value));
register_constructed(type->As<ast::type::Struct>()->name(), type);
register_constructed(
module_.SymbolToName(type->As<ast::type::Struct>()->symbol()), type);
module_.AddConstructedType(type);
return true;
}

View File

@@ -107,11 +107,11 @@ type B = A;)");
ASSERT_EQ(m.constructed_types().size(), 2u);
ASSERT_TRUE(m.constructed_types()[0]->Is<ast::type::Struct>());
auto* str = m.constructed_types()[0]->As<ast::type::Struct>();
EXPECT_EQ(str->name(), "A");
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
ASSERT_TRUE(m.constructed_types()[1]->Is<ast::type::Alias>());
auto* alias = m.constructed_types()[1]->As<ast::type::Alias>();
EXPECT_EQ(m.SymbolToName(alias->symbol()), "B");
EXPECT_EQ(alias->symbol(), p->get_module().RegisterSymbol("B"));
EXPECT_EQ(alias->type(), str);
}
@@ -169,7 +169,7 @@ TEST_F(ParserImplTest, GlobalDecl_ParsesStruct) {
ASSERT_TRUE(t->Is<ast::type::Struct>());
auto* str = t->As<ast::type::Struct>();
EXPECT_EQ(str->name(), "A");
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
EXPECT_EQ(str->impl()->members().size(), 2u);
}
@@ -188,7 +188,7 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithStride) {
ASSERT_TRUE(t->Is<ast::type::Struct>());
auto* str = t->As<ast::type::Struct>();
EXPECT_EQ(str->name(), "A");
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
EXPECT_EQ(str->impl()->members().size(), 1u);
EXPECT_FALSE(str->IsBlockDecorated());
@@ -212,7 +212,7 @@ TEST_F(ParserImplTest, GlobalDecl_Struct_WithDecoration) {
ASSERT_TRUE(t->Is<ast::type::Struct>());
auto* str = t->As<ast::type::Struct>();
EXPECT_EQ(str->name(), "A");
EXPECT_EQ(str->symbol(), p->get_module().RegisterSymbol("A"));
EXPECT_EQ(str->impl()->members().size(), 1u);
EXPECT_TRUE(str->IsBlockDecorated());
}

View File

@@ -39,7 +39,7 @@ struct S {
EXPECT_FALSE(s.errored);
EXPECT_TRUE(s.matched);
ASSERT_NE(s.value, nullptr);
ASSERT_EQ(s->name(), "S");
ASSERT_EQ(s->symbol(), p->get_module().RegisterSymbol("S"));
ASSERT_EQ(s->impl()->members().size(), 2u);
EXPECT_EQ(s->impl()->members()[0]->name(), "a");
EXPECT_EQ(s->impl()->members()[1]->name(), "b");
@@ -61,7 +61,7 @@ TEST_F(ParserImplTest, StructDecl_ParsesWithDecoration) {
EXPECT_FALSE(s.errored);
EXPECT_TRUE(s.matched);
ASSERT_NE(s.value, nullptr);
ASSERT_EQ(s->name(), "B");
ASSERT_EQ(s->symbol(), p->get_module().RegisterSymbol("B"));
ASSERT_EQ(s->impl()->members().size(), 2u);
EXPECT_EQ(s->impl()->members()[0]->name(), "a");
EXPECT_EQ(s->impl()->members()[1]->name(), "b");
@@ -86,7 +86,7 @@ TEST_F(ParserImplTest, StructDecl_ParsesWithMultipleDecoration) {
EXPECT_FALSE(s.errored);
EXPECT_TRUE(s.matched);
ASSERT_NE(s.value, nullptr);
ASSERT_EQ(s->name(), "S");
ASSERT_EQ(s->symbol(), p->get_module().RegisterSymbol("S"));
ASSERT_EQ(s->impl()->members().size(), 2u);
EXPECT_EQ(s->impl()->members()[0]->name(), "a");
EXPECT_EQ(s->impl()->members()[1]->name(), "b");

View File

@@ -60,7 +60,7 @@ TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
auto* s = alias->type()->As<ast::type::Struct>();
EXPECT_EQ(s->symbol(), p->get_module().RegisterSymbol("B"));
EXPECT_EQ(s->name(), "B");
EXPECT_EQ(s->symbol(), p->get_module().RegisterSymbol("B"));
}
TEST_F(ParserImplTest, TypeDecl_MissingIdent) {