[llvm-commits] [PATCH] Improve error handling, supersede cerr+abort

Török Edwin edwintorok at gmail.com
Sun Jun 28 13:55:48 PDT 2009


Hi,

As discussed here is a first implementation of an error handling API for
LLVM.

The attached patch introduces the API, and as an example converts 2
cerr+abort, and a assert(0)+abort to the new API.

The default is to call abort()/exit(1) as till now, but now a client can
install a custom error handler. If the custom handler returns
abort()/exit(1) is still called.
The intention is to also change LLVM to return failure codes instead of
aborting, but as a first incremental improvement I just introduced the
API, and tried
to preserve current behaviour.

Error handlers can be installed by calling llvm_install_error_handler.

cerr+abort should be replaced by llvm_report_fatal_error("Reason"), or
raw_string_ostream + llvm_report_fatal_error(ss.str()) if the error
message is not a simple string.
cerr+exit(1) should be replaced by llvm_report_error("Reason");

There is also a llvm_report_warning(), this could be used for the
warning printed in instcombine:
   cerr << "WARNING: While resolving call to function '"
           << Callee->getName() << "' arguments were dropped!\n";

Please review the patch.

Best regards,
--Edwin



-------------- next part --------------
A non-text attachment was scrubbed...
Name: error_handling.patch
Type: text/x-diff
Size: 8416 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20090628/0fb4ecca/attachment.patch>


More information about the llvm-commits mailing list