]> granicus.if.org Git - clang/commitdiff
Use std::find_if instead of manual loop.
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 29 Dec 2014 22:39:45 +0000 (22:39 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 29 Dec 2014 22:39:45 +0000 (22:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224960 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGVTables.cpp

index 48a93ba65d207e245d0aa03fa12d966c9917e725..1aff346978216591e728498a7d576085c7fc15b7 100644 (file)
@@ -159,14 +159,10 @@ void CodeGenFunction::GenerateVarArgsThunk(
   // with "this".
   llvm::Value *ThisPtr = &*AI;
   llvm::BasicBlock *EntryBB = Fn->begin();
-  llvm::Instruction *ThisStore = nullptr;
-  for (llvm::BasicBlock::iterator I = EntryBB->begin(), E = EntryBB->end();
-       I != E; I++) {
-    if (isa<llvm::StoreInst>(I) && I->getOperand(0) == ThisPtr) {
-      ThisStore = cast<llvm::StoreInst>(I);
-      break;
-    }
-  }
+  llvm::Instruction *ThisStore =
+      std::find_if(EntryBB->begin(), EntryBB->end(), [&](llvm::Instruction &I) {
+    return isa<llvm::StoreInst>(I) && I.getOperand(0) == ThisPtr;
+  });
   assert(ThisStore && "Store of this should be in entry block?");
   // Adjust "this", if necessary.
   Builder.SetInsertPoint(ThisStore);