[cfe-dev] ASTMatchers: isVirtual and isOverride

Pedro Delgado Perez pedro.delgadoperez at mail.uca.es
Fri Apr 19 01:17:59 PDT 2013


 
Thank you very much Gábor,

I'm using clang version 3.3, but indeed the isVirtual and isOverride matchers aren't present in my ASTMatchers.h. If other matchers are missing, I already know where to look for, thanks.

> Also, instead of isDefaultConstructor(), you could use argumentCountIs(0).
> 
What I meant to do is to fetch the node of the default constructor method declaration in order to delete it, not where the calls to that constructor were made, so your suggestion is not what I need. Any other suggestion? I would like to know as well if the default constructor is not empty (i.e., i don't want to fetch a constructor like Foo(){}, but a constructor like Foo(){ a=0;} or Foo():Bar(){})


Thanks,

Pedro.

El dia 19 abr 2013 01:58, Gábor Kozár <kozargabor at gmail.com> escribió:
> 
> 
> 
> Hi,
> 
> 
> What version are you using? The matchers isOverride() and isVirtual() I know for certain were not in version 3.2, and can only be found on SVN (in this file: http://llvm.org/svn/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h [ http://llvm.org/svn/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h ]).
> 
> Nonetheless, you can implement them all very easily manually, or just indeed copy their implementation from the link above. Also, instead of isDefaultConstructor(), you could use argumentCountIs(0).
> 
> Gabor
> 
> 
> 
> 
> 2013/4/18 Pedro Delgado Perez <pedro.delgadoperez at mail.uca.es [ mailto:pedro.delgadoperez at mail.uca.es ]>
> 
> 
> Hi,
> 
> I'm newbie using ASTMatchers and I'm trying to learn little by little how to use them.
> 
> I was basing on the matcher recordDecl(hasName("Foo"), isDerivedFrom("Bar")) shown in http://clang.llvm.org/docs/LibASTMatchers.html [ http://clang.llvm.org/docs/LibASTMatchers.html ] trying to include new features. For instance, I tried to look for classes which have at least one virtual method:
> 
> recordDecl(hasName("Foo"), isDerivedFrom("Bar"), hasMethod(isVirtual()))
> 
> Or I tried to match protected overriden methods:
> 
> methodDecl(allOf(isProtected(), isOverride());
> 
> But neither of them worked as it couldn't find "isOverride" and "isVirtual" identifiers. I was trying a lot of combinations, but I can't understand this well.
> 
> Finally, I tried to look for the the default constructor of a certain class:
> 
> constructorDecl(hasName("Foo"), isDefaultConstructor())
> 
> but this is wrong. What I'm doing bad? Please, any information you give me will be fine to me to understand how to use matchers.
> 
> Thanks in advance,
> 
> Pedro.
> 
> 
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> 
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev [ http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev ]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130419/bd83b2e4/attachment.html>


More information about the cfe-dev mailing list