summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-03-06 16:36:28 +0000
committerChris Lattner <sabre@nondot.org>2003-03-06 16:36:28 +0000
commitd5c4ef5456038b7b3699fe99b0668fb6fcfc3cbb (patch)
treeb92f72181eb45e8203a0cd32c64448345db2853b
parent17f868690059a2ecf317517059e2b3fd3bfe1268 (diff)
downloadbcm5719-llvm-d5c4ef5456038b7b3699fe99b0668fb6fcfc3cbb.tar.gz
bcm5719-llvm-d5c4ef5456038b7b3699fe99b0668fb6fcfc3cbb.zip
Add new getIncomingValueForBlock method
Relax a bit about constness llvm-svn: 5709
-rw-r--r--llvm/include/llvm/iPHINode.h22
1 files changed, 12 insertions, 10 deletions
diff --git a/llvm/include/llvm/iPHINode.h b/llvm/include/llvm/iPHINode.h
index c9d2a71ecbd..eba5a735542 100644
--- a/llvm/include/llvm/iPHINode.h
+++ b/llvm/include/llvm/iPHINode.h
@@ -33,13 +33,12 @@ public:
unsigned getNumIncomingValues() const { return Operands.size()/2; }
/// getIncomingValue - Return incoming value #x
- const Value *getIncomingValue(unsigned i) const {
- return Operands[i*2];
- }
- Value *getIncomingValue(unsigned i) {
+ Value *getIncomingValue(unsigned i) const {
+ assert(i*2 < Operands.size() && "Invalid value number!");
return Operands[i*2];
}
void setIncomingValue(unsigned i, Value *V) {
+ assert(i*2 < Operands.size() && "Invalid value number!");
Operands[i*2] = V;
}
inline unsigned getOperandNumForIncomingValue(unsigned i) {
@@ -47,16 +46,15 @@ public:
}
/// getIncomingBlock - Return incoming basic block #x
- const BasicBlock *getIncomingBlock(unsigned i) const {
- return (const BasicBlock*)Operands[i*2+1].get();
- }
- inline BasicBlock *getIncomingBlock(unsigned i) {
+ BasicBlock *getIncomingBlock(unsigned i) const {
+ assert(i*2+1 < Operands.size() && "Invalid value number!");
return (BasicBlock*)Operands[i*2+1].get();
}
- inline void setIncomingBlock(unsigned i, BasicBlock *BB) {
+ void setIncomingBlock(unsigned i, BasicBlock *BB) {
+ assert(i*2+1 < Operands.size() && "Invalid value number!");
Operands[i*2+1] = (Value*)BB;
}
- inline unsigned getOperandNumForIncomingBlock(unsigned i) {
+ unsigned getOperandNumForIncomingBlock(unsigned i) {
return i*2+1;
}
@@ -93,6 +91,10 @@ public:
return -1;
}
+ Value *getIncomingValueForBlock(const BasicBlock *BB) const {
+ return getIncomingValue(getBasicBlockIndex(BB));
+ }
+
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const PHINode *) { return true; }
static inline bool classof(const Instruction *I) {
OpenPOWER on IntegriCloud