From 6adacc92331b88674f7a49ad8857dbb7109a8b81 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Sat, 12 Sep 2015 00:08:21 +0000 Subject: [PATCH] Move asserts from PHINode::addIncoming to PHINode::setIncoming* We had asserts in PHINode::addIncoming to check that the value types matched the type of the PHI, and that the associated BB was not null. These did not catch, however, later uses of setIncomingValue and setIncomingBlock (which are called by addIncoming as well). Moving the asserts to PHINode::setIncoming* provides better coverage. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@247492 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Instructions.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h index d979b393066..1497231cbe0 100644 --- a/include/llvm/IR/Instructions.h +++ b/include/llvm/IR/Instructions.h @@ -2405,6 +2405,9 @@ public: return getOperand(i); } void setIncomingValue(unsigned i, Value *V) { + assert(V && "PHI node got a null value!"); + assert(getType() == V->getType() && + "All operands to PHI node must be the same type as the PHI node!"); setOperand(i, V); } static unsigned getOperandNumForIncomingValue(unsigned i) { @@ -2436,16 +2439,13 @@ public: } void setIncomingBlock(unsigned i, BasicBlock *BB) { + assert(BB && "PHI node got a null basic block!"); block_begin()[i] = BB; } /// addIncoming - Add an incoming value to the end of the PHI list /// void addIncoming(Value *V, BasicBlock *BB) { - assert(V && "PHI node got a null value!"); - assert(BB && "PHI node got a null basic block!"); - assert(getType() == V->getType() && - "All operands to PHI node must be the same type as the PHI node!"); if (getNumOperands() == ReservedSpace) growOperands(); // Get more space! // Initialize some new operands. -- 2.34.1