[llvm] r324628 - Use ranged for loops in TypeFinder.cpp, NFC
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 8 10:02:27 PST 2018
Author: vedantk
Date: Thu Feb 8 10:02:27 2018
New Revision: 324628
URL: http://llvm.org/viewvc/llvm-project?rev=324628&view=rev
Log:
Use ranged for loops in TypeFinder.cpp, NFC
Modified:
llvm/trunk/lib/IR/TypeFinder.cpp
Modified: llvm/trunk/lib/IR/TypeFinder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/TypeFinder.cpp?rev=324628&r1=324627&r2=324628&view=diff
==============================================================================
--- llvm/trunk/lib/IR/TypeFinder.cpp (original)
+++ llvm/trunk/lib/IR/TypeFinder.cpp Thu Feb 8 10:02:27 2018
@@ -33,18 +33,16 @@ void TypeFinder::run(const Module &M, bo
OnlyNamed = onlyNamed;
// Get types from global variables.
- for (Module::const_global_iterator I = M.global_begin(),
- E = M.global_end(); I != E; ++I) {
- incorporateType(I->getType());
- if (I->hasInitializer())
- incorporateValue(I->getInitializer());
+ for (const auto &G : M.globals()) {
+ incorporateType(G.getType());
+ if (G.hasInitializer())
+ incorporateValue(G.getInitializer());
}
// Get types from aliases.
- for (Module::const_alias_iterator I = M.alias_begin(),
- E = M.alias_end(); I != E; ++I) {
- incorporateType(I->getType());
- if (const Value *Aliasee = I->getAliasee())
+ for (const auto &A : M.aliases()) {
+ incorporateType(A.getType());
+ if (const Value *Aliasee = A.getAliasee())
incorporateValue(Aliasee);
}
@@ -57,9 +55,8 @@ void TypeFinder::run(const Module &M, bo
incorporateValue(U.get());
// First incorporate the arguments.
- for (Function::const_arg_iterator AI = FI.arg_begin(), AE = FI.arg_end();
- AI != AE; ++AI)
- incorporateValue(&*AI);
+ for (const auto &A : FI.args())
+ incorporateValue(&A);
for (const BasicBlock &BB : FI)
for (const Instruction &I : BB) {
@@ -68,26 +65,21 @@ void TypeFinder::run(const Module &M, bo
// Incorporate non-instruction operand types. (We are incorporating all
// instructions with this loop.)
- for (User::const_op_iterator OI = I.op_begin(), OE = I.op_end();
- OI != OE; ++OI)
- if (*OI && !isa<Instruction>(OI))
- incorporateValue(*OI);
+ for (const auto &O : I.operands())
+ if (&*O && !isa<Instruction>(&*O))
+ incorporateValue(&*O);
// Incorporate types hiding in metadata.
I.getAllMetadataOtherThanDebugLoc(MDForInst);
- for (unsigned i = 0, e = MDForInst.size(); i != e; ++i)
- incorporateMDNode(MDForInst[i].second);
-
+ for (const auto &MD : MDForInst)
+ incorporateMDNode(MD.second);
MDForInst.clear();
}
}
- for (Module::const_named_metadata_iterator I = M.named_metadata_begin(),
- E = M.named_metadata_end(); I != E; ++I) {
- const NamedMDNode *NMD = &*I;
- for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i)
- incorporateMDNode(NMD->getOperand(i));
- }
+ for (const auto &NMD : M.named_metadata())
+ for (const auto &MDOp : NMD.operands())
+ incorporateMDNode(MDOp);
}
void TypeFinder::clear() {
@@ -150,9 +142,8 @@ void TypeFinder::incorporateValue(const
// Look in operands for types.
const User *U = cast<User>(V);
- for (Constant::const_op_iterator I = U->op_begin(),
- E = U->op_end(); I != E;++I)
- incorporateValue(*I);
+ for (const auto &I : U->operands())
+ incorporateValue(&*I);
}
/// incorporateMDNode - This method is used to walk the operands of an MDNode to
@@ -163,8 +154,7 @@ void TypeFinder::incorporateMDNode(const
return;
// Look in operands for types.
- for (unsigned i = 0, e = V->getNumOperands(); i != e; ++i) {
- Metadata *Op = V->getOperand(i);
+ for (Metadata *Op : V->operands()) {
if (!Op)
continue;
if (auto *N = dyn_cast<MDNode>(Op)) {
More information about the llvm-commits
mailing list