<div dir="ltr">You can look at the equalsBoundNode matcher to get an idea of how something like you are trying to do can be implemented.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Sep 24, 2013 at 11:52 PM, Gabor Kozar <span dir="ltr"><<a href="mailto:kozargabor@gmail.com" target="_blank">kozargabor@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>




<div><div>Actually, the problem is that you're passing a matcher as argument, while you've defined your matchers to accept FieldDecl (the 3rd argument for the AST_MATCHER_P macro) - but the compiler already told you this.<br>
</div>
<div> </div>
<div>So I don't really see what you're confused about. For that matter, nor can I really tell what you're trying to do in your matcher expression... What is it that you're trying to express here?</div>
<div> </div>
<div><div>-- <br></div>
<div>  Gábor Kozár -- ShdNx<br></div>
<div>  <a href="mailto:kozargabor@gmail.com" target="_blank">kozargabor@gmail.com</a><br></div>
<div> </div>
</div><div><div class="h5">
<div> </div>
<div> </div>
<div>On Tue, Sep 24, 2013, at 17:02, Vane, Edwin wrote:<br></div>
</div></div><blockquote type="cite"><div><div class="h5"><div><p style="font-family:'Times New Roman',serif;font-size:12pt;margin:0cm 0cm 0.0001pt"><span style="color:rgb(31,73,125)"><span style="font-family:Calibri,sans-serif"><span style="font-size:11pt">The source of the failure is where you have SameType(recordDecl(…)). You’ll notice in the reference that recordDecl() returns a Matcher<Decl>. So your SameType()
 matcher is going to receive a ‘Decl’ as input. You’ll need to explicitly change this into a FieldDecl. I’m afraid I don’t know exactly what you’re trying to match or what IHD is so I can’t tell if there’s a more fundamental error here.</span></span></span><br>
</p><p style="font-family:'Times New Roman',serif;font-size:12pt;margin:0cm 0cm 0.0001pt"><a name="14151f72144d651b__MailEndCompose"><span style="color:rgb(31,73,125)"><span style="font-family:Calibri,sans-serif"><span style="font-size:11pt"></span></span></span></a><br>
</p><div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt"><div><div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm"><p style="font-family:'Times New Roman',serif;font-size:12pt;margin:0cm 0cm 0.0001pt">
<b><span style="font-family:Calibri,sans-serif"><span style="font-size:11pt">From:</span></span></b><span style="font-family:Calibri,sans-serif"><span style="font-size:11pt"> <a href="mailto:cfe-dev-bounces@cs.uiuc.edu" target="_blank">cfe-dev-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:cfe-dev-bounces@cs.uiuc.edu" target="_blank">cfe-dev-bounces@cs.uiuc.edu</a>]
<b>On Behalf Of </b>Daniel Quiñones Lopez</span></span><br></p><div><span style="font-family:Calibri,sans-serif"><span style="font-size:11pt">
<b>Sent:</b> Monday, September 23, 2013 11:18 AM</span></span><br></div>
<div><span style="font-family:Calibri,sans-serif"><span style="font-size:11pt">
<b>To:</b> <a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank">cfe-dev@cs.uiuc.edu</a></span></span><br></div>
<div><span style="font-family:Calibri,sans-serif"><span style="font-size:11pt">
<b>Subject:</b> [cfe-dev] Problem using ast matchers macros</span></span><br></div>
</div>
</div>
<p style="font-family:'Times New Roman',serif;font-size:12pt;margin:0cm 0cm 0.0001pt"><br></p><div><p style="margin:0cm 0cm 12pt;font-family:'Times New Roman',serif;font-size:12pt"><span style="font-family:Calibri,sans-serif">I'm trying to implement an ast matcher for the IHD (hidden variable deletion) operator. For this purpose, i also define two matchers using the ast macros. The
 code is as follows:</span><br></p><blockquote style="margin-top:5.0pt;margin-bottom:5.0pt"><p style="margin:0cm 0cm 12pt;font-family:'Times New Roman',serif;font-size:12pt"><span style="font-family:Calibri,sans-serif">namespace clang{</span><br>
</p><div><span style="font-family:Calibri,sans-serif">
    namespace ast_matchers{</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
      using namespace clang::ast_matchers::internal;</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
      </span><br></div>
<div><span style="font-family:Calibri,sans-serif">
         // Checks that two FieldDecl nodes have the same type</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
        AST_MATCHER_P(FieldDecl, SameType, FieldDecl, f)</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
        {</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
          return Node.getType() == f.getType();</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
        }</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
        </span><br></div>
<div><span style="font-family:Calibri,sans-serif">
        // Checks that two FieldDecl nodes have the same name</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
        AST_MATCHER_P(FieldDecl, SameName, FieldDecl, f)</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
        {</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
          return Node.getName() == f.getName();</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
        }</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
        </span><br></div>
<div><span style="font-family:Calibri,sans-serif">
       </span><br></div>
<div><span style="font-family:Calibri,sans-serif">
    }</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
}</span><br></div>
</blockquote><p style="margin:0cm 0cm 12pt;font-family:'Times New Roman',serif;font-size:12pt"><span style="font-family:Calibri,sans-serif">And the code for the IHD operator is:</span><br></p><blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p style="margin:0cm 0cm 12pt;font-family:'Times New Roman',serif;font-size:12pt"><span style="font-family:Calibri,sans-serif">DeclarationMatcher IHD__Matcher = recordDecl(</span><br></p><div><span style="font-family:Calibri,sans-serif">
                                                              has(</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                                                 fieldDecl().bind("IHD")</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                                              ),</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                                              isDerivedFrom(</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                                                 SameName(</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                                                    SameType(</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                                                       recordDecl(</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                                                          has(</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                                                            fieldDecl()</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                                                          )</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                                                        )</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                                                    )</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                                                 )</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                                              )</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                                           );</span><br></div>
