[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 05:56:39 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:
> Problem is, we don't actually want all functions in the lib, but only those used in the Python bindings...
What stop us from listing all exported functions?
> do some kind of static code analysis to check all functions that are used in cindex.py. A bit roundabout, but should work...
Sounds complicated, but if you think you can pull this off with a code that's easy enough to maintain, feel free to open a PR. I'm not sure if I'm going to like it, though.
> test as I did before, but ensure somehow that the lib test comes last. A bit ugly as it depends on the order of tests, and this requires that we have tests for any missing functions.
This is so ugly and brittle that I don't see how I can sign that off.
https://github.com/llvm/llvm-project/pull/140015
More information about the cfe-commits
mailing list