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>
diff --git a/src/tint/transform/packed_vec3.cc b/src/tint/transform/packed_vec3.cc
index 2aba94d..af0c219 100644
--- a/src/tint/transform/packed_vec3.cc
+++ b/src/tint/transform/packed_vec3.cc
@@ -56,16 +56,9 @@
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()));
}
}
}