For the second one, I altered my snippet:<br><br>MatcherProxy StlCOAPPred::getMatcher()<br>{<br>  TypeMatcher type = unless(anything());<br><br>  for(const auto& e : gContainers)<br>    type = anyOf(hasDeclaration(recordDecl(hasName(e))), type);<br>
<br>  return id("id",<br>            varDecl(allOf(hasType(recordDecl(hasDescendant(<br>                           classTemplateSpecializationDecl(hasAnyTemplateArgument(<br>                           refersToType(hasDeclaration(recordDecl(hasName("std::auto_ptr"))))))))),<br>
                         hasType(type))));<br>}<br><br><br>But it does not seems to work. It do not give me any matches.<br><br>For the first one, I futher will investigate it later today, however my bet would be that, it tries to match "std::_Rb_tree_const_iterator".<br>
<br>Thanks,<br>Gábor<br><br><div class="gmail_quote">On 10 October 2012 13:55, Daniel Jasper <span dir="ltr"><<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+cfe-dev, please remember to include<br>
<br>
I don't see anything generally wrong with your approach to match<br>
iterators. What I would do to debug this is locally editing<br>
ASTMatchers.h to add a "llvm::outs() << FullName;" debug output into<br>
the matchesName matcher. That way, you can see what it is actually<br>
trying to match.<br>
<br>
The second question should work like:<br>
<br>
  varDecl(hasType(recordDecl(<br>
    hasDescendent(classTemplateSpecialization(hasAnyTemplateArgument(<br>
      refersToType(hasName("std::auto_ptr")))))))).bind("id")<br>
<br>
This is just as a general idea, it might not yet be correct.<br>
<br>
Cheers,<br>
Daniel<br>
<div class="HOEnZb"><div class="h5"><br>
On Wed, Oct 10, 2012 at 1:23 PM, Gábor Horváth <<a href="mailto:xazax.hun@gmail.com">xazax.hun@gmail.com</a>> wrote:<br>
> Hi!<br>
><br>
> I want to create a matcher to match things like std::set<int>::iterator.<br>
><br>
> I come up with this one: ...<br>
> hasType(namedDecl(matchesName("std::set.*iterator"))) ...<br>
> however it did not give me any match.<br>
><br>
> Using the internal name of the iterator class like<br>
> std::_Rb_tree_const_iterator would work, however that is implementation<br>
> defined, so I do not want to rely on that one.<br>
><br>
> Do you have any idea what am I doing wrong?<br>
><br>
> My another question is, for example if I want to search for auto_ptr as<br>
> template arguments in containers, I want to match vector<auto_ptr<int>> and<br>
> also vector<vector<auto_ptr<int>>> ... etc.<br>
><br>
> Is there any proper way to do it? My current solution:<br>
><br>
> MatcherProxy StlCOAPPred::getMatcher()<br>
> {<br>
>   TypeMatcher type = unless(anything());<br>
><br>
>   for(const auto& e : gContainers)<br>
>     type = anyOf(hasDeclaration(recordDecl(hasName(e))), type);<br>
><br>
>   auto templateSpecWithArgument = [](DeclarationMatcher decl) -><br>
> DeclarationMatcher {<br>
>     return<br>
> classTemplateSpecializationDecl(hasAnyTemplateArgument(refersToType(hasDeclaration(decl))));<br>
>   };<br>
><br>
>   // 1, 2, 3 times embedded<br>
>   DeclarationMatcher decl =<br>
> anyOf(templateSpecWithArgument(recordDecl(hasName("std::auto_ptr"))),<br>
><br>
> templateSpecWithArgument(templateSpecWithArgument(recordDecl(hasName("std::auto_ptr")))),<br>
><br>
> templateSpecWithArgument(templateSpecWithArgument(templateSpecWithArgument(recordDecl(hasName("std::auto_ptr"))))));<br>
><br>
><br>
>   return id("id",varDecl(allOf(hasType(decl),hasType(type))));<br>
> }<br>
><br>
> I use templateSpecWithArgument, and nesting it. I could write a loop to do<br>
> this nesting several times, however I think that could degrade the<br>
> performance significantly (I did not measure yet).<br>
><br>
> Thanks<br>
> Gábor<br>
</div></div></blockquote></div><br>