diff options
author | Chris Lattner <sabre@nondot.org> | 2001-08-23 17:05:59 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-08-23 17:05:59 +0000 |
commit | bd8364aed7f112450622344d81c73ea3f47ec0fb (patch) | |
tree | bc2cc6ffb5a6d7d3d2d97f190435744afb8bc413 | |
parent | 92101acd7fd44fd467fbeb974ae6c042289c74f9 (diff) |
* Add assertions
* Add a nodeVisited method to the DF interator
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/CFG.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/include/llvm/CFG.h b/include/llvm/CFG.h index 05465ea6ac..5228746f34 100644 --- a/include/llvm/CFG.h +++ b/include/llvm/CFG.h @@ -108,9 +108,13 @@ public: typedef SuccIterator<_Term, _BB> _Self; // TODO: This can be random access iterator, need operator+ and stuff tho - inline SuccIterator(_Term T) : Term(T), idx(0) {} // begin iterator - inline SuccIterator(_Term T, bool) - : Term(T), idx(Term->getNumSuccessors()) {} // end iterator + inline SuccIterator(_Term T) : Term(T), idx(0) { // begin iterator + assert(T && "getTerminator returned null!"); + } + inline SuccIterator(_Term T, bool) // end iterator + : Term(T), idx(Term->getNumSuccessors()) { + assert(T && "getTerminator returned null!"); + } inline bool operator==(const _Self& x) const { return idx == x.idx; } inline bool operator!=(const _Self& x) const { return !operator==(x); } @@ -287,6 +291,14 @@ public: inline _Self operator++(int) { // Postincrement _Self tmp = *this; ++*this; return tmp; } + + // nodeVisited - return true if this iterator has already visited the + // specified node. This is public, and will probably be used to iterate over + // nodes that a depth first iteration did not find: ie unreachable nodes. + // + inline bool nodeVisited(NodeType *Node) const { + return Visited.count(Node) != 0; + } }; inline df_iterator df_begin(Method *M, bool Reverse = false) { |