[PATCH] D131320: [llvm] Remove uses of deprecated `std::iterator`
Markus Böck via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 6 04:30:14 PDT 2022
zero9178 updated this revision to Diff 450512.
zero9178 added a comment.
Fix typo; Rerun CI
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131320/new/
https://reviews.llvm.org/D131320
Files:
llvm/include/llvm/Transforms/IPO/SampleContextTracker.h
llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.h
llvm/unittests/ADT/IteratorTest.cpp
Index: llvm/unittests/ADT/IteratorTest.cpp
===================================================================
--- llvm/unittests/ADT/IteratorTest.cpp
+++ llvm/unittests/ADT/IteratorTest.cpp
@@ -19,8 +19,9 @@
template <int> struct Shadow;
-struct WeirdIter : std::iterator<std::input_iterator_tag, Shadow<0>, Shadow<1>,
- Shadow<2>, Shadow<3>> {};
+struct WeirdIter
+ : llvm::iterator_facade_base<WeirdIter, std::input_iterator_tag, Shadow<0>,
+ Shadow<1>, Shadow<2>, Shadow<3>> {};
struct AdaptedIter : iterator_adaptor_base<AdaptedIter, WeirdIter> {};
Index: llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.h
===================================================================
--- llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.h
+++ llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCInstrInfo.h
@@ -15,6 +15,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/MC/MCInst.h"
#include "llvm/Support/MathExtras.h"
@@ -41,8 +42,9 @@
namespace Hexagon {
-class PacketIterator : public std::iterator<std::forward_iterator_tag,
- PacketIterator> {
+class PacketIterator
+ : public llvm::iterator_facade_base<
+ PacketIterator, std::forward_iterator_tag, const MCInst> {
MCInstrInfo const &MCII;
MCInst::const_iterator BundleCurrent;
MCInst::const_iterator BundleEnd;
@@ -56,9 +58,6 @@
PacketIterator &operator++();
MCInst const &operator*() const;
bool operator==(PacketIterator const &Other) const;
- bool operator!=(PacketIterator const &Other) const {
- return !(*this == Other);
- }
};
} // end namespace Hexagon
Index: llvm/include/llvm/Transforms/IPO/SampleContextTracker.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/SampleContextTracker.h
+++ llvm/include/llvm/Transforms/IPO/SampleContextTracker.h
@@ -17,6 +17,7 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator.h"
#include "llvm/ProfileData/SampleProf.h"
#include <map>
#include <queue>
@@ -143,8 +144,9 @@
return FuncToCtxtProfiles;
}
- class Iterator : public std::iterator<std::forward_iterator_tag,
- const ContextTrieNode *> {
+ class Iterator : public llvm::iterator_facade_base<
+ Iterator, std::forward_iterator_tag, ContextTrieNode *,
+ std::ptrdiff_t, ContextTrieNode **, ContextTrieNode *> {
std::queue<ContextTrieNode *> NodeQueue;
public:
@@ -159,12 +161,6 @@
return *this;
}
- Iterator operator++(int) {
- assert(!NodeQueue.empty() && "Iterator already at the end");
- Iterator Ret = *this;
- ++(*this);
- return Ret;
- }
bool operator==(const Iterator &Other) const {
if (NodeQueue.empty() && Other.NodeQueue.empty())
return true;
@@ -172,7 +168,7 @@
return false;
return NodeQueue.front() == Other.NodeQueue.front();
}
- bool operator!=(const Iterator &Other) const { return !(*this == Other); }
+
ContextTrieNode *operator*() const {
assert(!NodeQueue.empty() && "Invalid access to end iterator");
return NodeQueue.front();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131320.450512.patch
Type: text/x-patch
Size: 3367 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220806/9941f5b6/attachment.bin>
More information about the llvm-commits
mailing list