]> granicus.if.org Git - clang/commit
Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012:
authorStepan Dyatkovskiy <stpworld@narod.ru>
Thu, 8 Mar 2012 07:06:48 +0000 (07:06 +0000)
committerStepan Dyatkovskiy <stpworld@narod.ru>
Thu, 8 Mar 2012 07:06:48 +0000 (07:06 +0000)
commitaae1d8bd6f2482e0bf13a29d5b0cb7639080974d
tree4dc694091fbbe2f846cf9cf55852b65b428935f2
parent76e035a529775dc8fd31124f819745a33a085796
Taken into account Duncan's comments for r149481 dated by 2nd Feb 2012:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120130/136146.html

Implemented CaseIterator and it solves almost all described issues: we don't need to mix operand/case/successor indexing anymore. Base iterator class is implemented as a template since it may be initialized either from "const SwitchInst*" or from "SwitchInst*".

ConstCaseIt is just a read-only iterator.
CaseIt is read-write iterator; it allows to change case successor and case value.

Usage of iterator allows totally remove resolveXXXX methods. All indexing convertions done automatically inside the iterator's getters.

Main way of iterator usage looks like this:
SwitchInst *SI = ... // intialize it somehow

for (SwitchInst::CaseIt i = SI->caseBegin(), e = SI->caseEnd(); i != e; ++i) {
  BasicBlock *BB = i.getCaseSuccessor();
  ConstantInt *V = i.getCaseValue();
  // Do something.
}

If you want to convert case number to TerminatorInst successor index, just use getSuccessorIndex iterator's method.
If you want initialize iterator from TerminatorInst successor index, use CaseIt::fromSuccessorIndex(...) method.

There are also related changes in llvm-clients: klee and clang.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152298 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/CGCleanup.cpp