<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>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:<br><br><blockquote>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>}<br><br></blockquote>And the code for the IHD operator is:<br><br><blockquote>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>                                                           );<br><br></blockquote>The problem is that when i compile i get the following errors:<br><br><blockquote>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<br><br></blockquote>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.<br>                                     </div></body>
</html>