[clang] [libclang/python] Ensure all library functions are registered (PR #140015)

Vlad Serebrennikov via cfe-commits cfe-commits at lists.llvm.org
Thu May 15 08:17:02 PDT 2025


================
@@ -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())
----------------
Endilll wrote:

> Assuming we had those, what do you want with that? Our only heuristic is "functions not in FUNCTION_LIST" which would include both a) functions used in cindex.py and b) functions exposed but not used in cindex.py with no way to distinguish them. Or did you mean to add entries for all libclang.so functions to FUNCTION_LIST, regardless whether they are used in the Python bindings?

Yes, I meant to put all exported function into `FUNCTION_LIST` irrespective of whether they are used. I believe the purpose of that list is to specify signatures of exported functions, and it's useful in itself. I'm not even sure what lack of unused functions tells us, save for a TODO list of unwrapped functions.

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


More information about the cfe-commits mailing list