summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Instruction.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2014-03-10 15:03:06 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2014-03-10 15:03:06 +0000
commit3ad5c96268db965191ec71cdcb6d8884f6fca99c (patch)
treefe813004837e99b1a2bdad22ab235a00530835dd /llvm/lib/IR/Instruction.cpp
parent059e4b158c272fbd15ba80f9b47ade2f2905d6e5 (diff)
downloadbcm5719-llvm-3ad5c96268db965191ec71cdcb6d8884f6fca99c.tar.gz
bcm5719-llvm-3ad5c96268db965191ec71cdcb6d8884f6fca99c.zip
[C++11] Modernize the IR library a bit.
No functionality change. llvm-svn: 203465
Diffstat (limited to 'llvm/lib/IR/Instruction.cpp')
-rw-r--r--llvm/lib/IR/Instruction.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index 67aa8b28183..bd7a62e83d9 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -281,9 +281,8 @@ bool Instruction::isIdenticalToWhenDefined(const Instruction *I) const {
// We have two instructions of identical opcode and #operands. Check to see
// if all operands are the same.
- for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
- if (getOperand(i) != I->getOperand(i))
- return false;
+ if (!std::equal(op_begin(), op_end(), I->op_begin()))
+ return false;
// Check special state that is a part of some instructions.
if (const LoadInst *LI = dyn_cast<LoadInst>(this))
@@ -323,11 +322,8 @@ bool Instruction::isIdenticalToWhenDefined(const Instruction *I) const {
RMWI->getSynchScope() == cast<AtomicRMWInst>(I)->getSynchScope();
if (const PHINode *thisPHI = dyn_cast<PHINode>(this)) {
const PHINode *otherPHI = cast<PHINode>(I);
- for (unsigned i = 0, e = thisPHI->getNumOperands(); i != e; ++i) {
- if (thisPHI->getIncomingBlock(i) != otherPHI->getIncomingBlock(i))
- return false;
- }
- return true;
+ return std::equal(thisPHI->block_begin(), thisPHI->block_end(),
+ otherPHI->block_begin());
}
return true;
}
@@ -552,8 +548,8 @@ Instruction *Instruction::clone() const {
// new one.
SmallVector<std::pair<unsigned, MDNode*>, 4> TheMDs;
getAllMetadataOtherThanDebugLoc(TheMDs);
- for (unsigned i = 0, e = TheMDs.size(); i != e; ++i)
- New->setMetadata(TheMDs[i].first, TheMDs[i].second);
+ for (const auto &MD : TheMDs)
+ New->setMetadata(MD.first, MD.second);
New->setDebugLoc(getDebugLoc());
return New;
OpenPOWER on IntegriCloud