From 99a0ded622559bd21f063415299a2ee7b7514233 Mon Sep 17 00:00:00 2001 From: James Price Date: Tue, 25 Apr 2023 18:10:19 +0000 Subject: [PATCH] tint: Use type::Struct::Name in CreateASTTypeFor The declaration may be nullptr, so doing this avoids a potential nullptr deref when the struct is an internal type (e.g. frexp result). In these cases we will now fail to resolve the resulting code, which is a little better than just crashing. A future change will update the resolver to allow us to use the internal struct names from our transforms. Bug: chromium:1430309 Change-Id: Ic72b5105bf3159c448c20dd9228d73b25a632b69 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/129120 Kokoro: Kokoro Commit-Queue: James Price Reviewed-by: Ben Clayton --- src/tint/transform/transform.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tint/transform/transform.cc b/src/tint/transform/transform.cc index 73ee3ae85a..2002d025b0 100644 --- a/src/tint/transform/transform.cc +++ b/src/tint/transform/transform.cc @@ -144,7 +144,7 @@ ast::Type Transform::CreateASTTypeFor(CloneContext& ctx, const type::Type* ty) { return ctx.dst->ty.array(el, u32(count.value()), std::move(attrs)); } if (auto* s = ty->As()) { - return ctx.dst->ty(ctx.Clone(s->Declaration()->name->symbol)); + return ctx.dst->ty(ctx.Clone(s->Name())); } if (auto* s = ty->As()) { return CreateASTTypeFor(ctx, s->StoreType());