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
This commit is contained in:
Chris Lattner 2003-11-20 00:09:43 +00:00
parent 8b1daa3e71
commit 4e4d8624c5

View File

@ -750,20 +750,24 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) {
else else
Out << "<badref>"; Out << "<badref>";
} }
if (BB != &BB->getParent()->front()) { // Not the entry block? if (BB->getParent() == 0)
// Output predecessors for the block... Out << "\t\t; Error: Block without parent!";
Out << "\t\t;"; else {
pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB); if (BB != &BB->getParent()->front()) { // Not the entry block?
// Output predecessors for the block...
if (PI == PE) { Out << "\t\t;";
Out << " No predecessors!"; pred_const_iterator PI = pred_begin(BB), PE = pred_end(BB);
} else {
Out << " preds ="; if (PI == PE) {
writeOperand(*PI, false, true); Out << " No predecessors!";
for (++PI; PI != PE; ++PI) { } else {
Out << ","; Out << " preds =";
writeOperand(*PI, false, true); writeOperand(*PI, false, true);
for (++PI; PI != PE; ++PI) {
Out << ",";
writeOperand(*PI, false, true);
}
} }
} }
} }