[llvm-commits] CVS: llvm/lib/VMCore/Instructions.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Apr 24 00:28:51 PDT 2005



Changes in directory llvm/lib/VMCore:

Instructions.cpp updated: 1.14 -> 1.15
---
Log message:

Allow these methods to take a generic Value* to simplify clients.  Use
const_cast instead of c casts.


---
Diffs of the changes:  (+12 -11)

 Instructions.cpp |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)


Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.14 llvm/lib/VMCore/Instructions.cpp:1.15
--- llvm/lib/VMCore/Instructions.cpp:1.14	Thu Apr 21 18:46:51 2005
+++ llvm/lib/VMCore/Instructions.cpp	Sun Apr 24 02:28:37 2005
@@ -823,27 +823,28 @@
   return false;
 }
 
-Value *BinaryOperator::getNegArgument(BinaryOperator *Bop) {
-  assert(isNeg(Bop) && "getNegArgument from non-'neg' instruction!");
-  return Bop->getOperand(1);
+Value *BinaryOperator::getNegArgument(Value *BinOp) {
+  assert(isNeg(BinOp) && "getNegArgument from non-'neg' instruction!");
+  return cast<BinaryOperator>(BinOp)->getOperand(1);
 }
 
-const Value *BinaryOperator::getNegArgument(const BinaryOperator *Bop) {
-  return getNegArgument((BinaryOperator*)Bop);
+const Value *BinaryOperator::getNegArgument(const Value *BinOp) {
+  return getNegArgument(const_cast<Value*>(BinOp));
 }
 
-Value *BinaryOperator::getNotArgument(BinaryOperator *Bop) {
-  assert(isNot(Bop) && "getNotArgument on non-'not' instruction!");
-  Value *Op0 = Bop->getOperand(0);
-  Value *Op1 = Bop->getOperand(1);
+Value *BinaryOperator::getNotArgument(Value *BinOp) {
+  assert(isNot(BinOp) && "getNotArgument on non-'not' instruction!");
+  BinaryOperator *BO = cast<BinaryOperator>(BinOp);
+  Value *Op0 = BO->getOperand(0);
+  Value *Op1 = BO->getOperand(1);
   if (isConstantAllOnes(Op0)) return Op1;
 
   assert(isConstantAllOnes(Op1));
   return Op0;
 }
 
-const Value *BinaryOperator::getNotArgument(const BinaryOperator *Bop) {
-  return getNotArgument((BinaryOperator*)Bop);
+const Value *BinaryOperator::getNotArgument(const Value *BinOp) {
+  return getNotArgument(const_cast<Value*>(BinOp));
 }
 
 






More information about the llvm-commits mailing list