[cfe-dev] Matcher with expressions
Pedro Delgado Perez
pedro.delgado at uca.es
Thu Sep 26 02:40:58 PDT 2013
> I'm not sure what the question is. You do not want definitions of what?
>
What I need is to find every call to a parent class constructor. Regarding the example I put, I want to match the invokation "A()" and I'm pretty lost in this case...
> Use hasType to match on the type of an expression.
>
Ok, that's good. But, I don't know how could I express that the type is a constructorDecl from a parent class...
Thanks,
Pedro.
El día 26 sep 2013 11:19, Manuel Klimek <klimek at google.com> escribió:
> On Thu, Sep 26, 2013 at 9:26 AM, Pedro Delgado Perez <pedro.delgadoperez at mail.uca.es [ mailto: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/a8f81e72/attachment.html>
More information about the cfe-dev
mailing list