Skip to content

Commit

Permalink
use unique_ptr to avoid calling deleted move ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
qingyuanzNV committed May 31, 2022
1 parent 279c28e commit b6df89b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions SPIRV/spvIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,12 @@ class Function {
{ 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<Instruction>(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; }
Expand All @@ -382,8 +382,8 @@ class Function {
void dump(std::vector<unsigned int>& out) const
{
// OpLine
if (hasDebugLineInfo()) {
lineInstruction.dump(out);
if (lineInstruction != nullptr) {
lineInstruction->dump(out);
}

// OpFunction
Expand All @@ -404,7 +404,7 @@ class Function {
Function& operator=(Function&);

Module& parent;
Instruction lineInstruction;
std::unique_ptr<Instruction> lineInstruction;
Instruction functionInstruction;
std::vector<Instruction*> parameterInstructions;
std::vector<Block*> blocks;
Expand Down Expand Up @@ -471,7 +471,7 @@ class Module {
// - 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)
{
Expand Down

0 comments on commit b6df89b

Please sign in to comment.