[RFC] Always using the diagnostic handler in the LLVMContext

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 4 15:31:33 PST 2015


> On Dec 4, 2015, at 2:39 PM, Rafael Espíndola <rafael.espindola at gmail.com> wrote:
> 
> The attached patch converts code that has access to a LLVMContext to
> not take a diagnostic handler.
> 
> This has a few advantages
> 
> * It is easier to use a consistent diagnostic handler in a single program.
> * Less clutter since we are not passing a handler around.

I like it :)

> 
> It also has a few problems:
> 
> * The code that creates the context may be far from the code that
> wants no see the diagnostic and we probably don't want to have a lot
> of places changing the diagnostic handler in flight.

I only see three places where you needed to call setDiagnosticHandler() on the Context, two of them in the C API to support “soon deprecated” API ;) 
and the third one in llvm-link.cpp:main() which seems good the me.

Do you had other places where it was not nice?



> 
> * Some C APIs require us to change the handler. If we go this way, we
> should probably deprecate them and add alternatives where the the
> caller can set the handler in LLVMContext. In particular we would
> deprecate:
> 
>  * Anything that takes a "char **error" and a context.
>  * lto_codegen_set_diagnostic_handler.
> 
> Do you guys think it is worth it (or even desirable?).

Yes.

Thanks for the cleanup!
— 
Mehdi



More information about the llvm-commits mailing list