1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00

Reject duplicate case values in a switch, PR5450.

llvm-svn: 86846
This commit is contained in:
Chris Lattner 2009-11-11 17:37:02 +00:00
parent f0d9823d0b
commit a3457e6bae

View File

@ -780,9 +780,13 @@ void Verifier::visitSwitchInst(SwitchInst &SI) {
// Check to make sure that all of the constants in the switch instruction
// have the same type as the switched-on value.
const Type *SwitchTy = SI.getCondition()->getType();
for (unsigned i = 1, e = SI.getNumCases(); i != e; ++i)
SmallPtrSet<ConstantInt*, 32> Constants;
for (unsigned i = 1, e = SI.getNumCases(); i != e; ++i) {
Assert1(SI.getCaseValue(i)->getType() == SwitchTy,
"Switch constants must all be same type as switch value!", &SI);
Assert2(Constants.insert(SI.getCaseValue(i)),
"Duplicate integer as switch case", &SI, SI.getCaseValue(i));
}
visitTerminatorInst(SI);
}