From 3ad5c96268db965191ec71cdcb6d8884f6fca99c Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 10 Mar 2014 15:03:06 +0000 Subject: [C++11] Modernize the IR library a bit. No functionality change. llvm-svn: 203465 --- llvm/lib/IR/Metadata.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'llvm/lib/IR/Metadata.cpp') diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index c6107f5d804..ba393345db8 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -224,8 +224,8 @@ MDNode *MDNode::getMDNode(LLVMContext &Context, ArrayRef Vals, // Note that if the operands are later nulled out, the node will be // removed from the uniquing map. FoldingSetNodeID ID; - for (unsigned i = 0; i != Vals.size(); ++i) - ID.AddPointer(Vals[i]); + for (Value *V : Vals) + ID.AddPointer(V); void *InsertPoint; MDNode *N = pImpl->MDNodeSet.FindNodeOrInsertPos(ID, InsertPoint); @@ -236,8 +236,7 @@ MDNode *MDNode::getMDNode(LLVMContext &Context, ArrayRef Vals, bool isFunctionLocal = false; switch (FL) { case FL_Unknown: - for (unsigned i = 0; i != Vals.size(); ++i) { - Value *V = Vals[i]; + for (Value *V : Vals) { if (!V) continue; if (isFunctionLocalValue(V)) { isFunctionLocal = true; @@ -649,9 +648,9 @@ void Instruction::setMetadata(unsigned KindID, MDNode *Node) { setHasMetadataHashEntry(true); } else { // Handle replacement of an existing value. - for (unsigned i = 0, e = Info.size(); i != e; ++i) - if (Info[i].first == KindID) { - Info[i].second = Node; + for (auto &P : Info) + if (P.first == KindID) { + P.second = Node; return; } } @@ -697,10 +696,9 @@ MDNode *Instruction::getMetadataImpl(unsigned KindID) const { LLVMContextImpl::MDMapTy &Info = getContext().pImpl->MetadataStore[this]; assert(!Info.empty() && "bit out of sync with hash table"); - for (LLVMContextImpl::MDMapTy::iterator I = Info.begin(), E = Info.end(); - I != E; ++I) - if (I->first == KindID) - return I->second; + for (const auto &I : Info) + if (I.first == KindID) + return I.second; return 0; } -- cgit v1.2.3