[clang] [libclang/python] export libclang version to the bindings (PR #86931)

via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 28 03:11:45 PDT 2024


https://github.com/efferre79 created https://github.com/llvm/llvm-project/pull/86931

it's useful to know which clang library the python byndings are running

>From 05a882b276e6e6f3c8502c9e1102d575f4c49018 Mon Sep 17 00:00:00 2001
From: efferre79 <rossi.f at inwind.it>
Date: Thu, 28 Mar 2024 11:11:21 +0100
Subject: [PATCH] [libclang/python] export libclang version to the bindings

---
 clang/bindings/python/clang/cindex.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index 302d99dccd77b5..a98fa9ee70569d 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -3846,6 +3846,7 @@ def write_main_file_to_stdout(self):
     ("clang_getCanonicalCursor", [Cursor], Cursor, Cursor.from_cursor_result),
     ("clang_getCanonicalType", [Type], Type, Type.from_result),
     ("clang_getChildDiagnostics", [Diagnostic], c_object_p),
+    ("clang_getClangVersion", [], _CXString, _CXString.from_result),
     ("clang_getCompletionAvailability", [c_void_p], c_int),
     ("clang_getCompletionBriefComment", [c_void_p], _CXString, _CXString.from_result),
     ("clang_getCompletionChunkCompletionString", [c_void_p, c_int], c_object_p),
@@ -4178,6 +4179,9 @@ def function_exists(self, name):
             return False
 
         return True
+ 
+    def get_version(self):
+        return self.lib.clang_getClangVersion()
 
 
 def register_enumerations():



More information about the cfe-commits mailing list