[cfe-dev] Libclang get storage class

Kevin Funk kfunk at kde.org
Tue Sep 16 04:26:42 PDT 2014


On Monday 08 September 2014 14:40:46 Guilherme wrote:
> Hello,
> 
> I'm trying to find out if a function/variable declaration in C was
> done using static as storage class or not.
> 
> I'm trying to retrieve the storage class using libclang and it's
> python bindings.
> 
> After checking the documentatation for libclang under
> https://github.com/llvm-mirror/clang/blob/master/tools/libclang/libclang.exp
> orts for storage class exports i could not find anything.
> 
> Is it really the case that no storage class access functions are
> exported in libclang or did i just oversee it?
> 
> Is this the right way to retrieve if a function/variable was declared
> static by looking at FunctionDecl::getStorageClass() and
> VarDecl::getStorageClass()? Or is it also retrievable somewhere else
> in libClang?
> 
> Thank you for your help.
> Gui

Heya,

I don't see a way to retrieve that either. Did you consider writing a patch 
for that instead?

It should be pretty trivial to wrap the StorageClass enum in libclang and 
provide a function such as 'clang_getCursorStorageClass' to retrieve the SC 
from either the FunctionDecl or VarDecl.

I think it totally makes sense to expose that in the libclang API.

I suggest having a look at 'clang_getCursorAvailability' for inspiration on 
how to do it. It does almost the same (exporting an enum from C++ to the C 
API)

Cheers

-- 
Kevin Funk | kfunk at kde.org | http://kfunk.org



More information about the cfe-dev mailing list