diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h --- a/llvm/include/llvm-c/Core.h +++ b/llvm/include/llvm-c/Core.h @@ -479,6 +479,16 @@ @see ManagedStatic */ void LLVMShutdown(void); +/*===-- Version query -----------------------------------------------------===*/ + +/** + * Return the major, minor, and patch version of LLVM + * + * The version components are returned via the function's three output + * parameters or skipped if a NULL pointer was supplied. + */ +void LLVMGetVersion(unsigned *major, unsigned *minor, unsigned *patch); + /*===-- Error handling ----------------------------------------------------===*/ char *LLVMCreateMessage(const char *Message); diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -61,6 +61,17 @@ 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) {