[all-commits] [llvm/llvm-project] a04ceb: [libclang/python] Return actual C types from libcl...
Thomas Applencourt via All-commits
all-commits at lists.llvm.org
Fri Nov 7 01:01:15 PST 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: a04ceb02ad316cc4f2e6edfdeacc089526751608
https://github.com/llvm/llvm-project/commit/a04ceb02ad316cc4f2e6edfdeacc089526751608
Author: Thomas Applencourt <tapplencourt at anl.gov>
Date: 2025-11-07 (Fri, 07 Nov 2025)
Changed paths:
M clang/bindings/python/clang/cindex.py
Log Message:
-----------
[libclang/python] Return actual C types from libclang functions instead of Python bool (#166446)
In the previous implementation, 43 libclang functions are registered in
FUNCTION_LIST with return type ctypes.c_bool. However, none of these
functions actually return a C bool type; instead, they return unsigned
or signed integers (unsigned int / int) on the C side.
Although ctypes automatically casts nonzero integers to True and zero to
False, this implicit conversion hides the "true" c-return type.
This PR updates those functions to use their proper “native” ctypes
return types (c_uint or c_int) and updates the corresponding Python
convenience wrappers to explicitly cast their results using the bool
constructor.
As a side effect, the related `# type: ignore` annotations have been
removed, as they are no longer necessary.
Some libclang functions are used directly without any intermediate
Python wrapper. These functions (`clang_equalCursors`,
`clang_equalLocations`, `clang_equalRanges`, `clang_equalTypes`,
`clang_File_isEqual`, and `clang_isFileMultipleIncludeGuarded`) are now
explicitly cast to bool at their call sites. Note that
`clang_isFileMultipleIncludeGuarded` is never called in the binding.
Thix fix #164915.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list