aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-23 04:22:38 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-04-23 04:22:38 +0000
commitd9bbdce7159d2c5dc123292b155aca53535e190d (patch)
treee8631ba67266d209c71ebc2ea73df138ea176752 /llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
parent4b1bc647f05341a959c6f6a433791d4ce62e7de4 (diff)
downloadllvm-d9bbdce7159d2c5dc123292b155aca53535e190d.zip
llvm-d9bbdce7159d2c5dc123292b155aca53535e190d.tar.gz
llvm-d9bbdce7159d2c5dc123292b155aca53535e190d.tar.bz2
ValueEnumerator: Use std::find_if, NFC
Mehdi's pattern recognition pulled this one out. This is cleaner with std::find_if than with the strange helper function that took an iterator by reference and updated it. llvm-svn: 267271
Diffstat (limited to 'llvm/lib/Bitcode/Writer/ValueEnumerator.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/ValueEnumerator.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
index 068bf62..4de0d26 100644
--- a/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
+++ b/llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
@@ -575,11 +575,15 @@ void ValueEnumerator::EnumerateMetadata(unsigned F, const Metadata *MD) {
while (!Worklist.empty()) {
const MDNode *N = Worklist.back().first;
- MDNode::op_iterator &I = Worklist.back().second;
- // Enumerate operands until the worklist changes. We need to traverse new
- // nodes before visiting the rest of N's operands.
- if (const MDNode *Op = enumerateMetadataOperands(F, I, N->op_end())) {
+ // Enumerate operands until we hit a new node. We need to traverse these
+ // nodes' operands before visiting the rest of N's operands.
+ MDNode::op_iterator I = std::find_if(
+ Worklist.back().second, N->op_end(),
+ [&](const Metadata *MD) { return enumerateMetadataImpl(F, MD); });
+ if (I != N->op_end()) {
+ auto *Op = cast<MDNode>(*I);
+ Worklist.back().second = ++I;
Worklist.push_back(std::make_pair(Op, Op->op_begin()));
continue;
}
@@ -591,15 +595,6 @@ void ValueEnumerator::EnumerateMetadata(unsigned F, const Metadata *MD) {
}
}
-const MDNode *
-ValueEnumerator::enumerateMetadataOperands(unsigned F, MDNode::op_iterator &I,
- MDNode::op_iterator E) {
- while (I != E)
- if (const MDNode *N = enumerateMetadataImpl(F, *I++)) // Always increment I.
- return N;
- return nullptr;
-}
-
const MDNode *ValueEnumerator::enumerateMetadataImpl(unsigned F, const Metadata *MD) {
if (!MD)
return nullptr;