forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit a04ceb0
authored
[libclang/python] Return actual C types from libclang functions instead of Python bool (llvm#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 llvm#164915.1 parent 4508f44 commit a04ceb0Copy full SHA for a04ceb0
File tree
Expand file treeCollapse file tree
1 file changed
+88
-86
lines changedOpen diff view settings
Filter options
- clang/bindings/python/clang
Expand file treeCollapse file tree
1 file changed
+88
-86
lines changedOpen diff view settings
0 commit comments