From 2bd48f03ba8d60ce91e91a88d75c4336e3cf5b04 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Tue, 26 Nov 2013 20:55:11 +0000 Subject: [PATCH] [PM] [cleanup] Run clang-format over this file. If fixes many inconsistencies that I'll just need to fix myself as I edit things. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195784 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/SCCIterator.h | 54 ++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/include/llvm/ADT/SCCIterator.h b/include/llvm/ADT/SCCIterator.h index 8089024bf5e..f98cad925c6 100644 --- a/include/llvm/ADT/SCCIterator.h +++ b/include/llvm/ADT/SCCIterator.h @@ -35,13 +35,13 @@ namespace llvm { /// This is implemented using Tarjan's DFS algorithm using an internal stack to /// build up a vector of nodes in a particular SCC. Note that it is a forward /// iterator and thus you cannot backtrack or re-visit nodes. -template > +template > class scc_iterator - : public std::iterator, ptrdiff_t> { - typedef typename GT::NodeType NodeType; + : public std::iterator, ptrdiff_t> { + typedef typename GT::NodeType NodeType; typedef typename GT::ChildIteratorType ChildItTy; - typedef std::vector SccTy; + typedef std::vector SccTy; typedef std::iterator, ptrdiff_t> super; typedef typename super::reference reference; @@ -102,10 +102,11 @@ class scc_iterator // Compute the next SCC using the DFS traversal. void GetNextSCC() { assert(VisitStack.size() == MinVisitNumStack.size()); - CurrentSCC.clear(); // Prepare to compute the next SCC + CurrentSCC.clear(); // Prepare to compute the next SCC while (!VisitStack.empty()) { DFSVisitChildren(); - assert(VisitStack.back().second ==GT::child_end(VisitStack.back().first)); + assert(VisitStack.back().second == + GT::child_end(VisitStack.back().first)); NodeType *visitingN = VisitStack.back().first; unsigned minVisitNum = MinVisitNumStack.back(); VisitStack.pop_back(); @@ -139,13 +140,17 @@ class scc_iterator DFSVisitOne(entryN); GetNextSCC(); } - inline scc_iterator() { /* End is when DFS stack is empty */ } + + // End is when the DFS stack is empty. + inline scc_iterator() {} public: typedef scc_iterator _Self; - static inline _Self begin(const GraphT &G){return _Self(GT::getEntryNode(G));} - static inline _Self end (const GraphT &) { return _Self(); } + static inline _Self begin(const GraphT &G) { + return _Self(GT::getEntryNode(G)); + } + static inline _Self end(const GraphT &) { return _Self(); } /// \brief Direct loop termination test which is more efficient than /// comparison with \c end(). @@ -154,17 +159,19 @@ public: return CurrentSCC.empty(); } - inline bool operator==(const _Self& x) const { + inline bool operator==(const _Self &x) const { return VisitStack == x.VisitStack && CurrentSCC == x.CurrentSCC; } - inline bool operator!=(const _Self& x) const { return !operator==(x); } + inline bool operator!=(const _Self &x) const { return !operator==(x); } - inline _Self& operator++() { + inline _Self &operator++() { GetNextSCC(); return *this; } inline _Self operator++(int) { - _Self tmp = *this; ++*this; return tmp; + _Self tmp = *this; + ++*this; + return tmp; } inline const SccTy &operator*() const { @@ -182,9 +189,11 @@ public: /// still contain a loop if the node has an edge back to itself. bool hasLoop() const { assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!"); - if (CurrentSCC.size() > 1) return true; + if (CurrentSCC.size() > 1) + return true; NodeType *N = CurrentSCC.front(); - for (ChildItTy CI = GT::child_begin(N), CE=GT::child_end(N); CI != CE; ++CI) + for (ChildItTy CI = GT::child_begin(N), CE = GT::child_end(N); CI != CE; + ++CI) if (*CI == N) return true; return false; @@ -199,28 +208,23 @@ public: } }; - /// \brief Construct the begin iterator for a deduced graph type T. -template -scc_iterator scc_begin(const T &G) { +template scc_iterator scc_begin(const T &G) { return scc_iterator::begin(G); } /// \brief Construct the end iterator for a deduced graph type T. -template -scc_iterator scc_end(const T &G) { +template scc_iterator scc_end(const T &G) { return scc_iterator::end(G); } /// \brief Construct the begin iterator for a deduced graph type T's Inverse. -template -scc_iterator > scc_begin(const Inverse &G) { +template scc_iterator > scc_begin(const Inverse &G) { return scc_iterator >::begin(G); } /// \brief Construct the end iterator for a deduced graph type T's Inverse. -template -scc_iterator > scc_end(const Inverse &G) { +template scc_iterator > scc_end(const Inverse &G) { return scc_iterator >::end(G); }