[tint][constant] Make Value::Clone() return a const pointer

Once constants are de-duplicated, they must be fully immutable.

Bug: tint:1935
Change-Id: Iba1f85079f2ada1f44ba44d1da9b8a65d1abf2ad
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/134361
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
This commit is contained in:
Ben Clayton 2023-05-24 23:07:36 +00:00
parent 9aa8012d91
commit a71bd22de1
6 changed files with 6 additions and 6 deletions

View File

@ -28,7 +28,7 @@ Composite::Composite(const type::Type* t,
Composite::~Composite() = default;
Composite* Composite::Clone(CloneContext& ctx) const {
const Composite* Composite::Clone(CloneContext& ctx) const {
auto* ty = type->Clone(ctx.type_ctx);
utils::Vector<const constant::Value*, 4> els;
for (const auto* el : elements) {

View File

@ -61,7 +61,7 @@ class Composite : public utils::Castable<Composite, Value> {
/// Clones the constant into the provided context
/// @param ctx the clone context
/// @returns the cloned node
Composite* Clone(CloneContext& ctx) const override;
const Composite* Clone(CloneContext& ctx) const override;
/// The composite type
type::Type const* const type;

View File

@ -61,7 +61,7 @@ class Scalar : public utils::Castable<Scalar<T>, Value> {
/// Clones the constant into the provided context
/// @param ctx the clone context
/// @returns the cloned node
Scalar* Clone(CloneContext& ctx) const override {
const Scalar* Clone(CloneContext& ctx) const override {
auto* ty = type->Clone(ctx.type_ctx);
return ctx.dst.constants->Create<Scalar<T>>(ty, value);
}

View File

@ -22,7 +22,7 @@ Splat::Splat(const type::Type* t, const constant::Value* e, size_t n) : type(t),
Splat::~Splat() = default;
Splat* Splat::Clone(CloneContext& ctx) const {
const Splat* Splat::Clone(CloneContext& ctx) const {
auto* ty = type->Clone(ctx.type_ctx);
auto* element = el->Clone(ctx);
return ctx.dst.constants->Create<Splat>(ty, element, count);

View File

@ -57,7 +57,7 @@ class Splat : public utils::Castable<Splat, Value> {
/// Clones the constant into the provided context
/// @param ctx the clone context
/// @returns the cloned node
Splat* Clone(CloneContext& ctx) const override;
const Splat* Clone(CloneContext& ctx) const override;
/// The type of the splat element
type::Type const* const type;

View File

@ -80,7 +80,7 @@ class Value : public utils::Castable<Value, Node> {
/// Clones the constant into the provided context
/// @param ctx the clone context
/// @returns the cloned node
virtual Value* Clone(CloneContext& ctx) const = 0;
virtual const Value* Clone(CloneContext& ctx) const = 0;
protected:
/// @returns the value, if this is of a scalar value or abstract numeric, otherwise