[clang] [libclang/python] Ensure all library functions are registered (PR #140015)
via cfe-commits
cfe-commits at lists.llvm.org
Thu May 15 00:03:16 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Jannick Kremer (DeinAlptraum)
<details>
<summary>Changes</summary>
Add a few library functions that were not previously registered to the `CDLL` object. The current behavior relies on the default `restype` to work.
Add a test to check that all library functions are properly registered. This is not 100% reliable: for a yet unkown reason, `clang_getCursorTLSKind` is not in the list of attributes of the library object, despite working as intended even when not registered.
---
Full diff: https://github.com/llvm/llvm-project/pull/140015.diff
1 Files Affected:
- (added) clang/bindings/python/tests/cindex/test_lib.py (+17)
``````````diff
diff --git a/clang/bindings/python/tests/cindex/test_lib.py b/clang/bindings/python/tests/cindex/test_lib.py
new file mode 100644
index 0000000000000..f8f892731500b
--- /dev/null
+++ b/clang/bindings/python/tests/cindex/test_lib.py
@@ -0,0 +1,17 @@
+import os
+
+from clang.cindex import Config, conf, FUNCTION_LIST
+
+if "CLANG_LIBRARY_PATH" in os.environ:
+ Config.set_library_path(os.environ["CLANG_LIBRARY_PATH"])
+
+import unittest
+
+
+class TestIndex(unittest.TestCase):
+ def test_functions_registered(self):
+ IGNORED = set(["_FuncPtr", "_name", "_handle"])
+ lib_functions = set(vars(conf.lib).keys())
+ registered_functions = set([item[0] for item in FUNCTION_LIST])
+ unregistered_functions = lib_functions - registered_functions - IGNORED
+ self.assertEqual(unregistered_functions, set())
``````````
</details>
https://github.com/llvm/llvm-project/pull/140015
More information about the cfe-commits
mailing list