diff options
author | Chris Lattner <sabre@nondot.org> | 2003-11-20 00:09:43 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-11-20 00:09:43 +0000 |
commit | 4e4d8624c5c44578d64fe1344670520cceec03f2 (patch) | |
tree | 9b8d63b1f5fe6d9b6909a8dceefd41eb47ceed0c | |
parent | 8b1daa3e71109b8ae6a057a1def35ae0ab87ce37 (diff) |
Don't crash if we are printing an orphaned basic block!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10100 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 2c36ed98cb..1823412755 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -750,20 +750,24 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { else Out << "<badref>"; } - - if (BB != &BB->getParent()->front()) { // Not the entry block? - // Output predecessors for the block... - Out << "\t\t;"; - pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB); - - if (PI == PE) { - Out << " No predecessors!"; - } else { - Out << " preds ="; - writeOperand(*PI, false, true); - for (++PI; PI != PE; ++PI) { - Out << ","; + + if (BB->getParent() == 0) + Out << "\t\t; Error: Block without parent!"; + else { + if (BB != &BB->getParent()->front()) { // Not the entry block? + // Output predecessors for the block... + Out << "\t\t;"; + pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB); + + if (PI == PE) { + Out << " No predecessors!"; + } else { + Out << " preds ="; writeOperand(*PI, false, true); + for (++PI; PI != PE; ++PI) { + Out << ","; + writeOperand(*PI, false, true); + } } } } |