| author | |
| committer | |
| log | e2345f006ffcd17e41aa73b27890044a0e1f2218 |
| tree | 7f220ca6cdd8bb06668d6d3196583e2eb915b347 |
| parent | 9d500bda2d09fe67c39ee98067c1e53c58adbd5e |
These functions allows the caller to find out wether the context
encounters broken debug info or not.3 files changed, 29 insertions(+), 0 deletions(-)
src/codegen/llvm/bindings.zig+6| ... | ... | @@ -37,6 +37,12 @@ pub const Context = opaque { |
| 37 | 37 | |
| 38 | 38 | pub const setOptBisectLimit = ZigLLVMSetOptBisectLimit; |
| 39 | 39 | extern fn ZigLLVMSetOptBisectLimit(C: *Context, limit: c_int) void; |
| 40 | ||
| 41 | pub const enableBrokenDebugInfoCheck = ZigLLVMEnableBrokenDebugInfoCheck; | |
| 42 | extern fn ZigLLVMEnableBrokenDebugInfoCheck(C: *Context) void; | |
| 43 | ||
| 44 | pub const getBrokenDebugInfo = ZigLLVMGetBrokenDebugInfo; | |
| 45 | extern fn ZigLLVMGetBrokenDebugInfo(C: *Context) bool; | |
| 40 | 46 | }; |
| 41 | 47 | |
| 42 | 48 | pub const Module = opaque { |
src/zig_llvm.cpp+20| ... | ... | @@ -380,6 +380,26 @@ void ZigLLVMSetOptBisectLimit(LLVMContextRef context_ref, int limit) { |
| 380 | 380 | unwrap(context_ref)->setOptPassGate(opt_bisect); |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | struct ZigDiagnosticHandler : public DiagnosticHandler { | |
| 384 | bool BrokenDebugInfo; | |
| 385 | ZigDiagnosticHandler() : BrokenDebugInfo(false) {} | |
| 386 | bool handleDiagnostics(const DiagnosticInfo &DI) override { | |
| 387 | if (auto *Remark = dyn_cast<DiagnosticInfoDebugMetadataVersion>(&DI)) { | |
| 388 | BrokenDebugInfo = true; | |
| 389 | } | |
| 390 | return false; | |
| 391 | } | |
| 392 | }; | |
| 393 | ||
| 394 | void ZigLLVMEnableBrokenDebugInfoCheck(LLVMContextRef context_ref) { | |
| 395 | unwrap(context_ref)->setDiagnosticHandler(std::make_unique<ZigDiagnosticHandler>()); | |
| 396 | } | |
| 397 | ||
| 398 | bool ZigLLVMGetBrokenDebugInfo(LLVMContextRef context_ref) { | |
| 399 | return ((const ZigDiagnosticHandler*) | |
| 400 | unwrap(context_ref)->getDiagHandlerPtr())->BrokenDebugInfo; | |
| 401 | } | |
| 402 | ||
| 383 | 403 | void ZigLLVMParseCommandLineOptions(size_t argc, const char *const *argv) { |
| 384 | 404 | cl::ParseCommandLineOptions(argc, argv); |
| 385 | 405 | } |
src/zig_llvm.h+3| ... | ... | @@ -44,6 +44,9 @@ ZIG_EXTERN_C LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, co |
| 44 | 44 | |
| 45 | 45 | ZIG_EXTERN_C void ZigLLVMSetOptBisectLimit(LLVMContextRef context_ref, int limit); |
| 46 | 46 | |
| 47 | ZIG_EXTERN_C void ZigLLVMEnableBrokenDebugInfoCheck(LLVMContextRef context_ref); | |
| 48 | ZIG_EXTERN_C bool ZigLLVMGetBrokenDebugInfo(LLVMContextRef context_ref); | |
| 49 | ||
| 47 | 50 | enum ZigLLVMTailCallKind { |
| 48 | 51 | ZigLLVMTailCallKindNone, |
| 49 | 52 | ZigLLVMTailCallKindTail, |