Avoid Array<> assignment The Array<> assignment operator gets auto-generated, but is unsafe as it overwrites the Variable address field. Also delete the Variable assignment operator. Bug b/129356087 Change-Id: If6d5945f2a56f9a81bbc1491a524e3f17c1561da Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/28088 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/Pipeline/SpirvShader.cpp b/src/Pipeline/SpirvShader.cpp index a7d044c..e64c953 100644 --- a/src/Pipeline/SpirvShader.cpp +++ b/src/Pipeline/SpirvShader.cpp
@@ -1343,6 +1343,8 @@ // the block. struct LoopPhi { + LoopPhi(Object::ID id, uint32_t size) : phiId(id), storage(size) {} + Object::ID phiId; // The Phi identifier. Object::ID continueValue; // The source merge value from the loop. Array<SIMD::Int> storage; // The alloca. @@ -1359,9 +1361,7 @@ auto &object = getObject(objectId); auto &type = getType(object.type); - LoopPhi phi; - phi.phiId = Object::ID(insn.word(2)); - phi.storage = Array<SIMD::Int>(type.sizeInComponents); + LoopPhi phi(insn.word(2), type.sizeInComponents); // Start with the Phi set to 0. for (uint32_t i = 0; i < type.sizeInComponents; i++)
diff --git a/src/Reactor/Reactor.hpp b/src/Reactor/Reactor.hpp index d13b602..ebf2a7a 100644 --- a/src/Reactor/Reactor.hpp +++ b/src/Reactor/Reactor.hpp
@@ -81,8 +81,15 @@ class Variable { - protected: friend class PrintValue; + + Variable &operator=(const Variable&) = delete; + + public: + Variable() = default; + Variable(const Variable&) = default; + + protected: Value *address; };