ErrorHandling.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. /*===-- llvm-c/ErrorHandling.h - Error Handling C Interface -------*- C -*-===*\
  7. |* *|
  8. |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
  9. |* Exceptions. *|
  10. |* See https://llvm.org/LICENSE.txt for license information. *|
  11. |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
  12. |* *|
  13. |*===----------------------------------------------------------------------===*|
  14. |* *|
  15. |* This file defines the C interface to LLVM's error handling mechanism. *|
  16. |* *|
  17. \*===----------------------------------------------------------------------===*/
  18. #ifndef LLVM_C_ERRORHANDLING_H
  19. #define LLVM_C_ERRORHANDLING_H
  20. #include "llvm-c/ExternC.h"
  21. LLVM_C_EXTERN_C_BEGIN
  22. /**
  23. * @addtogroup LLVMCError
  24. *
  25. * @{
  26. */
  27. typedef void (*LLVMFatalErrorHandler)(const char *Reason);
  28. /**
  29. * Install a fatal error handler. By default, if LLVM detects a fatal error, it
  30. * will call exit(1). This may not be appropriate in many contexts. For example,
  31. * doing exit(1) will bypass many crash reporting/tracing system tools. This
  32. * function allows you to install a callback that will be invoked prior to the
  33. * call to exit(1).
  34. */
  35. void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler);
  36. /**
  37. * Reset the fatal error handler. This resets LLVM's fatal error handling
  38. * behavior to the default.
  39. */
  40. void LLVMResetFatalErrorHandler(void);
  41. /**
  42. * Enable LLVM's built-in stack trace code. This intercepts the OS's crash
  43. * signals and prints which component of LLVM you were in at the time if the
  44. * crash.
  45. */
  46. void LLVMEnablePrettyStackTrace(void);
  47. /**
  48. * @}
  49. */
  50. LLVM_C_EXTERN_C_END
  51. #endif
  52. #ifdef __GNUC__
  53. #pragma GCC diagnostic pop
  54. #endif