#how do I check if cursor is pointing to a variable definition or only a declaration with libclang?
19 messages · Page 1 of 1 (latest)
When your question is answered use !solved or the button below to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
I mean, the only time a variable is solely a declaration is extern, so check the storage class
I think that's clang_Cursor_getStorageClass(cursor) or something like that
There's also clang_isCursorDefinition I think, which may be what you want
I swear I tried this before but I tried it again and it worked so idk
either way thanks!
no problem. glad it worked!
@dusky lily Has your question been resolved? If so, type !solved :)
!solved
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
Pro tip: move to the C++ libclang api
You might run into missing features in C one and then have to migrate 😛
yeah I was gonna use that for the real project but this is just a proof of concept which is just a frankenstine of the example on the llvm website xd
ik its been a while but Im getting back into this project and I cant find any reference of the C++ API
could you provide a link to the docs?
I dunno I just looked at the headers
And on the tiny examples you get when googling "clang libtooling"
And when it's a static data member declared without an initializer.
struct A { static int x; };
here's a reference that should help with this. the VS2022 "Struct Layout" extension uses this internally as a fallback when it can't pull this info from pdb files, or just generally when whatever else VS provides for utils through their SDK's involving this stuff isn't good enough to extract the context needed to collect accurate info from the source shown in the IDE: https://github.com/Viladoman/StructLayout/blob/main/Parsers/ClangLayout/src/Parser.cpp
Visual Studio Extension for C++ struct memory layout visualization - Viladoman/StructLayout