[cfe-dev] Matcher with expressions

Manuel Klimek klimek at google.com
Thu Sep 26 02:19:39 PDT 2013


On Thu, Sep 26, 2013 at 9:26 AM, Pedro Delgado Perez <
pedro.delgadoperez at mail.uca.es> wrote:

>  Hello,
>
> Sorry to write you directly, but I have been sending this message since
> two days ago to cfe-dev but my message is not posted and I need help as
> soon as possible.
>
> This is the message:
>
> "Up to now, I have been using matchers to match declarations, but now, I
> need to match an expression and I am having some problems.
> I am looking for a CXXConstructExpr like the one marked in bold in the
> next example:
> class A{
>    A() {...}
>    ...
> };
> class B: public A{
>      B () {* A (); *}
> }
> I think the matcher should follow this structure:
> StatementMatcher CE = constructExpr(...);
>
> Then:
>
> 1. If I put nothing within the parentheses, "A()" in class A, "B()" and
> "A()" in class B are all retrieved. Therefore, I need to indicate that I do
> not want the definitions. Thus, I thought about the matcher "isDefinition",
> but it is only for the type "Decl", how can I solve this problem?
> The only thing that I have found is the matcher "hasDeclaration", but I do
> not know how this matcher could help me in this task.
>
I'm not sure what the question is. You do not want definitions of what?

> 2. I also need to ensure that the constructor invoked belongs to a parent
> class. In the same way, when matching declarations I can ask if the
> CXXConstructDecl "B()" is "ofClass(recordDecl(isDerivedFrom(...)))". But,
> with an expression...
>
Use hasType to match on the type of an expression.

Cheers,
/Manuel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130926/a6b8729f/attachment.html>


More information about the cfe-dev mailing list