From 5fa1f6f57ab71e3e590626ec8d714ba4167fba2d Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Wed, 15 Jan 2014 22:04:35 +0000 Subject: [LTO] Add a hook to map LLVM diagnostics into the clients of LTO. Add a hook in the C API of LTO so that clients of the code generator can set their own handler for the LLVM diagnostics. The handler is defined like this: typedef void (*lto_diagnostic_handler_t)(lto_codegen_diagnostic_severity_t severity, const char *diag, void *ctxt) - severity says how bad this is. - diag is a string that contains the diagnostic message. - ctxt is the registered context for this handler. This hook is more general than the lto_get_error_message, since this function keeps only the latest message and can only be queried when something went wrong (no warning for instance). llvm-svn: 199338 --- llvm/include/llvm-c/lto.h | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'llvm/include/llvm-c/lto.h') diff --git a/llvm/include/llvm-c/lto.h b/llvm/include/llvm-c/lto.h index 2292f470eba..483ad1a917a 100644 --- a/llvm/include/llvm-c/lto.h +++ b/llvm/include/llvm-c/lto.h @@ -40,7 +40,7 @@ typedef bool lto_bool_t; * @{ */ -#define LTO_API_VERSION 6 +#define LTO_API_VERSION 7 typedef enum { LTO_SYMBOL_ALIGNMENT_MASK = 0x0000001F, /* log2 of alignment */ @@ -204,6 +204,33 @@ lto_module_get_symbol_name(lto_module_t mod, unsigned int index); extern lto_symbol_attributes lto_module_get_symbol_attribute(lto_module_t mod, unsigned int index); +/** + * Diagnostic severity. + */ +typedef enum { + LTO_DS_ERROR, + LTO_DS_WARNING, + LTO_DS_NOTE +} lto_codegen_diagnostic_severity_t; + +/** + * Diagnostic handler type. + * \p severity defines the severity. + * \p diag is the actual diagnostic. + * The diagnostic is not prefixed by any of severity keyword, e.g., 'error: '. + * \p ctxt is used to pass the context set with the diagnostic handler. + */ +typedef void (*lto_diagnostic_handler_t)( + lto_codegen_diagnostic_severity_t severity, const char *diag, void *ctxt); + +/** + * Set a diagnostic handler and the related context (void *). + * This is more general than lto_get_error_message, as the diagnostic handler + * can be called at anytime within lto. + */ +extern void lto_codegen_set_diagnostic_handler(lto_code_gen_t, + lto_diagnostic_handler_t, + void *); /** * Instantiates a code generator. -- cgit v1.2.3