<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">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.<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></a></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 class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""> cfe-dev-bounces@cs.uiuc.edu [mailto:cfe-dev-bounces@cs.uiuc.edu]
<b>On Behalf Of </b>Daniel Quiñones Lopez<br>
<b>Sent:</b> Monday, September 23, 2013 11:18 AM<br>
<b>To:</b> cfe-dev@cs.uiuc.edu<br>
<b>Subject:</b> [cfe-dev] Problem using ast matchers macros<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><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:<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Calibri","sans-serif"">namespace clang{<br>
    namespace ast_matchers{<br>
      using namespace clang::ast_matchers::internal;<br>
      <br>
         // Checks that two FieldDecl nodes have the same type<br>
        AST_MATCHER_P(FieldDecl, SameType, FieldDecl, f)<br>
        {<br>
          return Node.getType() == f.getType();<br>
        }<br>
        <br>
        // Checks that two FieldDecl nodes have the same name<br>
        AST_MATCHER_P(FieldDecl, SameName, FieldDecl, f)<br>
        {<br>
          return Node.getName() == f.getName();<br>
        }<br>
        <br>
       <br>
    }<br>
}<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Calibri","sans-serif"">And the code for the IHD operator is:<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Calibri","sans-serif"">DeclarationMatcher IHD__Matcher = recordDecl(<br>
                                                              has(<br>
                                                                 fieldDecl().bind("IHD")<br>
                                                              ),<br>
                                                              isDerivedFrom(<br>
                                                                 SameName(<br>
                                                                    SameType(<br>
                                                                       recordDecl(<br>
                                                                          has(<br>
                                                                            fieldDecl()<br>
                                                                          )<br>
                                                                        )<br>
                                                                    )<br>
                                                                 )<br>
                                                              )<br>
                                                           );<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-family:"Calibri","sans-serif"">The problem is that when i compile i get the following errors:<o:p></o:p></span></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt"><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<br>
IHD_operator.cpp:83:6: error: no matching function for call to 'SameType'<br>
                                        SameType(<br>
                                        ^~~~~~~~<br>
IHD_operator.cpp:39:28: note: candidate function not viable: no known conversion from 'clang::ast_matchers::internal::BindableMatcher<clang::Decl>' to<br>
      'const clang::FieldDecl' for 1st argument<br>
                AST_MATCHER_P(FieldDecl, SameType, FieldDecl, f)<br>
                                         ^<br>
/usr/local/include/clang/ASTMatchers/ASTMatchersMacros.h:86:32: note: expanded from macro 'AST_MATCHER_P'<br>
  AST_MATCHER_P_OVERLOAD(Type, DefineMatcher, ParamType, Param, 0)<br>
                               ^<br>
/usr/local/include/clang/ASTMatchers/ASTMatchersMacros.h:104:34: note: expanded from macro 'AST_MATCHER_P_OVERLOAD'<br>
  inline internal::Matcher<Type> DefineMatcher(const ParamType &Param) {       \<br>
                                 ^<br>
1 error generated.<br>
make: *** [IHD_operator.o] Error 1<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><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.<o:p></o:p></span></p>
</div>
</div>
</div>
</body>
</html>