diff options
author | Chris Lattner <sabre@nondot.org> | 2009-11-11 17:37:02 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-11-11 17:37:02 +0000 |
commit | d682a60c4ece505e97dcfe9fb39c7e3da7f6b5a4 (patch) | |
tree | a69db7077a3774cfe8c24c6c6ce44b317c78c6be | |
parent | a3da922a27da1b5db04bbbe6cbf4848a688b6786 (diff) |
Reject duplicate case values in a switch, PR5450.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86846 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Verifier.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 5990e48168..7ab7b15168 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -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); } |