SIL: Ensure all terminators are handled by TermInst::getSuccessors.

Create a separate TERMINATOR xmacro in SILNodes.def that only expands for terminators. Use it in TermInst::getSuccessors to automatically delegate to leaf terminator getSuccessors implementations without requiring additional maintenance work when new terminator instructions are added in the future.

Swift SVN r6869
This commit is contained in:
Joe Groff
2013-08-02 23:26:17 +00:00
parent 893723d82f
commit a851072a25
2 changed files with 26 additions and 20 deletions

View File

@@ -491,16 +491,12 @@ UpcastExistentialInst::UpcastExistentialInst(SILLocation Loc,
TermInst::SuccessorListTy TermInst::getSuccessors() {
assert(isa<TermInst>(this) && "Only TermInsts are allowed");
if (auto I = dyn_cast<UnreachableInst>(this))
return I->getSuccessors();
if (auto I = dyn_cast<ReturnInst>(this))
return I->getSuccessors();
if (auto I = dyn_cast<AutoreleaseReturnInst>(this))
return I->getSuccessors();
if (auto I = dyn_cast<CondBranchInst>(this))
return I->getSuccessors();
return cast<BranchInst>(this)->getSuccessors();
#define TERMINATOR(TYPE, PARENT, EFFECT) \
if (auto I = dyn_cast<TYPE>(this)) \
return I->getSuccessors();
#include "swift/SIL/SILNodes.def"
llvm_unreachable("not a terminator?!");
}
BranchInst::BranchInst(SILLocation Loc,