#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)

dusky lily
#

self explenotary

whole pumiceBOT
#

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.

waxen zodiac
#

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

dusky lily
#

either way thanks!

waxen zodiac
#

no problem. glad it worked!

whole pumiceBOT
#

@dusky lily Has your question been resolved? If so, type !solved :)

dusky lily
#

!solved

whole pumiceBOT
#

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

late patrol
#

Pro tip: move to the C++ libclang api

#

You might run into missing features in C one and then have to migrate 😛

dusky lily
dusky lily
late patrol
#

I dunno I just looked at the headers

#

And on the tiny examples you get when googling "clang libtooling"

tall urchin
long leaf
#

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

GitHub

Visual Studio Extension for C++ struct memory layout visualization - Viladoman/StructLayout