diff options
| author | Craig Topper <craig.topper@gmail.com> | 2017-06-26 07:15:59 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@gmail.com> | 2017-06-26 07:15:59 +0000 |
| commit | 700892fd890067eb22cb9ed89c68d53d2be8251c (patch) | |
| tree | 5eef9779ff21c010eda0b0011653b8142d220fc9 /llvm | |
| parent | 0e70206c8fc6a17a2b9b9c55aa2a7ddf982037a6 (diff) | |
| download | bcm5719-llvm-700892fd890067eb22cb9ed89c68d53d2be8251c.tar.gz bcm5719-llvm-700892fd890067eb22cb9ed89c68d53d2be8251c.zip | |
[IR] Rename BinaryOperator::init to AssertOK and remove argument. Replace default case in switch with llvm_unreachable since all valid opcodes are covered.
This method doesn't do any initializing. It just contains asserts. So renaming to AssertOK makes it consistent with similar instructions in other Instruction classes.
llvm-svn: 306277
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/IR/InstrTypes.h | 4 | ||||
| -rw-r--r-- | llvm/lib/IR/Instructions.cpp | 11 |
2 files changed, 7 insertions, 8 deletions
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h index b3c6644c7e8..76524b41245 100644 --- a/llvm/include/llvm/IR/InstrTypes.h +++ b/llvm/include/llvm/IR/InstrTypes.h @@ -322,14 +322,14 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(UnaryInstruction, Value) //===----------------------------------------------------------------------===// class BinaryOperator : public Instruction { + void AssertOK(); + protected: BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty, const Twine &Name, Instruction *InsertBefore); BinaryOperator(BinaryOps iType, Value *S1, Value *S2, Type *Ty, const Twine &Name, BasicBlock *InsertAtEnd); - void init(BinaryOps iType); - // Note: Instruction needs to be a friend here to call cloneImpl. friend class Instruction; diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index 44b6d6a99ad..a79b00be4ff 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -1995,8 +1995,8 @@ BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, InsertBefore) { Op<0>() = S1; Op<1>() = S2; - init(iType); setName(Name); + AssertOK(); } BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, @@ -2008,17 +2008,17 @@ BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, InsertAtEnd) { Op<0>() = S1; Op<1>() = S2; - init(iType); setName(Name); + AssertOK(); } -void BinaryOperator::init(BinaryOps iType) { +void BinaryOperator::AssertOK() { Value *LHS = getOperand(0), *RHS = getOperand(1); (void)LHS; (void)RHS; // Silence warnings. assert(LHS->getType() == RHS->getType() && "Binary operator operand types must match!"); #ifndef NDEBUG - switch (iType) { + switch (getOpcode()) { case Add: case Sub: case Mul: assert(getType() == LHS->getType() && @@ -2075,8 +2075,7 @@ void BinaryOperator::init(BinaryOps iType) { assert(getType()->isIntOrIntVectorTy() && "Tried to create a logical operation on a non-integral type!"); break; - default: - break; + default: llvm_unreachable("Invalid opcode provided"); } #endif } |

