[Question] about TerminatorInst

Under what circumstances will a TerminatorInst will have multiple successors?

The three methods:

virtual BasicBlock *getSuccessorV(unsigned idx) const = 0;
virtual unsigned getNumSuccessorsV() const = 0;
virtual void setSuccessorV(unsigned idx, BasicBlock *B) = 0;

are defined for the TerminatorInst class, but I cannot see why a terminator is allowed to go to different targets.

Thanks,
Jeff Kunkel

A conditional branch goes to two different basic blocks based on whether the condition is true/false. Switch can go to any number of different destinations.

-Chris

Conditional branches have two targets. Indirect branches presumably
have as many as there are blocks in the function whose addresses are
taken.

Reid

Hi Jeff,

Under what circumstances will a TerminatorInst will have multiple successors?

for example when it is a condition branch (two successors), an invoke (also two
successors) or a switch (maybe many successors).

Ciao,

Duncan.

Thank you for the quick response.