summaryrefslogtreecommitdiff
path: root/lib/VMCore/Verifier.cpp
diff options
context:
space:
mode:
authorStepan Dyatkovskiy <stpworld@narod.ru>2012-05-21 10:44:40 +0000
committerStepan Dyatkovskiy <stpworld@narod.ru>2012-05-21 10:44:40 +0000
commit1c8f4b8c34a75e184ec40251225c2699efecedac (patch)
tree8cc5dc0d704f1b7060f6429fe2727d2361cd2d6d /lib/VMCore/Verifier.cpp
parent8ae97baef204508272b60f63da0ccf97ecf09b01 (diff)
downloadllvm-1c8f4b8c34a75e184ec40251225c2699efecedac.tar.gz
llvm-1c8f4b8c34a75e184ec40251225c2699efecedac.tar.bz2
llvm-1c8f4b8c34a75e184ec40251225c2699efecedac.tar.xz
PR1255 (case ranges: work with ConstantRangesSet instead of ConstantInt) related changes for Execution and Verifier.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157183 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Verifier.cpp')
-rw-r--r--lib/VMCore/Verifier.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 47baef3e29..f11efff9f1 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -804,14 +804,28 @@ 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.
Type *SwitchTy = SI.getCondition()->getType();
- SmallPtrSet<ConstantInt*, 32> Constants;
+ CRSBuilder Builder;
+ std::map<ConstantRangesSet::Range, unsigned> RangeSetMap;
for (SwitchInst::CaseIt i = SI.case_begin(), e = SI.case_end(); i != e; ++i) {
- Assert1(i.getCaseValue()->getType() == SwitchTy,
- "Switch constants must all be same type as switch value!", &SI);
- Assert2(Constants.insert(i.getCaseValue()),
- "Duplicate integer as switch case", &SI, i.getCaseValue());
+ ConstantRangesSet RS = i.getCaseValueEx();
+ for (unsigned ri = 0, rie = RS.getNumItems(); ri < rie; ++ri) {
+ ConstantRangesSet::Range r = RS.getItem(ri);
+ Assert1(r.Low->getType() == SwitchTy,
+ "Switch constants must all be same type as switch value!", &SI);
+ Assert1(r.High->getType() == SwitchTy,
+ "Switch constants must all be same type as switch value!", &SI);
+ Builder.add(r);
+ RangeSetMap[r] = i.getCaseIndex();
+ }
}
-
+
+ CRSBuilder::RangeIterator errItem;
+ if (!Builder.verify(errItem)) {
+ unsigned CaseIndex = RangeSetMap[errItem->first];
+ SwitchInst::CaseIt i(&SI, CaseIndex);
+ Assert2(false, "Duplicate integer as switch case", &SI, i.getCaseValueEx());
+ }
+
visitTerminatorInst(SI);
}