aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Core.cpp
diff options
context:
space:
mode:
authorWenzel Jakob <wenzel.jakob@epfl.ch>2022-12-07 11:12:53 +0100
committerNikita Popov <npopov@redhat.com>2022-12-07 11:18:32 +0100
commitcb5b25c587833317fd0bb93daf702f4c47048fb1 (patch)
treee456e9dd4387759121397c044e62e2054e7aa9c5 /llvm/lib/IR/Core.cpp
parent93d9c2e563cf63b852ead108340e94bd213ea2a6 (diff)
downloadllvm-cb5b25c587833317fd0bb93daf702f4c47048fb1.zip
llvm-cb5b25c587833317fd0bb93daf702f4c47048fb1.tar.gz
llvm-cb5b25c587833317fd0bb93daf702f4c47048fb1.tar.bz2
[llvm-c] Added a C-API binding to query the LLVM version
The LLVM C bindings currently offer no way to query the version string dynamically. This is a useful feature in situations where a program isn't compiled against a specific version of LLVM but rather loads it dynamically (e.g. using dlopen()). In situations where the shared library filename doesn't reveal the version (e.g. LLVM-C.dll) and to adapt to version-specific API differences, it is then useful to be able to query the version string by calling the proposed LLVMGetVersion function. Differential Revision: https://reviews.llvm.org/D139381
Diffstat (limited to 'llvm/lib/IR/Core.cpp')
-rw-r--r--llvm/lib/IR/Core.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 1235c46..f376bfb 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -61,6 +61,17 @@ void LLVMShutdown() {
llvm_shutdown();
}
+/*===-- Version query -----------------------------------------------------===*/
+
+void LLVMGetVersion(unsigned *Major, unsigned *Minor, unsigned *Patch) {
+ if (Major)
+ *Major = LLVM_VERSION_MAJOR;
+ if (Minor)
+ *Minor = LLVM_VERSION_MINOR;
+ if (Patch)
+ *Patch = LLVM_VERSION_PATCH;
+}
+
/*===-- Error handling ----------------------------------------------------===*/
char *LLVMCreateMessage(const char *Message) {