Open japendergrass opened 2 years ago
This appears to impact get_children
for a wide range of AST node types that may contain NULL
as a subexpression. For example:
int foo(){return 0 == NULL}
int foo(char *x){while(x == NULL){x = "hello";}
Both exhibit similar behavior where the COMPOUND_STMT
body of the function reports no children.
This does not seem to affect the version of the underlying libclang.so
installed by the ubuntu package manager. Just the version installed by pip install libclang
The libclang python bindings are consistently not returning the initializer child cursor for
VAR_DECL
cursors if aNULL
is present (apparently) anywhere in the initializer. This includes initializing a value toNULL
, to an array with at least oneNULL
element, or to a structure with aNULL
field (and seems to apply when these are nested as well).Using
((void*)0)
instead ofNULL
does not produce this issue, nor does using0
.The following
demo.py
(apologies for not attaching, the github page keeps producing an error when I try) illustrates the issue by dumping the children of amy_global
variable on several sample C files.Tested with version 12.0.0 and 13.0.0 of the libclang python bindings on Ubuntu 20.04
demo.py
test1-bad.c
Output is the empty list but should be
[CursorKind.UNEXPOSED_EXPR]
test1-good.c
test2-bad.c
Output is the empty list but should be
[CursorKind.INIT_LIST_EXPR]
test2-good.c
test3-bad.c
Output is
[CursorKind.TYPE_REF]
but should be[CursorKind.TYPE_REF, CursorKind.INIT_LIST_EXPR]
test3-good.c