[LLVMdev] Getting strcut member attributes

Sebastian Redl sebastian.redl at getdesigned.at
Thu Jul 11 05:55:39 PDT 2013


On 2013-07-11 10:40, Raghavendra K wrote:
> #define OPT
> #define MAN
>
> struct A
> {
>     int i;
>     char* c;
>   };
>
>
> struct B
> {
>    OPT A a;
>    MAN int i;
> };
>
> After parsing the above .h file,   how to get the attributes of B members specifically
> for member A which is prefixed with OPT...
>
> So far am able to get type of a as A but unable to OPT...as it might be preprocessed and as it is empty
> it may discarded or...
>
Are you talking about Clang's AST (in which case you should ask your 
question on cfe-dev, not here) or IR?
In either case, empty preprocessor defines are gone. There's no way to 
recover them. Instead, define OPT and MAN to be something like 
__attribute__((annotate("opt"))), which will be preserved.

Sebastian



More information about the llvm-dev mailing list