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

<rdar://problem/15517596>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199338 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Quentin Colombet
2014-01-15 22:04:35 +00:00
parent 7fa843cfef
commit 4c831d97bf
5 changed files with 94 additions and 2 deletions

View File

@ -46,6 +46,7 @@
namespace llvm {
class LLVMContext;
class DiagnosticInfo;
class GlobalValue;
class Mangler;
class MemoryBuffer;
@ -115,6 +116,8 @@ struct LTOCodeGenerator {
bool disableGVNLoadPRE,
std::string &errMsg);
void setDiagnosticHandler(lto_diagnostic_handler_t, void *);
bool shouldInternalize() const {
return InternalizeStrategy != LTO_INTERNALIZE_NONE;
}
@ -139,6 +142,10 @@ private:
llvm::Mangler &Mangler);
bool determineTarget(std::string &errMsg);
static void DiagnosticHandler(const llvm::DiagnosticInfo &DI, void *Context);
void DiagnosticHandler2(const llvm::DiagnosticInfo &DI);
typedef llvm::StringMap<uint8_t> StringSet;
llvm::LLVMContext &Context;
@ -155,6 +162,8 @@ private:
std::string MCpu;
std::string NativeObjectPath;
llvm::TargetOptions Options;
lto_diagnostic_handler_t DiagHandler;
void *DiagContext;
};
#endif // LTO_CODE_GENERATOR_H