From aa2091505f6de0ababf8a6ec54e8a26c8b0be2be Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 26 Jun 2016 17:27:42 +0000 Subject: Apply clang-tidy's modernize-loop-convert to lib/Analysis. Only minor manual fixes. No functionality change intended. llvm-svn: 273816 --- llvm/lib/Analysis/CallGraph.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'llvm/lib/Analysis/CallGraph.cpp') diff --git a/llvm/lib/Analysis/CallGraph.cpp b/llvm/lib/Analysis/CallGraph.cpp index 7d9252f746d..39cb86d2ccb 100644 --- a/llvm/lib/Analysis/CallGraph.cpp +++ b/llvm/lib/Analysis/CallGraph.cpp @@ -80,11 +80,9 @@ void CallGraph::addToCallGraph(Function *F) { Node->addCalledFunction(CallSite(), CallsExternalNode.get()); // Look for calls by this function. - for (Function::iterator BB = F->begin(), BBE = F->end(); BB != BBE; ++BB) - for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE; - ++II) { - CallSite CS(cast(II)); - if (CS) { + for (BasicBlock &BB : *F) + for (Instruction &I : BB) { + if (auto CS = CallSite(&I)) { const Function *Callee = CS.getCalledFunction(); if (!Callee || !Intrinsic::isLeaf(Callee->getIntrinsicID())) // Indirect calls of intrinsics are not allowed so no need to check. @@ -111,8 +109,8 @@ void CallGraph::print(raw_ostream &OS) const { SmallVector Nodes; Nodes.reserve(FunctionMap.size()); - for (auto I = begin(), E = end(); I != E; ++I) - Nodes.push_back(I->second.get()); + for (const auto &I : *this) + Nodes.push_back(I.second.get()); std::sort(Nodes.begin(), Nodes.end(), [](CallGraphNode *LHS, CallGraphNode *RHS) { @@ -186,9 +184,9 @@ void CallGraphNode::print(raw_ostream &OS) const { OS << "<<" << this << ">> #uses=" << getNumReferences() << '\n'; - for (const_iterator I = begin(), E = end(); I != E; ++I) { - OS << " CS<" << I->first << "> calls "; - if (Function *FI = I->second->getFunction()) + for (const auto &I : *this) { + OS << " CS<" << I.first << "> calls "; + if (Function *FI = I.second->getFunction()) OS << "function '" << FI->getName() <<"'\n"; else OS << "external node\n"; -- cgit v1.2.3