[llvm] r207336 - [LCG] Eliminate more boiler plate by using the iterator facade base
Chandler Carruth
chandlerc at gmail.com
Sat Apr 26 15:51:32 PDT 2014
Author: chandlerc
Date: Sat Apr 26 17:51:31 2014
New Revision: 207336
URL: http://llvm.org/viewvc/llvm-project?rev=207336&view=rev
Log:
[LCG] Eliminate more boiler plate by using the iterator facade base
class.
Modified:
llvm/trunk/include/llvm/ADT/iterator.h
llvm/trunk/include/llvm/Analysis/LazyCallGraph.h
Modified: llvm/trunk/include/llvm/ADT/iterator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/iterator.h?rev=207336&r1=207335&r2=207336&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/iterator.h (original)
+++ llvm/trunk/include/llvm/ADT/iterator.h Sat Apr 26 17:51:31 2014
@@ -32,7 +32,7 @@ namespace llvm {
/// terms of addition of one. These aren't equivalent for all iterator
/// categories, and respecting that adds a lot of complexity for little gain.
template <typename DerivedT, typename IteratorCategoryT, typename T,
- typename DifferenceTypeT, typename PointerT = T *,
+ typename DifferenceTypeT = ptrdiff_t, typename PointerT = T *,
typename ReferenceT = T &>
struct iterator_facade_base
: std::iterator<IteratorCategoryT, T, DifferenceTypeT, PointerT,
Modified: llvm/trunk/include/llvm/Analysis/LazyCallGraph.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LazyCallGraph.h?rev=207336&r1=207335&r2=207336&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LazyCallGraph.h (original)
+++ llvm/trunk/include/llvm/Analysis/LazyCallGraph.h Sat Apr 26 17:51:31 2014
@@ -228,7 +228,8 @@ public:
/// always visits SCCs for a callee prior to visiting the SCC for a caller
/// (when they are in different SCCs).
class postorder_scc_iterator
- : public std::iterator<std::forward_iterator_tag, SCC> {
+ : public iterator_facade_base<postorder_scc_iterator,
+ std::forward_iterator_tag, SCC> {
friend class LazyCallGraph;
friend class LazyCallGraph::Node;
@@ -251,22 +252,14 @@ public:
bool operator==(const postorder_scc_iterator &Arg) const {
return G == Arg.G && C == Arg.C;
}
- bool operator!=(const postorder_scc_iterator &Arg) const {
- return !operator==(Arg);
- }
reference operator*() const { return *C; }
- pointer operator->() const { return &operator*(); }
+ using iterator_facade_base::operator++;
postorder_scc_iterator &operator++() {
C = G->getNextSCCInPostOrder();
return *this;
}
- postorder_scc_iterator operator++(int) {
- postorder_scc_iterator prev = *this;
- ++*this;
- return prev;
- }
};
/// \brief Construct a graph for the given module.
More information about the llvm-commits
mailing list