LLVM and "who does delete"

Hi,

I am new to LLVM, and I am pretty much paranoid about loose pointers. I would like to write a compiler in C++ + boost + llvm, but am worried about the pointers created and passed as parameters, especially about whose responsibility it is of deallocating them (does the LLVM API do it internally, or is it the application programmer's responsibility?). And what is the best practice for dealing with pointers (only new, new + delete, encapsulated reference counting just as boost::shared_ptr, etc.)?

Thank you in advance,

Nabil Stendardo

Most IR objects have their lifetime automatically managed, either because
they belong to the LLVMContext (like constants and metadata) or because
they are logically parented by another IR object to which they belong (e.g.
Instructions belong to a BasicBlock, which belongs to a Function, which
belongs to a Module). So the only parts of the LLVM ABI you need to
manually manage are (1) the LLVMContext, (2) the Module, and
(3) normally-parented IR objects which have been removed from their parent
(or never added to one). (1) and (2) can be easily managed with smart
pointers. (3) is trickier because you have to ensure that there aren't any
extant dependencies on the object you want to delete, so usually you can't
just hand the work off to some smart pointer.

John.