aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/CloneModule.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2016-06-26 12:28:59 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2016-06-26 12:28:59 +0000
commit135f735af149e305635ba3886065b493d5c2bf8c (patch)
treeefc8ab49d69279615e3d0a3563a7d05354270bf5 /llvm/lib/Transforms/Utils/CloneModule.cpp
parentff976c99c79d7a00f1c836a57c3e7499316553c4 (diff)
downloadllvm-135f735af149e305635ba3886065b493d5c2bf8c.zip
llvm-135f735af149e305635ba3886065b493d5c2bf8c.tar.gz
llvm-135f735af149e305635ba3886065b493d5c2bf8c.tar.bz2
Apply clang-tidy's modernize-loop-convert to most of lib/Transforms.
Only minor manual fixes. No functionality change intended. llvm-svn: 273808
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneModule.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/CloneModule.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp
index 4eed604..17e34c4 100644
--- a/llvm/lib/Transforms/Utils/CloneModule.cpp
+++ b/llvm/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