mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
tint: Have ast::TypeName use ast::Identifier
Consistency with the other AST nodes. Change-Id: I8db3d237c27fea44c80101ed3d24b62832d45c18 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118360 Commit-Queue: Ben Clayton <bclayton@chromium.org> Reviewed-by: James Price <jrprice@google.com> Reviewed-by: Dan Sinclair <dsinclair@chromium.org> Kokoro: Ben Clayton <bclayton@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
14685aa05b
commit
89a717bacf
@@ -164,8 +164,9 @@ Transform::ApplyResult ClampFragDepth::Apply(const Program* src, const DataMap&,
|
||||
auto* struct_ty = sem.Get(fn)->ReturnType()->As<sem::Struct>()->Declaration();
|
||||
auto helper = io_structs_clamp_helpers.GetOrCreate(struct_ty, [&] {
|
||||
auto* return_ty = fn->return_type;
|
||||
auto fn_sym = b.Symbols().New("clamp_frag_depth_" +
|
||||
sym.NameFor(return_ty->As<ast::TypeName>()->name));
|
||||
auto fn_sym =
|
||||
b.Symbols().New("clamp_frag_depth_" +
|
||||
sym.NameFor(return_ty->As<ast::TypeName>()->name->symbol));
|
||||
|
||||
utils::Vector<const ast::Expression*, 8u> initializer_args;
|
||||
for (auto* member : struct_ty->members) {
|
||||
|
||||
@@ -1263,8 +1263,6 @@ Transform::ApplyResult Renamer::Apply(const Program* src,
|
||||
|
||||
// Identifiers that need to keep their symbols preserved.
|
||||
utils::Hashset<const ast::Identifier*, 8> preserved_identifiers;
|
||||
// Type names that need to keep their symbols preserved.
|
||||
utils::Hashset<const ast::TypeName*, 8> preserved_type_names;
|
||||
|
||||
auto is_type_short_name = [&](const Symbol& symbol) {
|
||||
auto name = src->Symbols().NameFor(symbol);
|
||||
@@ -1317,8 +1315,8 @@ Transform::ApplyResult Renamer::Apply(const Program* src,
|
||||
preserved_identifiers.Add(diagnostic->rule_name);
|
||||
},
|
||||
[&](const ast::TypeName* type_name) {
|
||||
if (is_type_short_name(type_name->name)) {
|
||||
preserved_type_names.Add(type_name);
|
||||
if (is_type_short_name(type_name->name->symbol)) {
|
||||
preserved_identifiers.Add(type_name->name);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1386,16 +1384,6 @@ Transform::ApplyResult Renamer::Apply(const Program* src,
|
||||
return nullptr; // Clone ident. Uses the symbol remapping above.
|
||||
});
|
||||
|
||||
ctx.ReplaceAll([&](const ast::TypeName* type_name) -> const ast::TypeName* {
|
||||
if (preserved_type_names.Contains(type_name)) {
|
||||
auto sym_in = type_name->name;
|
||||
auto str = src->Symbols().NameFor(sym_in);
|
||||
auto sym_out = b.Symbols().Register(str);
|
||||
return ctx.dst->create<ast::TypeName>(ctx.Clone(type_name->source), sym_out);
|
||||
}
|
||||
return nullptr; // Clone ident. Uses the symbol remapping above.
|
||||
});
|
||||
|
||||
ctx.Clone(); // Must come before the std::move()
|
||||
|
||||
outputs.Add<Data>(std::move(remappings));
|
||||
|
||||
@@ -405,7 +405,7 @@ struct Std140::State {
|
||||
ty, //
|
||||
[&](const sem::Struct* str) -> const ast::Type* {
|
||||
if (auto std140 = std140_structs.Find(str)) {
|
||||
return b.create<ast::TypeName>(*std140);
|
||||
return b.ty.type_name(*std140);
|
||||
}
|
||||
return nullptr;
|
||||
},
|
||||
|
||||
@@ -138,7 +138,7 @@ const ast::Type* Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type
|
||||
return ctx.dst->ty.array(el, u32(count.value()), std::move(attrs));
|
||||
}
|
||||
if (auto* s = ty->As<sem::Struct>()) {
|
||||
return ctx.dst->create<ast::TypeName>(ctx.Clone(s->Declaration()->name));
|
||||
return ctx.dst->ty.type_name(ctx.Clone(s->Declaration()->name));
|
||||
}
|
||||
if (auto* s = ty->As<type::Reference>()) {
|
||||
return CreateASTTypeFor(ctx, s->StoreType());
|
||||
|
||||
@@ -116,7 +116,7 @@ TEST_F(CreateASTTypeForTest, AliasedArrayWithComplexOverrideLength) {
|
||||
CloneContext ctx(&ast_type_builder, &program, false);
|
||||
auto* ast_ty = tint::As<ast::TypeName>(CreateASTTypeFor(ctx, arr_ty));
|
||||
ASSERT_NE(ast_ty, nullptr);
|
||||
EXPECT_EQ(ast_type_builder.Symbols().NameFor(ast_ty->name), "A");
|
||||
EXPECT_EQ(ast_type_builder.Symbols().NameFor(ast_ty->name->symbol), "A");
|
||||
}
|
||||
|
||||
TEST_F(CreateASTTypeForTest, Struct) {
|
||||
@@ -126,7 +126,7 @@ TEST_F(CreateASTTypeForTest, Struct) {
|
||||
4u /* size */, 4u /* size_no_padding */);
|
||||
});
|
||||
ASSERT_TRUE(str->Is<ast::TypeName>());
|
||||
EXPECT_EQ(ast_type_builder.Symbols().NameFor(str->As<ast::TypeName>()->name), "S");
|
||||
EXPECT_EQ(ast_type_builder.Symbols().NameFor(str->As<ast::TypeName>()->name->symbol), "S");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user