inspector: Implement a custom StageVariable copy constructor
The fields `has_location_decoration` and `location_decoration` are references to `has_location_attribute` and `location_attribute`, respectively, which act as an alias for a field-rename.
The default copy-constructor was copying across the reference (pointer) to the source StageVariable, instead of making a reference to the target's fields. This is causing Bad Thingsā¢ to happen in downstream projects.
Credit to dneto@ for identifying the issue, and for making this fix (which I've stolen for this CL).
Change-Id: Id0570e4e389f28980fa5aea29ad63b5100373dc5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/79200
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/inspector/entry_point.cc b/src/inspector/entry_point.cc
index 076ebac..7cce84c 100644
--- a/src/inspector/entry_point.cc
+++ b/src/inspector/entry_point.cc
@@ -18,7 +18,17 @@
namespace inspector {
StageVariable::StageVariable() = default;
-StageVariable::StageVariable(const StageVariable&) = default;
+StageVariable::StageVariable(const StageVariable& other)
+ : name(other.name),
+ has_location_attribute(other.has_location_attribute),
+ location_attribute(other.location_attribute),
+ has_location_decoration(has_location_attribute),
+ location_decoration(location_attribute),
+ component_type(other.component_type),
+ composition_type(other.composition_type),
+ interpolation_type(other.interpolation_type),
+ interpolation_sampling(other.interpolation_sampling) {}
+
StageVariable::~StageVariable() = default;
EntryPoint::EntryPoint() = default;
diff --git a/src/inspector/entry_point.h b/src/inspector/entry_point.h
index 03d4705..f7bb23a 100644
--- a/src/inspector/entry_point.h
+++ b/src/inspector/entry_point.h
@@ -59,7 +59,8 @@
/// Constructor
StageVariable();
/// Copy constructor
- StageVariable(const StageVariable&);
+ /// @param other the StageVariable to copy
+ StageVariable(const StageVariable& other);
/// Destructor
~StageVariable();