sighingnow / libclang

(Unofficial) Release libclang (clang.cindex) on pypi.
https://pypi.org/project/libclang
Other
81 stars 21 forks source link

size_t not recognized correctly #62

Closed tregua87 closed 10 months ago

tregua87 commented 10 months ago

Hi, I reopen this issue.

I am encountering the same problem. For some files/headers, the libclang misinterpret size_t type.

I am in an Ubuntu 20.04 (Dockerized) with libclang==14.0.6 (installed from pip).

$ uname -a
Linux d3718923266e 5.15.0-73-generic #80~20.04.1-Ubuntu SMP Wed May 17 14:58:14 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

I made a minimal example here. You should just unzip and run ./sizet_error.py

To note that clang-12 seems to get the correct AST.

$ clang-12 --version
Ubuntu clang version 12.0.0-3ubuntu1~20.04.5
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

$ clang-12 -I. -Xclang -ast-dump -fsyntax-only min.cc | grep aom_uleb_encode_fixed_size
| | | `-FunctionDecl 0x20ae310 <line:60:1, line:62:50> line:60:5 aom_uleb_encode_fixed_size 'int (uint64_t, size_
sighingnow commented 10 months ago
     tu = index.parse(tmp_file, args=[f"-I{include_folder}"])
+    for diag in tu.diagnostics:
+        print(diag)

You will see that there are some errors during parsing:

./min.cc
././aom/aomcx.h:19:10: fatal error: 'aom/aom.h' file not found