aboutsummaryrefslogtreecommitdiff
path: root/src/zig_llvm.cpp
diff options
context:
space:
mode:
authorantlilja <liljaanton2001@gmail.com>2024-03-02 15:19:09 +0100
committerantlilja <liljaanton2001@gmail.com>2024-03-02 20:53:06 +0100
commite2345f006ffcd17e41aa73b27890044a0e1f2218 (patch)
tree7f220ca6cdd8bb06668d6d3196583e2eb915b347 /src/zig_llvm.cpp
parent9d500bda2d09fe67c39ee98067c1e53c58adbd5e (diff)
downloadzig-e2345f006ffcd17e41aa73b27890044a0e1f2218.tar.gz
zig-e2345f006ffcd17e41aa73b27890044a0e1f2218.zip
LLVM: Add enableBrokenDebugInfoCheck and getBrokenDebugInfo
These functions allows the caller to find out wether the context encounters broken debug info or not.
Diffstat (limited to 'src/zig_llvm.cpp')
-rw-r--r--src/zig_llvm.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/zig_llvm.cpp b/src/zig_llvm.cpp
index e5432737f9..92364cc143 100644
--- a/src/zig_llvm.cpp
+++ b/src/zig_llvm.cpp
@@ -380,6 +380,26 @@ void ZigLLVMSetOptBisectLimit(LLVMContextRef context_ref, int limit) {
unwrap(context_ref)->setOptPassGate(opt_bisect);
}
+struct ZigDiagnosticHandler : public DiagnosticHandler {
+ bool BrokenDebugInfo;
+ ZigDiagnosticHandler() : BrokenDebugInfo(false) {}
+ bool handleDiagnostics(const DiagnosticInfo &DI) override {
+ if (auto *Remark = dyn_cast<DiagnosticInfoDebugMetadataVersion>(&DI)) {
+ BrokenDebugInfo = true;
+ }
+ return false;
+ }
+};
+
+void ZigLLVMEnableBrokenDebugInfoCheck(LLVMContextRef context_ref) {
+ unwrap(context_ref)->setDiagnosticHandler(std::make_unique<ZigDiagnosticHandler>());
+}
+
+bool ZigLLVMGetBrokenDebugInfo(LLVMContextRef context_ref) {
+ return ((const ZigDiagnosticHandler*)
+ unwrap(context_ref)->getDiagHandlerPtr())->BrokenDebugInfo;
+}
+
void ZigLLVMParseCommandLineOptions(size_t argc, const char *const *argv) {
cl::ParseCommandLineOptions(argc, argv);
}