diff options
author | Kazu Hirata <kazu@google.com> | 2021-02-07 09:49:36 -0800 |
---|---|---|
committer | Kazu Hirata <kazu@google.com> | 2021-02-07 09:49:36 -0800 |
commit | be23012d5a84fefdb6d0a267f9ffb4bafb4804d7 (patch) | |
tree | 286d9b13a8c93c76ae9566fd8e81380116f9c358 /llvm/lib/Transforms/Utils/CloneModule.cpp | |
parent | 92a6055835e26254429b5c1bfc889ab1bb711d1d (diff) | |
download | llvm-be23012d5a84fefdb6d0a267f9ffb4bafb4804d7.zip llvm-be23012d5a84fefdb6d0a267f9ffb4bafb4804d7.tar.gz llvm-be23012d5a84fefdb6d0a267f9ffb4bafb4804d7.tar.bz2 |
[Transforms/Utils] Use range-based for loops (NFC)
Diffstat (limited to 'llvm/lib/Transforms/Utils/CloneModule.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/CloneModule.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneModule.cpp b/llvm/lib/Transforms/Utils/CloneModule.cpp index a6327bb..6de679b 100644 --- a/llvm/lib/Transforms/Utils/CloneModule.cpp +++ b/llvm/lib/Transforms/Utils/CloneModule.cpp @@ -115,28 +115,27 @@ std::unique_ptr<Module> llvm::CloneModule( // have been created, loop through and copy the global variable referrers // over... We also set the attributes on the global now. // - for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); - I != E; ++I) { - GlobalVariable *GV = cast<GlobalVariable>(VMap[&*I]); + for (const GlobalVariable &G : M.globals()) { + GlobalVariable *GV = cast<GlobalVariable>(VMap[&G]); SmallVector<std::pair<unsigned, MDNode *>, 1> MDs; - I->getAllMetadata(MDs); + G.getAllMetadata(MDs); for (auto MD : MDs) GV->addMetadata(MD.first, *MapMetadata(MD.second, VMap, RF_MoveDistinctMDs)); - if (I->isDeclaration()) + if (G.isDeclaration()) continue; - if (!ShouldCloneDefinition(&*I)) { + if (!ShouldCloneDefinition(&G)) { // Skip after setting the correct linkage for an external reference. GV->setLinkage(GlobalValue::ExternalLinkage); continue; } - if (I->hasInitializer()) - GV->setInitializer(MapValue(I->getInitializer(), VMap)); + if (G.hasInitializer()) + GV->setInitializer(MapValue(G.getInitializer(), VMap)); - copyComdat(GV, &*I); + copyComdat(GV, &G); } // Similarly, copy over function bodies now... |