[cfe-dev] Matcher with expressions
Pedro Delgado Perez
pedro.delgadoperez at mail.uca.es
Fri Sep 27 02:57:57 PDT 2013
Thanks a lot, Manuel. It looks great, but unfortunately, I can't test it as my clang version doesn't recognize equalsBoundNode... I have to solve this problem as my system is not able to identify lots of the matchers in the reference...
Regards,
Pedro.
El día 27 sep 2013 08:33, Manuel Klimek <klimek at google.com> escribió:
>
> Something like (untested):
> constructExpr(hasDeclaration(methodDecl(ofClass(recordDecl().bind("constructedType")))), hasAncestor(methodDecl(ofClass(recordDecl(isDerivedFrom(equalsBoundNode("constructedType"))))))).bind("constructExpr")
>
> Cheers,
> /Manuel
>
>
>
> On Thu, Sep 26, 2013 at 11:40 AM, Pedro Delgado Perez <pedro.delgado at uca.es [ mailto:pedro.delgado at uca.es ]> wrote:
>
>
>
>
> 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 [ mailto: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/20130927/824bde62/attachment.html>
More information about the cfe-dev
mailing list