mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user