diff --git a/SPIRV/spvIR.h b/SPIRV/spvIR.h index 948ea52c..ddccd26b 100644 --- a/SPIRV/spvIR.h +++ b/SPIRV/spvIR.h @@ -358,12 +358,12 @@ public: { return reducedPrecisionReturn ? DecorationRelaxedPrecision : NoPrecision; } void setDebugLineInfo(Id fileName, int line, int column) { - lineInstruction = Instruction(OpLine); - lineInstruction.addIdOperand(fileName); - lineInstruction.addImmediateOperand(line); - lineInstruction.addImmediateOperand(column); + lineInstruction = std::make_unique(OpLine); + lineInstruction->addIdOperand(fileName); + lineInstruction->addImmediateOperand(line); + lineInstruction->addImmediateOperand(column); } - bool hasDebugLineInfo() const { return lineInstruction.getOpCode() == OpLine; } + bool hasDebugLineInfo() const { return lineInstruction != nullptr; } void setImplicitThis() { implicitThis = true; } bool hasImplicitThis() const { return implicitThis; } @@ -382,8 +382,8 @@ public: void dump(std::vector& out) const { // OpLine - if (hasDebugLineInfo()) { - lineInstruction.dump(out); + if (lineInstruction != nullptr) { + lineInstruction->dump(out); } // OpFunction @@ -404,7 +404,7 @@ protected: Function& operator=(Function&); Module& parent; - Instruction lineInstruction; + std::unique_ptr lineInstruction; Instruction functionInstruction; std::vector parameterInstructions; std::vector blocks; @@ -471,7 +471,7 @@ protected: // - the OpFunction instruction // - all the OpFunctionParameter instructions __inline Function::Function(Id id, Id resultType, Id functionType, Id firstParamId, Module& parent) - : parent(parent), lineInstruction(OpNop), + : parent(parent), lineInstruction(nullptr), functionInstruction(id, resultType, OpFunction), implicitThis(false), reducedPrecisionReturn(false) {