llvm.org GIT mirror llvm / 598179e
SuccIterator on bbs without terminator insts Remove the assert that triggers if SuccIterator is constructed for a basic block without a terminator instruction. Instead of triggering an assert a succ_end() iterator is returned. This models a basic block with zero successors and allows us to use F->viewCFG() on incompletely constructed functions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134398 91177308-0d34-0410-b5e6-96231b3b80d8 Tobias Grosser 9 years ago
1 changed file(s) with 11 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
108108 // TODO: This can be random access iterator, only operator[] missing.
109109
110110 explicit inline SuccIterator(Term_ T) : Term(T), idx(0) {// begin iterator
111 assert(T && "getTerminator returned null!");
112111 }
113112 inline SuccIterator(Term_ T, bool) // end iterator
114 : Term(T), idx(Term->getNumSuccessors()) {
115 assert(T && "getTerminator returned null!");
113 : Term(T) {
114 if (Term)
115 idx = Term->getNumSuccessors();
116 else
117 // Term == NULL happens, if a basic block is not fully constructed and
118 // consequently getTerminator() returns NULL. In this case we construct a
119 // SuccIterator which describes a basic block that has zero successors.
120 // Defining SuccIterator for incomplete and malformed CFGs is especially
121 // useful for debugging.
122 idx = 0;
116123 }
117124
118125 inline const Self &operator=(const Self &I) {
200207
201208 /// Get the source BB of this iterator.
202209 inline BB_ *getSource() {
210 assert(Term && "Source not available, if basic block was malformed");
203211 return Term->getParent();
204212 }
205213 };