Do not allow a user to set the operand for a constant.
authorTanya Lattner <tonic@nondot.org>
Tue, 28 Oct 2008 17:22:40 +0000 (17:22 +0000)
committerTanya Lattner <tonic@nondot.org>
Tue, 28 Oct 2008 17:22:40 +0000 (17:22 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58335 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/User.h

index 570f381d1a8c4eb168e16f21305cfc3d0b0be78f..919693e082925582cd3e6a756a8cabf8fee1efff 100644 (file)
@@ -95,6 +95,9 @@ public:
   }
   void setOperand(unsigned i, Value *Val) {
     assert(i < NumOperands && "setOperand() out of range!");
+    assert((!isa<Constant>((const Value*)this) ||
+            isa<GlobalValue>((const Value*)this)) &&
+           "Cannot mutate a constant with setOperand!");
     OperandList[i] = Val;
   }
   unsigned getNumOperands() const { return NumOperands; }