From 927d8e610ab8d86ca007255db1dfffa4886ad659 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 12 Apr 2017 07:27:28 +0000 Subject: [IR] Redesign the case iterator in SwitchInst to actually be an iterator and to expose a handle to represent the actual case rather than having the iterator return a reference to itself. All of this allows the iterator to be used with common STL facilities, standard algorithms, etc. Doing this exposed some missing facilities in the iterator facade that I've fixed and required some work to the actual iterator to fully support the necessary API. Differential Revision: https://reviews.llvm.org/D31548 llvm-svn: 300032 --- llvm/tools/llvm-diff/DifferenceEngine.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'llvm/tools/llvm-diff') diff --git a/llvm/tools/llvm-diff/DifferenceEngine.cpp b/llvm/tools/llvm-diff/DifferenceEngine.cpp index df208a26ab7..95a63d7f9c8 100644 --- a/llvm/tools/llvm-diff/DifferenceEngine.cpp +++ b/llvm/tools/llvm-diff/DifferenceEngine.cpp @@ -315,17 +315,15 @@ class FunctionDifferenceEngine { bool Difference = false; DenseMap LCases; - - for (SwitchInst::CaseIt I = LI->case_begin(), E = LI->case_end(); - I != E; ++I) - LCases[I.getCaseValue()] = I.getCaseSuccessor(); - - for (SwitchInst::CaseIt I = RI->case_begin(), E = RI->case_end(); - I != E; ++I) { - ConstantInt *CaseValue = I.getCaseValue(); + for (auto Case : LI->cases()) + LCases[Case.getCaseValue()] = Case.getCaseSuccessor(); + + for (auto Case : RI->cases()) { + ConstantInt *CaseValue = Case.getCaseValue(); BasicBlock *LCase = LCases[CaseValue]; if (LCase) { - if (TryUnify) tryUnify(LCase, I.getCaseSuccessor()); + if (TryUnify) + tryUnify(LCase, Case.getCaseSuccessor()); LCases.erase(CaseValue); } else if (Complain || !Difference) { if (Complain) -- cgit v1.2.3