<div dir="ltr"><div class="gmail_quote"><div>(cfe-dev back in)</div><div><br></div><div dir="ltr">On Mon, Jul 4, 2016 at 10:26 AM Farzad Sadeghi <<a href="mailto:thabogre@gmail.com">thabogre@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Are you using clang as the compiler?<br>
I'm using g++ and the library built using g++. maybe that's what's causing this.<br></blockquote><div><br></div><div>Yea, I'm using a recent enough clang. My system GCC is unfortunately super old (ubuntu LTS). The interesting part would be to reduce it so we can see which compiler has the bug.</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 7/4/16, Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:<br>
> On Fri, Jul 1, 2016 at 3:15 PM Farzad Sadeghi via cfe-dev <<br>
> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
>> i have the following ASTMatcher:<br>
>><br>
>> `functionDecl(forEachDescendant(expr(allOf(forEachDescendant(callExpr(anyOf(hasDescendant(declRefExpr(to(varDecl(anything()))).bind("args")),<br>
>> unless(hasDescendant(declRefExpr(to(varDecl(anything()))))))<br>
>><br>
>> ).bind("callee")),unless(hasAncestor(binaryOperator())))).bind("expression"))).bind("scopeDaddy")`.<br>
>> it compiles and works fine both after building and running it and also<br>
>> in clang-query.<br>
>> i needed to make some changes to it so i wrote this one:<br>
>><br>
>> `functionDecl(forEachDescendant(anyOf(expr(allOf(forEachDescendant(callExpr(anyOf(hasDescendant(declRefExpr(to(varDecl(anything()))).bind("args")),<br>
>> unless(hasDescendant(declRefExpr(to(varDecl(anything()))))))<br>
>><br>
>> ).bind("callee")),unless(hasAncestor(binaryOperator())))).bind("expression"),<br>
>><br>
>> callExpr(unless(hasAncestor(expr()))).bind("orphancall")))).bind("scopeDaddy")`<br>
>> when i run it in clang-query it runs without a problem but when i put<br>
>> that in my code and try to compile it, the compiler returns this:<br>
>><br>
>> -----------------------------------------------------------------------------------------------------------------------------<br>
>> tokenizer.cpp: In constructor<br>
>> ‘TokenizerASTConsumer::TokenizerASTConsumer(clang::Rewriter&)’:<br>
>> tokenizer.cpp:544:348: error: no match for call to ‘(const<br>
>><br>
>> clang::ast_matchers::internal::ArgumentAdaptingMatcherFunc<clang::ast_matchers::internal::ForEachDescendantMatcher>)<br>
>><br>
>> (clang::ast_matchers::internal::VariadicOperatorMatcher<clang::ast_matchers::internal::Matcher<clang::Stmt>,<br>
>> clang::ast_matchers::internal::BindableMatcher<clang::Stmt> >)’<br>
>> Decl(anything()))))))<br>
>><br>
>> ).bind("callee")),unless(hasAncestor(binaryOperator())))).bind("expression"),<br>
>> callExpr(unless(hasAncestor(expr())))))).bind("sc<br>
>><br>
>> ^<br>
>> In file included from<br>
>> /usr/local/include/clang/ASTMatchers/ASTMatchers.h:52:0,<br>
>> from tokenizer.cpp:15:<br>
>> /usr/local/include/clang/ASTMatchers/ASTMatchersInternal.h:1043:14:<br>
>> note: candidate: template<class T><br>
>><br>
>> clang::ast_matchers::internal::ArgumentAdaptingMatcherFunc<ArgumentAdapterT,<br>
>> FromTypes, ToTypes>::Adaptor<T><br>
>><br>
>> clang::ast_matchers::internal::ArgumentAdaptingMatcherFunc<ArgumentAdapterT,<br>
>> FromTypes, ToTypes>::operator()(const<br>
>> clang::ast_matchers::internal::Matcher<From>&) const [with T = T;<br>
>> ArgumentAdapterT =<br>
>> clang::ast_matchers::internal::ForEachDescendantMatcher; FromTypes =<br>
>> clang::ast_matchers::internal::TypeList<clang::Decl, clang::Stmt,<br>
>> clang::NestedNameSpecifier, clang::NestedNameSpecifierLoc,<br>
>> clang::QualType, clang::Type, clang::TypeLoc,<br>
>> clang::CXXCtorInitializer>; ToTypes =<br>
>> clang::ast_matchers::internal::TypeList<clang::Decl, clang::Stmt,<br>
>> clang::NestedNameSpecifier, clang::NestedNameSpecifierLoc,<br>
>> clang::TypeLoc, clang::QualType>]<br>
>> Adaptor<T> operator()(const Matcher<T> &InnerMatcher) const {<br>
>> ^<br>
>> /usr/local/include/clang/ASTMatchers/ASTMatchersInternal.h:1043:14:<br>
>> note: template argument deduction/substitution failed:<br>
>> tokenizer.cpp:544:348: note:<br>
>><br>
>> ‘clang::ast_matchers::internal::VariadicOperatorMatcher<clang::ast_matchers::internal::Matcher<clang::Stmt>,<br>
>> clang::ast_matchers::internal::BindableMatcher<clang::Stmt> >’ is not<br>
>> derived from ‘const clang::ast_matchers::internal::Matcher<T>’<br>
>> Decl(anything()))))))<br>
>><br>
>> ).bind("callee")),unless(hasAncestor(binaryOperator())))).bind("expression"),<br>
>> callExpr(unless(hasAncestor(expr())))))).bind("sc<br>
>><br>
>><br>
>> ------------------------------------------------------------------------------------------------------------------------------<br>
>> I've built my llvm and clang libraries from the SVN version 3.9.0<br>
>> using g++ and use g++ 5.3.1 to compile this code .<br>
>> is the matcher wrong and clang-query fails to see that(even though it<br>
>> acts exactly as i intended it to) or it's something else?<br>
>><br>
><br>
> Hrm, for me with clang trunk this matcher compiles just fine.<br>
><br>
><br>
><br>
>><br>
>><br>
>><br>
>> --<br>
>> Farzad Sadeghi<br>
>> _______________________________________________<br>
>> cfe-dev mailing list<br>
>> <a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
>><br>
><br>
<br>
<br>
--<br>
Farzad Sadeghi<br>
</blockquote></div></div>