tint/transform: Use InsertFront to add attribute

This is simpler than reconstructing the attribute list and manually
cloning the struct member.

Change-Id: I3d0bd4039030b47e53ce618d9de7ee572b9698f1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/113422
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
James Price 2022-12-08 19:01:17 +00:00
parent 48802bb9ea
commit 04f792de9f
1 changed files with 3 additions and 10 deletions

View File

@ -56,16 +56,9 @@ struct PackedVec3::State {
members.Add(member);
// Apply the PackedVec3::Attribute to the member
auto* member_decl = member->Declaration();
auto name = ctx.Clone(member->Name());
auto* type = ctx.Clone(member_decl->type);
utils::Vector<const ast::Attribute*, 4> attrs{
b.ASTNodes().Create<Attribute>(b.ID(), b.AllocateNodeID()),
};
for (auto* attr : member_decl->attributes) {
attrs.Push(ctx.Clone(attr));
}
ctx.Replace(member_decl, b.Member(name, type, std::move(attrs)));
ctx.InsertFront(
member->Declaration()->attributes,
b.ASTNodes().Create<Attribute>(b.ID(), b.AllocateNodeID()));
}
}
}