Detect exception throwing in basic blocks


For code:

try {
throw 42;
} catch(int e){}

Are there any helpers in LLVM API to give me info that in “try block” there is a throw which will be executed? I am interested in info “yes, this block throws”.

Thank you

In LLVM IR, you would see an invoke instruction that calls the appropriate C++ runtime function to set up a C++ exception. It would be __cxa_throw or CxxThrowException on Windows.

Since only function calls can throw, this is not a property of the basic block, but a property of individual call instructions.