diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2011-07-04 23:09:02 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2011-07-04 23:09:02 +0000 |
commit | 598179ee2f5a31d4b2d3932963a3714ab235ec2e (patch) | |
tree | 2cebce09d62bba08b26572e699f1808e71b9ff20 | |
parent | fc87cdc1f4df357167a7cef91af92b5012934124 (diff) |
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
-rw-r--r-- | include/llvm/Support/CFG.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/include/llvm/Support/CFG.h b/include/llvm/Support/CFG.h index 7e193ff15e..29313ef900 100644 --- a/include/llvm/Support/CFG.h +++ b/include/llvm/Support/CFG.h @@ -109,11 +109,18 @@ public: // TODO: This can be random access iterator, only operator[] missing. explicit 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!"); + : Term(T) { + if (Term) + idx = Term->getNumSuccessors(); + else + // Term == NULL happens, if a basic block is not fully constructed and + // consequently getTerminator() returns NULL. In this case we construct a + // SuccIterator which describes a basic block that has zero successors. + // Defining SuccIterator for incomplete and malformed CFGs is especially + // useful for debugging. + idx = 0; } inline const Self &operator=(const Self &I) { @@ -201,6 +208,7 @@ public: /// Get the source BB of this iterator. inline BB_ *getSource() { + assert(Term && "Source not available, if basic block was malformed"); return Term->getParent(); } }; |