How can I find out, in llvm-c API, whether a basic block is well
formed? In C++ I could call getTerminator and test for NULL.
There's not currently a binding for this. In general, there's incomplete support for inspection and analysis through the C bindings.
BasicBlock::getTerminator() is just a convenient way to spell for dyn_cast<Terminator>(*--BB->end()). Adding bindings for isa<> would be the way I'd prefer to approach this, since that would be most broadly useful. But if your only introspection need is for BasicBlock::getTerminator, we could add bindings for that to be expedient.
— Gordon
Hi Seo,
As of http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20081215/071365.html, you can now write in C:
bool HasTerminator(LLVMBasicBlockRef BB) {
return LLVMIsATerminatorInst(LLVMGetLastInstruction(BB));
}
HTH,
Gordon