[InstructionCost] Prevent InstructionCost being created with CostState.

For a function that returns InstructionCost, it is very tempting to write:

  return InstructionCost::Invalid;

But that actually returns InstructionCost(1 /* int value of Invalid */))
which has a totally different meaning. By marking this constructor as
`delete`, this can no longer happen.
This commit is contained in:
Sander de Smalen 2021-01-21 16:37:09 +00:00
parent 8fdd5784f0
commit d196f9e2fc
1 changed files with 1 additions and 0 deletions

View File

@ -47,6 +47,7 @@ private:
public:
InstructionCost() = default;
InstructionCost(CostState) = delete;
InstructionCost(CostType Val) : Value(Val), State(Valid) {}
static InstructionCost getInvalid(CostType Val = 0) {