macro(SelectInst) \
macro(ShuffleVectorInst) \
macro(StoreInst) \
- macro(TerminatorInst) \
- macro(BranchInst) \
- macro(IndirectBrInst) \
- macro(InvokeInst) \
- macro(ReturnInst) \
- macro(SwitchInst) \
- macro(UnreachableInst) \
- macro(ResumeInst) \
- macro(CleanupReturnInst) \
- macro(CatchReturnInst) \
+ macro(BranchInst) \
+ macro(IndirectBrInst) \
+ macro(InvokeInst) \
+ macro(ReturnInst) \
+ macro(SwitchInst) \
+ macro(UnreachableInst) \
+ macro(ResumeInst) \
+ macro(CleanupReturnInst) \
+ macro(CatchReturnInst) \
macro(FuncletPadInst) \
macro(CatchPadInst) \
macro(CleanupPadInst) \
* If the basic block does not have a terminator (it is not well-formed
* if it doesn't), then NULL is returned.
*
- * The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
+ * The returned LLVMValueRef corresponds to an llvm::Instruction.
*
* @see llvm::BasicBlock::getTerminator()
*/
LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
/**
+ * Determine whether an instruction is a terminator. This routine is named to
+ * be compatible with historical functions that did this by querying the
+ * underlying C++ type.
+ *
+ * @see llvm::Instruction::isTerminator()
+ */
+LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst);
+
+/**
* @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
*
* Functions in this group apply to instructions that refer to call
/**
* @defgroup LLVMCCoreValueInstructionTerminator Terminators
*
- * Functions in this group only apply to instructions that map to
- * llvm::TerminatorInst instances.
+ * Functions in this group only apply to instructions for which
+ * LLVMIsATerminatorInst returns true.
*
* @{
*/
/**
* Return the number of successors that this terminator has.
*
- * @see llvm::TerminatorInst::getNumSuccessors
+ * @see llvm::Instruction::getNumSuccessors
*/
unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
/**
* Return the specified successor.
*
- * @see llvm::TerminatorInst::getSuccessor
+ * @see llvm::Instruction::getSuccessor
*/
LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
/**
* Update the specified successor to point at the provided block.
*
- * @see llvm::TerminatorInst::setSuccessor
+ * @see llvm::Instruction::setSuccessor
*/
void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
return nullptr;
}
+LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst) {
+ Instruction *I = dyn_cast<Instruction>(unwrap(Inst));
+ return (I && I->isTerminator()) ? wrap(I) : nullptr;
+}
+
unsigned LLVMGetNumArgOperands(LLVMValueRef Instr) {
if (FuncletPadInst *FPI = dyn_cast<FuncletPadInst>(unwrap(Instr))) {
return FPI->getNumArgOperands();
/*--.. Operations on terminators ...........................................--*/
unsigned LLVMGetNumSuccessors(LLVMValueRef Term) {
- return unwrap<TerminatorInst>(Term)->getNumSuccessors();
+ return unwrap<Instruction>(Term)->getNumSuccessors();
}
LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i) {
- return wrap(unwrap<TerminatorInst>(Term)->getSuccessor(i));
+ return wrap(unwrap<Instruction>(Term)->getSuccessor(i));
}
void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block) {
- return unwrap<TerminatorInst>(Term)->setSuccessor(i,unwrap(block));
+ return unwrap<Instruction>(Term)->setSuccessor(i, unwrap(block));
}
/*--.. Operations on branch instructions (only) ............................--*/