Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

size_t getting TypeKind.INT instead of TypeKind.ULONG #53

Closed
Victorious3 opened this issue May 12, 2023 · 4 comments
Closed

size_t getting TypeKind.INT instead of TypeKind.ULONG #53

Victorious3 opened this issue May 12, 2023 · 4 comments
Labels
question Further information is requested

Comments

@Victorious3
Copy link

For the case of libc's malloc function I get the tokens:

['extern', 'void', '*', 'malloc', '(', 'size_t', '__size', ')', '__THROW', '__attribute_malloc__']

and the parameter has the tokens:

['size_t', '__size']

However when I look at the type of the parameter with param.type I get TypeKind.INT instead of something resembling size_t.

@sighingnow
Copy link
Owner

Cannot reproduce. size_t itself is a TypeKind.TYPEDEF, whose canonical type's kind is TypeKind.ULONG, not TypeKind.INT.

You could check TranslationUnit.diagnostics to see if there are compilation errors during parsing (missing include or something like that).

@sighingnow sighingnow added the question Further information is requested label May 23, 2023
@sighingnow
Copy link
Owner

Closing as answered. Feel free to reopen if you could provide minimal example that can reproduce this issue.

@tregua87
Copy link

I am encountering the same problem. For some files/headers, the library 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: libclang.zip
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_t, size_t, uint8_t *, size_t *)'

@tregua87
Copy link

@sighingnow do you prefer I open a new issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants