https://github.com/efferre79 updated https://github.com/llvm/llvm-project/pull/86931
>From 136de0f3809260a8e26c14cee4e5e7bce55dc364 Mon Sep 17 00:00:00 2001 From: efferre79 <[email protected]> Date: Thu, 19 Mar 2026 22:53:24 +0100 Subject: [PATCH] [libclang/python] export libclang version to the bindings --- clang/bindings/python/clang/cindex.py | 6 ++++++ clang/bindings/python/tests/cindex/test_version.py | 12 ++++++++++++ clang/docs/ReleaseNotes.rst | 2 ++ 3 files changed, 20 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..5b0dea69be29e --- /dev/null +++ b/clang/bindings/python/tests/cindex/test_version.py @@ -0,0 +1,12 @@ +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.assertTrue(version.startswith("clang version")) + self.assertRegex(version, r"^clang version \d+\.\d+\.\d+") diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 45234c316eba8..7535825433983 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() for the class Config to read the + 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
