diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-08 19:30:17 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-05-08 19:30:17 +0000 |
commit | 82cb28e99a19be95356b7e4bad9f5fd551c8cb39 (patch) | |
tree | 20f3de5898cd3bdd7ee929bcc52729ae40af1c65 /tools/llvm-extract | |
parent | 8115f93cdbb4e6ff0ee1f68cf0204b0e6e118662 (diff) | |
download | llvm-82cb28e99a19be95356b7e4bad9f5fd551c8cb39.tar.gz llvm-82cb28e99a19be95356b7e4bad9f5fd551c8cb39.tar.bz2 llvm-82cb28e99a19be95356b7e4bad9f5fd551c8cb39.tar.xz |
Use range loops.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208353 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-extract')
-rw-r--r-- | tools/llvm-extract/llvm-extract.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/tools/llvm-extract/llvm-extract.cpp b/tools/llvm-extract/llvm-extract.cpp index 769f82a057..0f7086802a 100644 --- a/tools/llvm-extract/llvm-extract.cpp +++ b/tools/llvm-extract/llvm-extract.cpp @@ -166,10 +166,9 @@ int main(int argc, char **argv) { "invalid regex: " << Error; } bool match = false; - for (Module::global_iterator GV = M->global_begin(), - E = M->global_end(); GV != E; GV++) { - if (RegEx.match(GV->getName())) { - GVs.insert(&*GV); + for (auto &GV : M->globals()) { + if (RegEx.match(GV.getName())) { + GVs.insert(&GV); match = true; } } @@ -229,22 +228,19 @@ int main(int argc, char **argv) { else { // Deleting. Materialize every GV that's *not* in GVs. SmallPtrSet<GlobalValue *, 8> GVSet(GVs.begin(), GVs.end()); - for (Module::global_iterator I = M->global_begin(), E = M->global_end(); - I != E; ++I) { - GlobalVariable *G = I; - if (!GVSet.count(G) && G->isMaterializable()) { + for (auto &G : M->globals()) { + if (!GVSet.count(&G) && G.isMaterializable()) { std::string ErrInfo; - if (G->Materialize(&ErrInfo)) { + if (G.Materialize(&ErrInfo)) { errs() << argv[0] << ": error reading input: " << ErrInfo << "\n"; return 1; } } } - for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) { - Function *F = I; - if (!GVSet.count(F) && F->isMaterializable()) { + for (auto &F : *M) { + if (!GVSet.count(&F) && F.isMaterializable()) { std::string ErrInfo; - if (F->Materialize(&ErrInfo)) { + if (F.Materialize(&ErrInfo)) { errs() << argv[0] << ": error reading input: " << ErrInfo << "\n"; return 1; } |