[cfe-dev] How to get field name/array index of a init list expression?

Jay Wang via cfe-dev cfe-dev at lists.llvm.org
Wed Apr 4 03:29:06 PDT 2018


Say I have code below:

char *init[] = {
    "string1", "string2"
}

When I visit expression StringLiteral "string1", I need something like
"init[0]".

struct _thestruct {
    char str[20];
    int foo;
};

_thestruct var[] = { {"string1", 2},  {"string2", 3} };

When I visit expression StringLiteral "string2", I need "var[1].str".

How do I implement this?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180404/c561be96/attachment.html>


More information about the cfe-dev mailing list