forked from OSchip/llvm-project
[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:
parent
8fdd5784f0
commit
d196f9e2fc
|
@ -47,6 +47,7 @@ private:
|
|||
public:
|
||||
InstructionCost() = default;
|
||||
|
||||
InstructionCost(CostState) = delete;
|
||||
InstructionCost(CostType Val) : Value(Val), State(Valid) {}
|
||||
|
||||
static InstructionCost getInvalid(CostType Val = 0) {
|
||||
|
|
Loading…
Reference in New Issue