diff options
Diffstat (limited to 'lib/Transforms/Utils/CloneModule.cpp')
-rw-r--r-- | lib/Transforms/Utils/CloneModule.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp index 4eed60492a7..17e34c4ffa0 100644 --- a/lib/Transforms/Utils/CloneModule.cpp +++ b/lib/Transforms/Utils/CloneModule.cpp @@ -64,12 +64,11 @@ std::unique_ptr<Module> llvm::CloneModule( } // Loop over the functions in the module, making external functions as before - for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) { - Function *NF = - Function::Create(cast<FunctionType>(I->getValueType()), - I->getLinkage(), I->getName(), New.get()); - NF->copyAttributesFrom(&*I); - VMap[&*I] = NF; + for (const Function &I : *M) { + Function *NF = Function::Create(cast<FunctionType>(I.getValueType()), + I.getLinkage(), I.getName(), New.get()); + NF->copyAttributesFrom(&I); + VMap[&I] = NF; } // Loop over the aliases in the module @@ -124,12 +123,12 @@ std::unique_ptr<Module> llvm::CloneModule( // Similarly, copy over function bodies now... // - for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) { - if (I->isDeclaration()) + for (const Function &I : *M) { + if (I.isDeclaration()) continue; - Function *F = cast<Function>(VMap[&*I]); - if (!ShouldCloneDefinition(&*I)) { + Function *F = cast<Function>(VMap[&I]); + if (!ShouldCloneDefinition(&I)) { // Skip after setting the correct linkage for an external reference. F->setLinkage(GlobalValue::ExternalLinkage); // Personality function is not valid on a declaration. @@ -138,17 +137,17 @@ std::unique_ptr<Module> llvm::CloneModule( } Function::arg_iterator DestI = F->arg_begin(); - for (Function::const_arg_iterator J = I->arg_begin(); J != I->arg_end(); + for (Function::const_arg_iterator J = I.arg_begin(); J != I.arg_end(); ++J) { DestI->setName(J->getName()); VMap[&*J] = &*DestI++; } SmallVector<ReturnInst *, 8> Returns; // Ignore returns cloned. - CloneFunctionInto(F, &*I, VMap, /*ModuleLevelChanges=*/true, Returns); + CloneFunctionInto(F, &I, VMap, /*ModuleLevelChanges=*/true, Returns); - if (I->hasPersonalityFn()) - F->setPersonalityFn(MapValue(I->getPersonalityFn(), VMap)); + if (I.hasPersonalityFn()) + F->setPersonalityFn(MapValue(I.getPersonalityFn(), VMap)); } // And aliases |