From: Owen Anderson Date: Wed, 2 Jul 2014 05:32:13 +0000 (+0000) Subject: Add range for-loop iterator adapter for cases in SwitchInst. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=90fdedc064a473b7206d0ff8c8db2ed79a9af135;p=oota-llvm.git Add range for-loop iterator adapter for cases in SwitchInst. Patch by Marcello Maggioni, reviewed by Reid Kleckner. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212163 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h index e0c829ac985..a590f5ad7b2 100644 --- a/include/llvm/IR/Instructions.h +++ b/include/llvm/IR/Instructions.h @@ -2661,6 +2661,9 @@ public: assert(RHS.SI == SI && "Incompatible operators."); return RHS.Index != Index; } + Self &operator*() { + return *this; + } }; typedef CaseIteratorT @@ -2741,6 +2744,17 @@ public: ConstCaseIt case_end() const { return ConstCaseIt(this, getNumCases()); } + + /// cases - iteration adapter for range-for loops. + iterator_range cases() { + return iterator_range(case_begin(), case_end()); + } + + /// cases - iteration adapter for range-for loops. + iterator_range cases() const { + return iterator_range(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.