llvm-c bindings and exceptions?

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?

[OT: Does clang warn about throw statements from within "extern C" functions?]

Thanks & Regards,
-Mahadevan.

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.

[OT: Does clang warn about throw statements from within "extern C" functions?]

Not yet,

-Chris

Hi,

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).

There might also be C++ client code (e.g. overridden virtual functions
in custom passes) which might (unintentionally) throw exceptions.

Regards,
-Mahadevan.

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

-Chris