[cfe-dev] Getting multiple AST matches as a list

Jesper Eskilson jesper.eskilson at iar.com
Fri Aug 30 04:22:51 PDT 2013


Hello,

I'm learning about how to use AST matchers, but one usecase is giving me 
headaches. I have a declaration like this:

const char *list = { "a", "b" };

and I would like to retrieve the array initializer as a list of strings 
in my matcher callback.  I've managed to get a pointer to the 
InitListExpr which looks like this:

> InitListExpr 0x46be670 'const char *[2]'
> |-ImplicitCastExpr 0x46be6c0 'const char *' <ArrayToPointerDecay>
> | `-StringLiteral 0x46be5b8 'const char [12]' lvalue "semihosting"
> `-ImplicitCastExpr 0x46be6d8 'const char *' <ArrayToPointerDecay>
>   `-StringLiteral 0x46be5f0 'const char [4]' lvalue "swo"

I've looked through the traversal matchers, but it seems like I can only 
get matchers which will generate a match for each element in the list. 
Is there any way to generate a single match with all elements wrapped up 
in a list?

/Jesper
-- 
*Jesper Eskilson* /Development Engineer/
IAR Systems AB
Box 23051, Strandbodgatan 1
SE-750 23 Uppsala, SWEDEN
E-mail: jesper.eskilson at iar.com <mailto:jesper.eskilson at iar.com> 
Website: www.iar.com
<http://www.iar.com> Twitter: www.twitter.com/iarsystems 
<http://www.twitter.com/iarsystems>



More information about the cfe-dev mailing list