[cfe-commits] libclang: Patch to get an integer value from a cursor.
Argyrios Kyrtzidis
kyrtzidis at apple.com
Tue Sep 20 18:04:06 PDT 2011
> /**
> + * \brief Retrieve an integer value from a CXCursor (if any).
> + *
> + * For example, this can be used to:
> + *
> + * * Get the value of an enumeration constant.
> + * * Get the value of a currently unexposed declaration attribute
> + * (for example, inline or calling convention attributes).
> + * * Get the value of an initializer or bit field width
> + * from a currently unexposed expression.
> + */
> +CINDEX_LINKAGE int clang_getCursorValue(CXCursor C);
> +
Merging unrelated functionality in one function does not seem ideal.
How about:
-actually expose the attributes that you are interested in
-adding clang_getConstantValue(CXCursor) where CXCursor can be a decl with an init value (like CXCursor_EnumConstantDecl) or a constant-folded expression.
-adding clang_getBitfieldWidth(CXCursor) where CXCursor is a FieldDecl (separate function otherwise there may be some difficulty distinguishing between a bitfield width and an in-class initializer)
-Argyrios
On Sep 15, 2011, at 5:54 AM, Vinay Sajip wrote:
> I've attached a patch to allow getting useful integer values from a cursor, such as
>
> An enumeration constant value
>
> An unexposed declaration attribute (e.g. inline)
> An unexposed expression (e.g. a bit field width)
>
> Comments welcome.
>
> Regards,
>
> Vinay Sajip
> <cursor-value.diff>_______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110920/02a79b32/attachment.html>
More information about the cfe-commits
mailing list