[clang] [libclang/python] Renaming `get_version` into `get_clang_version` (PR #188515)

via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 25 08:41:04 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Thomas Applencourt (TApplencourt)

<details>
<summary>Changes</summary>

Rename `get_version` to `get_clang_version` to match the `libclang.so` name[1], and be clear we doesn't return some `cindex.py` internal versioning but the `libclang.so` one. 

[1]  This match was some current API are doing for example `conf.lib.clang_getArraySize` is mapped to `get_array_size`.

--- 

We now have an inconsistency between `get_cindex_library` who return a path to `libclang.so`, and `get_clang_version` (and not `get_cindex_version`) who return the version of this lib. 

- One possibility will be to rename `get_cindex_library` to `get_clang_library`, but this is quite a big breaking change
- Another will be to rename `get_clang_version` to `get_cindex_version` but this obscure the link between `cindex_version` and the libclang.so call `getClangversion`. 

So personally, I can leave with this inconsistency. 

---
Full diff: https://github.com/llvm/llvm-project/pull/188515.diff


2 Files Affected:

- (modified) clang/bindings/python/clang/cindex.py (+1-1) 
- (modified) clang/bindings/python/tests/cindex/test_version.py (+1-1) 


``````````diff
diff --git a/clang/bindings/python/clang/cindex.py b/clang/bindings/python/clang/cindex.py
index 6e8ea782df74c..b71f9ed2275e0 100644
--- a/clang/bindings/python/clang/cindex.py
+++ b/clang/bindings/python/clang/cindex.py
@@ -4650,7 +4650,7 @@ def get_cindex_library(self) -> CDLL:
 
         return library
 
-    def get_version(self):
+    def get_clang_version(self) -> str:
         """
         Returns the libclang version string used by the bindings
         """
diff --git a/clang/bindings/python/tests/cindex/test_version.py b/clang/bindings/python/tests/cindex/test_version.py
index 0540185221daa..2b25b0bd1c526 100755
--- a/clang/bindings/python/tests/cindex/test_version.py
+++ b/clang/bindings/python/tests/cindex/test_version.py
@@ -6,6 +6,6 @@
 class TestClangVersion(unittest.TestCase):
     def test_get_version_format(self):
         conf = Config()
-        version = conf.get_version()
+        version = conf.get_clang_version()
 
         self.assertRegex(version, r"^clang version \d+\.\d+\.\d+")

``````````

</details>


https://github.com/llvm/llvm-project/pull/188515


More information about the cfe-commits mailing list