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

>From 1a7ccb5aaf97e3919ecbb24eff3d1dc8b4f4ccdb Mon Sep 17 00:00:00 2001
From: efferre79 <[email protected]>
Date: Thu, 19 Mar 2026 22:53:24 +0100
Subject: [PATCH 1/2] [libclang/python] export libclang version to the bindings

---
 clang/bindings/python/clang/cindex.py              |  6 ++++++
 clang/bindings/python/tests/cindex/test_version.py | 11 +++++++++++
 clang/docs/ReleaseNotes.rst                        |  2 ++
 3 files changed, 19 insertions(+)
 create mode 100755 clang/bindings/python/tests/cindex/test_version.py

diff --git a/clang/bindings/python/clang/cindex.py 
b/clang/bindings/python/clang/cindex.py
index c34a1c0db01e9..48b3f5bfef6b6 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -4339,6 +4339,7 @@ def set_property(self, property, value):
     ("clang_getCanonicalCursor", [Cursor], Cursor),
     ("clang_getCanonicalType", [Type], Type),
     ("clang_getChildDiagnostics", [Diagnostic], c_object_p),
+    ("clang_getClangVersion", [], _CXString),
     ("clang_getCompletionAvailability", [c_void_p], c_int),
     ("clang_getCompletionBriefComment", [c_void_p], _CXString),
     ("clang_getCompletionChunkCompletionString", [c_void_p, c_int], 
c_object_p),
@@ -4649,6 +4650,11 @@ def get_cindex_library(self) -> CDLL:
 
         return library
 
+    def get_version(self):
+        """
+        Returns the libclang version string used by the bindings
+        """
+        return _CXString.from_result(self.lib.clang_getClangVersion())
 
 conf = Config()
 
diff --git a/clang/bindings/python/tests/cindex/test_version.py 
b/clang/bindings/python/tests/cindex/test_version.py
new file mode 100755
index 0000000000000..0540185221daa
--- /dev/null
+++ b/clang/bindings/python/tests/cindex/test_version.py
@@ -0,0 +1,11 @@
+import unittest
+import re
+from clang.cindex import Config
+
+
+class TestClangVersion(unittest.TestCase):
+    def test_get_version_format(self):
+        conf = Config()
+        version = conf.get_version()
+
+        self.assertRegex(version, r"^clang version \d+\.\d+\.\d+")
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 45234c316eba8..22b4e4d5cf121 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -544,6 +544,8 @@ Python Binding Changes
   ``CodeCompletionResults.results`` should be changed to directly use
   ``CodeCompletionResults``: it nows supports ``__len__`` and ``__getitem__``,
   so it can be used the same as ``CodeCompletionResults.results``.
+- Added a new helper method ``get_version`` to the class ``Config`` to read the
+  version string of the libclang in use
 
 OpenMP Support
 --------------

>From 8416847170cb84ab44daecd9415ddddd0fd5eb45 Mon Sep 17 00:00:00 2001
From: efferre79 <[email protected]>
Date: Sat, 21 Mar 2026 12:35:44 +0100
Subject: [PATCH 2/2] Update clang/docs/ReleaseNotes.rst

Co-authored-by: Vlad Serebrennikov <[email protected]>
---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 22b4e4d5cf121..e72bd9a52ae1c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -545,7 +545,7 @@ Python Binding Changes
   ``CodeCompletionResults``: it nows supports ``__len__`` and ``__getitem__``,
   so it can be used the same as ``CodeCompletionResults.results``.
 - Added a new helper method ``get_version`` to the class ``Config`` to read the
-  version string of the libclang in use
+  version string of the libclang in use.
 
 OpenMP Support
 --------------

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to