<div dir="ltr">This is causing build errors for me: <div><br></div><div><div>/home/kcc/llvm/lib/Support/ErrorHandling.cpp:110:5: error: cast between pointer-to-function and pointer-to-object is an extension [-Werror,-Wpedantic]</div>
<div>    reinterpret_cast<LLVMFatalErrorHandler>(user_data);</div><div>    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</div><div>/home/kcc/llvm/lib/Support/ErrorHandling.cpp:116:27: error: cast between pointer-to-function and pointer-to-object is an extension [-Werror,-Wpedantic]</div>
<div>    bindingsErrorHandler, reinterpret_cast<void*>(Handler));</div><div>                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</div></div><div><br></div><div>Does anyone else see these?<br></div><div><br></div>
<div>My build config is: </div><div><div>cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON \</div><div> -DCMAKE_C_COMPILER=/home/kcc/host_clang/bin/clang \</div><div> -DCMAKE_CXX_COMPILER=/home/kcc/host_clang/bin/clang++ \</div>
<div> -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \</div><div> -DLLVM_ENABLE_WERROR=ON</div></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Oct 17, 2013 at 5:38 AM, Filip Pizlo <span dir="ltr"><<a href="mailto:fpizlo@apple.com" target="_blank">fpizlo@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: fpizlo<br>
Date: Wed Oct 16 20:38:28 2013<br>
New Revision: 192864<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=192864&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=192864&view=rev</a><br>
Log:<br>
Expose install_fatal_error_handler() through the C API.<br>
<br>
I expose the API with some caveats:<br>
<br>
- The C++ API involves a traditional void* opaque pointer for the fatal<br>
error callback.  The C API doesn’t do this.  I don’t think that the void*<br>
opaque pointer makes any sense since this is a global callback - there will<br>
only be one of them.  So if you need to pass some data to your callback,<br>
just put it in a global variable.<br>
<br>
- The bindings will ignore the gen_crash_diag boolean.  I ignore it because<br>
(1) I don’t know what it does, (2) it’s not documented AFAIK, and (3) I<br>
couldn’t imagine any use for it.  I made the gut call that it probably<br>
wasn’t important enough to expose through the C API.<br>
<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm-c/Core.h<br>
    llvm/trunk/lib/Support/ErrorHandling.cpp<br>
<br>
Modified: llvm/trunk/include/llvm-c/Core.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=192864&r1=192863&r2=192864&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=192864&r1=192863&r2=192864&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/include/llvm-c/Core.h (original)<br>
+++ llvm/trunk/include/llvm-c/Core.h Wed Oct 16 20:38:28 2013<br>
@@ -416,6 +416,22 @@ void LLVMShutdown();<br>
 char *LLVMCreateMessage(const char *Message);<br>
 void LLVMDisposeMessage(char *Message);<br>
<br>
+typedef void (*LLVMFatalErrorHandler)(const char *Reason);<br>
+<br>
+/**<br>
+ * Install a fatal error handler. By default, if LLVM detects a fatal error, it<br>
+ * will call exit(1). This may not be appropriate in many contexts. For example,<br>
+ * doing exit(1) will bypass many crash reporting/tracing system tools. This<br>
+ * function allows you to install a callback that will be invoked prior to the<br>
+ * call to exit(1).<br>
+ */<br>
+void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler);<br>
+<br>
+/**<br>
+ * Reset the fatal error handler. This resets LLVM's fatal error handling<br>
+ * behavior to the default.<br>
+ */<br>
+void LLVMResetFatalErrorHandler(void);<br>
<br>
 /**<br>
  * @defgroup LLVMCCoreContext Contexts<br>
<br>
Modified: llvm/trunk/lib/Support/ErrorHandling.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ErrorHandling.cpp?rev=192864&r1=192863&r2=192864&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ErrorHandling.cpp?rev=192864&r1=192863&r2=192864&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/lib/Support/ErrorHandling.cpp (original)<br>
+++ llvm/trunk/lib/Support/ErrorHandling.cpp Wed Oct 16 20:38:28 2013<br>
@@ -20,6 +20,7 @@<br>
 #include "llvm/Support/Signals.h"<br>
 #include "llvm/Support/Threading.h"<br>
 #include "llvm/Support/raw_ostream.h"<br>
+#include "llvm-c/Core.h"<br>
 #include <cassert><br>
 #include <cstdlib><br>
<br>
@@ -102,3 +103,19 @@ void llvm::llvm_unreachable_internal(con<br>
   LLVM_BUILTIN_UNREACHABLE;<br>
 #endif<br>
 }<br>
+<br>
+static void bindingsErrorHandler(void *user_data, const std::string& reason,<br>
+                                 bool gen_crash_diag) {<br>
+  LLVMFatalErrorHandler handler =<br>
+    reinterpret_cast<LLVMFatalErrorHandler>(user_data);<br>
+  handler(reason.c_str());<br>
+}<br>
+<br>
+void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler) {<br>
+  install_fatal_error_handler(<br>
+    bindingsErrorHandler, reinterpret_cast<void*>(Handler));<br>
+}<br>
+<br>
+void LLVMResetFatalErrorHandler() {<br>
+  remove_fatal_error_handler();<br>
+}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>