[llvm] r212163 - Add range for-loop iterator adapter for cases in SwitchInst.
Owen Anderson
resistor at mac.com
Tue Jul 1 22:32:13 PDT 2014
Author: resistor
Date: Wed Jul 2 00:32:13 2014
New Revision: 212163
URL: http://llvm.org/viewvc/llvm-project?rev=212163&view=rev
Log:
Add range for-loop iterator adapter for cases in SwitchInst.
Patch by Marcello Maggioni, reviewed by Reid Kleckner.
Modified:
llvm/trunk/include/llvm/IR/Instructions.h
Modified: llvm/trunk/include/llvm/IR/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instructions.h?rev=212163&r1=212162&r2=212163&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Instructions.h (original)
+++ llvm/trunk/include/llvm/IR/Instructions.h Wed Jul 2 00:32:13 2014
@@ -2661,6 +2661,9 @@ public:
assert(RHS.SI == SI && "Incompatible operators.");
return RHS.Index != Index;
}
+ Self &operator*() {
+ return *this;
+ }
};
typedef CaseIteratorT<const SwitchInst, const ConstantInt, const BasicBlock>
@@ -2741,6 +2744,17 @@ public:
ConstCaseIt case_end() const {
return ConstCaseIt(this, getNumCases());
}
+
+ /// cases - iteration adapter for range-for loops.
+ iterator_range<CaseIt> cases() {
+ return iterator_range<CaseIt>(case_begin(), case_end());
+ }
+
+ /// cases - iteration adapter for range-for loops.
+ iterator_range<ConstCaseIt> cases() const {
+ return iterator_range<ConstCaseIt>(case_begin(), case_end());
+ }
+
/// Returns an iterator that points to the default case.
/// Note: this iterator allows to resolve successor only. Attempt
/// to resolve case value causes an assertion.
More information about the llvm-commits
mailing list