[LLVMdev] llvm-c bindings and exceptions?

Chris Lattner clattner at apple.com
Tue Aug 5 14:17:36 PDT 2008


On Aug 3, 2008, at 10:01 PM, Mahadevan R wrote:

> Hi,
>
> On Sun, Aug 3, 2008 at 11:42 PM, Chris Lattner <clattner at apple.com>  
> wrote:
>>
>> On Aug 3, 2008, at 7:54 AM, Mahadevan R wrote:
>>
>>> Hi,
>>>
>>> Just wondering -- shouldn't all (C linkage) functions exposed by
>>> LLVM-C (and written in C++) be catching std::exception (or "...") to
>>> prevent exceptions being passed on to C callers?
>>
>> LLVM doesn't use exceptions in anything that has C bindings, so the
>> catch isn't needed.
>
> It does use 'new' (e.g. LLVMCreateModuleProviderForExistingModule),
> and also calls C++ functions which in turn use new (e.g.
> LLVMGetBitcodeModuleProvider -> llvm::getBitcodeModuleProvider), so
> std::bad_alloc is a possibility (a quick search didn't turn up any
> "set_new_handler" also).

The C++ code is compiled with -fno-exceptions, so bad_alloc won't work  
anyway.

-Chris




More information about the llvm-dev mailing list