[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Aug 17 10:28:58 PDT 2004
Changes in directory llvm/lib/VMCore:
Constants.cpp updated: 1.101 -> 1.102
---
Log message:
Check constant expression validity more strictly
---
Diffs of the changes: (+31 -0)
Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.101 llvm/lib/VMCore/Constants.cpp:1.102
--- llvm/lib/VMCore/Constants.cpp:1.101 Wed Aug 4 17:26:13 2004
+++ llvm/lib/VMCore/Constants.cpp Tue Aug 17 12:28:46 2004
@@ -1127,6 +1127,37 @@
}
Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) {
+#ifndef NDEBUG
+ switch (Opcode) {
+ case Instruction::Add: case Instruction::Sub:
+ case Instruction::Mul: case Instruction::Div:
+ case Instruction::Rem:
+ assert(C1->getType() == C2->getType() && "Op types should be identical!");
+ assert((C1->getType()->isInteger() || C1->getType()->isFloatingPoint()) &&
+ "Tried to create an arithmetic operation on a non-arithmetic type!");
+ break;
+ case Instruction::And:
+ case Instruction::Or:
+ case Instruction::Xor:
+ assert(C1->getType() == C2->getType() && "Op types should be identical!");
+ assert(C1->getType()->isIntegral() &&
+ "Tried to create an logical operation on a non-integral type!");
+ break;
+ case Instruction::SetLT: case Instruction::SetGT: case Instruction::SetLE:
+ case Instruction::SetGE: case Instruction::SetEQ: case Instruction::SetNE:
+ assert(C1->getType() == C2->getType() && "Op types should be identical!");
+ break;
+ case Instruction::Shl:
+ case Instruction::Shr:
+ assert(C2->getType() == Type::UByteTy && "Shift should be by ubyte!");
+ assert(C1->getType()->isInteger() &&
+ "Tried to create a shift operation on a non-integer type!");
+ break;
+ default:
+ break;
+ }
+#endif
+
if (Instruction::isRelational(Opcode))
return getTy(Type::BoolTy, Opcode, C1, C2);
else
More information about the llvm-commits
mailing list