[llvm-commits] CVS: llvm/include/llvm/Constant.h

Chris Lattner lattner at cs.uiuc.edu
Tue Aug 3 19:43:12 PDT 2004



Changes in directory llvm/include/llvm:

Constant.h updated: 1.16 -> 1.17
---
Log message:

Now that ConstantPointerRef is gone, it is the case that all operands of constants
are themselves constants.  This should allow us to reduce a significant amount
of casting in the sourcebase.


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

Index: llvm/include/llvm/Constant.h
diff -u llvm/include/llvm/Constant.h:1.16 llvm/include/llvm/Constant.h:1.17
--- llvm/include/llvm/Constant.h:1.16	Mon Jul 19 16:22:02 2004
+++ llvm/include/llvm/Constant.h	Tue Aug  3 21:43:00 2004
@@ -40,6 +40,18 @@
 
   virtual void print(std::ostream &O) const;
 
+  // Specialize get/setOperand for Constant's as their operands are always
+  // constants as well.
+  Constant *getOperand(unsigned i) { 
+    return static_cast<Constant*>(User::getOperand(i));
+  }
+  const Constant *getOperand(unsigned i) const {
+    return static_cast<const Constant*>(User::getOperand(i));
+  }
+  void setOperand(unsigned i, Constant *C) {
+    User::setOperand(i, C);
+  }
+
   /// destroyConstant - Called if some element of this constant is no longer
   /// valid.  At this point only other constants may be on the use_list for this
   /// constant.  Any constants on our Use list must also be destroy'd.  The






More information about the llvm-commits mailing list