[cfe-dev] Get the number of bits of a bit field with libclang?
Argyrios Kyrtzidis
kyrtzidis at apple.com
Tue May 22 12:51:31 PDT 2012
On May 22, 2012, at 12:37 PM, Jacob Carlborg wrote:
> On 2012-05-22 21:28, Argyrios Kyrtzidis wrote:
>> On May 22, 2012, at 11:42 AM, Jacob Carlborg wrote:
>>
>>> Is it possible to get the number of bits of a bit field with libclang?
>>>
>>> struct Foo
>>> {
>>> int a : 1;
>>> };
>>>
>>> I noticed I could traverse to the "value" of "a" and the type of the
>>> cursor was CXCursor_IntegerLiteral. But is it possible to get the actual
>>> value?
>>
>> No, are you interested in submitting a patch ? I suggest something like "clang_Cursor_getBitWidthValue(CXCursor)" similar to how clang_Cursor_getNumArguments(CXCursor C) works, with the difference that it can return "unsigned" and 0 if the cursor is not a bitfield.
>
> Probably in the long run if no one else does it. But right now I have
> other things on my todo-list for my tool with higher priority.
>
> Would two functions be a good idea, one for signed and one for unsigned
> values? Just like "clang_getEnumConstantDeclValue" and
> "clang_getEnumConstantDeclUnsignedValue".
No, negative values are not allowed for bitfield width.
>
> --
> /Jacob Carlborg
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list