</blockquote><p style="margin:0cm 0cm 12pt;font-family:'Times New Roman',serif;font-size:12pt"><span style="font-family:Calibri,sans-serif">The problem is that when i compile i get the following errors:</span><br>
</p><blockquote style="margin-top:5.0pt;margin-bottom:5.0pt"><p style="margin:0cm 0cm 12pt;font-family:'Times New Roman',serif;font-size:12pt"><span style="font-family:Calibri,sans-serif">clang++ -I/usr/local/include  -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -g -fvisibility-inlines-hidden -fno-exceptions
 -fno-rtti -fPIC -Woverloaded-virtual -Wcast-qual -fno-rtti   -c -o IHD_operator.o IHD_operator.cpp</span><br></p><div><span style="font-family:Calibri,sans-serif">
IHD_operator.cpp:83:6: error: no matching function for call to 'SameType'</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                        SameType(</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                        ^~~~~~~~</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
IHD_operator.cpp:39:28: note: candidate function not viable: no known conversion from 'clang::ast_matchers::internal::BindableMatcher<clang::Decl>' to</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
      'const clang::FieldDecl' for 1st argument</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                AST_MATCHER_P(FieldDecl, SameType, FieldDecl, f)</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                         ^</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
/usr/local/include/clang/ASTMatchers/ASTMatchersMacros.h:86:32: note: expanded from macro 'AST_MATCHER_P'</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
  AST_MATCHER_P_OVERLOAD(Type, DefineMatcher, ParamType, Param, 0)</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                               ^</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
/usr/local/include/clang/ASTMatchers/ASTMatchersMacros.h:104:34: note: expanded from macro 'AST_MATCHER_P_OVERLOAD'</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
  inline internal::Matcher<Type> DefineMatcher(const ParamType &Param) {       \</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
                                 ^</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
1 error generated.</span><br></div>
<div><span style="font-family:Calibri,sans-serif">
make: *** [IHD_operator.o] Error 1</span><br></div>
</blockquote><p style="font-family:'Times New Roman',serif;font-size:12pt;margin:0cm 0cm 0.0001pt"><span style="font-family:Calibri,sans-serif">I don't know why is trying to make a conversion to FieldDecl from Decl if it is supose to be receiving a FieldDecl type param.</span><br>
</p></div>
</div>
</div>
</div></div><div><u>_______________________________________________</u><br></div>
<div>cfe-dev mailing list<br></div>
<div><a href="mailto:cfe-dev@cs.uiuc.edu" style="text-decoration:underline;color:rgb(5,99,193)" target="_blank">cfe-dev@cs.uiuc.edu</a><br></div>
<div><a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" style="text-decoration:underline;color:rgb(5,99,193)" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br></div>
</blockquote></div>

<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>