Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLVM exception throwing

Tags:

exception

llvm

I have read this blog post, this documentation page and this example, but I still don't understand how to throw a basic exception using the LLVM's IRBuilder for a non-C++ oriented language.

From my understanding, I have to :

  • Create a llvm::Value containing the throwed value.
  • Call "a function", passing it the throwed value. This function will not return.

The example is using a system rewinding function (_Unwind_RaiseException) in order to throw a C++ exception, and I don't really understand how to use my own raising function instead (since I only need to throw an object pointer). What am I missing ?

like image 992
Maël Nison Avatar asked Feb 12 '13 03:02

Maël Nison


1 Answers

Short answer is that _Unwind_RaiseException is not a C++-specific function. It comes from the libunwind library, and allows to throw any type of exception.

More details can be found on these blog posts.

like image 62
Maël Nison Avatar answered Oct 04 '22 16:10

Maël Nison