From 7679afda82bb2401fe12f1a5d6c55876cfa8d04c Mon Sep 17 00:00:00 2001 From: Pete Cooper Date: Fri, 24 Jul 2015 21:13:43 +0000 Subject: Use make_range(rbegin(), rend()) to allow foreach loops. NFC. Instead of the pattern for (auto I = x.rbegin(), E = x.end(); I != E; ++I) we can use make_range to construct the reverse range and iterate using that instead. llvm-svn: 243163 --- llvm/lib/Transforms/Scalar/Float2Int.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'llvm/lib/Transforms/Scalar/Float2Int.cpp') diff --git a/llvm/lib/Transforms/Scalar/Float2Int.cpp b/llvm/lib/Transforms/Scalar/Float2Int.cpp index 13e4637..8c1dce1 100644 --- a/llvm/lib/Transforms/Scalar/Float2Int.cpp +++ b/llvm/lib/Transforms/Scalar/Float2Int.cpp @@ -242,11 +242,11 @@ void Float2Int::walkBackwards(const SmallPtrSetImpl &Roots) { // Walk forwards down the list of seen instructions, so we visit defs before // uses. void Float2Int::walkForwards() { - for (auto It = SeenInsts.rbegin(), E = SeenInsts.rend(); It != E; ++It) { - if (It->second != unknownRange()) + for (auto &It : make_range(SeenInsts.rbegin(), SeenInsts.rend())) { + if (It.second != unknownRange()) continue; - Instruction *I = It->first; + Instruction *I = It.first; std::function)> Op; switch (I->getOpcode()) { // FIXME: Handle select and phi nodes. @@ -507,9 +507,8 @@ Value *Float2Int::convert(Instruction *I, Type *ToTy) { // Perform dead code elimination on the instructions we just modified. void Float2Int::cleanup() { - for (auto I = ConvertedInsts.rbegin(), E = ConvertedInsts.rend(); - I != E; ++I) - I->first->eraseFromParent(); + for (auto &I : make_range(ConvertedInsts.rbegin(), ConvertedInsts.rend())) + I.first->eraseFromParent(); } bool Float2Int::runOnFunction(Function &F) { -- cgit v1.1