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
/// 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.
/// 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<class GraphT, class GT = GraphTraits<GraphT> >
+template <class GraphT, class GT = GraphTraits<GraphT> >
- : public std::iterator<std::forward_iterator_tag,
- std::vector<typename GT::NodeType>, ptrdiff_t> {
- typedef typename GT::NodeType NodeType;
+ : public std::iterator<std::forward_iterator_tag,
+ std::vector<typename GT::NodeType>, ptrdiff_t> {
+ typedef typename GT::NodeType NodeType;
typedef typename GT::ChildIteratorType ChildItTy;
typedef typename GT::ChildIteratorType ChildItTy;
- typedef std::vector<NodeType*> SccTy;
+ typedef std::vector<NodeType *> SccTy;
typedef std::iterator<std::forward_iterator_tag,
std::vector<typename GT::NodeType>, ptrdiff_t> super;
typedef typename super::reference reference;
typedef std::iterator<std::forward_iterator_tag,
std::vector<typename GT::NodeType>, ptrdiff_t> super;
typedef typename super::reference reference;
// Compute the next SCC using the DFS traversal.
void GetNextSCC() {
assert(VisitStack.size() == MinVisitNumStack.size());
// 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();
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();
NodeType *visitingN = VisitStack.back().first;
unsigned minVisitNum = MinVisitNumStack.back();
VisitStack.pop_back();
DFSVisitOne(entryN);
GetNextSCC();
}
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<GraphT, GT> _Self;
public:
typedef scc_iterator<GraphT, GT> _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().
/// \brief Direct loop termination test which is more efficient than
/// comparison with \c end().
return CurrentSCC.empty();
}
return CurrentSCC.empty();
}
- inline bool operator==(const _Self& x) const {
+ inline bool operator==(const _Self &x) const {
return VisitStack == x.VisitStack && CurrentSCC == x.CurrentSCC;
}
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) {
GetNextSCC();
return *this;
}
inline _Self operator++(int) {
- _Self tmp = *this; ++*this; return tmp;
+ _Self tmp = *this;
+ ++*this;
+ return tmp;
}
inline const SccTy &operator*() const {
}
inline const SccTy &operator*() const {
/// still contain a loop if the node has an edge back to itself.
bool hasLoop() const {
assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!");
/// 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();
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;
if (*CI == N)
return true;
return false;
/// \brief Construct the begin iterator for a deduced graph type T.
/// \brief Construct the begin iterator for a deduced graph type T.
-template <class T>
-scc_iterator<T> scc_begin(const T &G) {
+template <class T> scc_iterator<T> scc_begin(const T &G) {
return scc_iterator<T>::begin(G);
}
/// \brief Construct the end iterator for a deduced graph type T.
return scc_iterator<T>::begin(G);
}
/// \brief Construct the end iterator for a deduced graph type T.
-template <class T>
-scc_iterator<T> scc_end(const T &G) {
+template <class T> scc_iterator<T> scc_end(const T &G) {
return scc_iterator<T>::end(G);
}
/// \brief Construct the begin iterator for a deduced graph type T's Inverse<T>.
return scc_iterator<T>::end(G);
}
/// \brief Construct the begin iterator for a deduced graph type T's Inverse<T>.
-template <class T>
-scc_iterator<Inverse<T> > scc_begin(const Inverse<T> &G) {
+template <class T> scc_iterator<Inverse<T> > scc_begin(const Inverse<T> &G) {
return scc_iterator<Inverse<T> >::begin(G);
}
/// \brief Construct the end iterator for a deduced graph type T's Inverse<T>.
return scc_iterator<Inverse<T> >::begin(G);
}
/// \brief Construct the end iterator for a deduced graph type T's Inverse<T>.
-template <class T>
-scc_iterator<Inverse<T> > scc_end(const Inverse<T> &G) {
+template <class T> scc_iterator<Inverse<T> > scc_end(const Inverse<T> &G) {
return scc_iterator<Inverse<T> >::end(G);
}
return scc_iterator<Inverse<T> >::end(G);
}