<div dir="ltr">(larger list back in, please reply-to all, not just me, thanks! :)<br><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 4, 2016 at 11:44 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">i just checked the matcher using clang++ and llvm-devel and<br>
clang-devel that i just got from Fedora's repository (3.7.0.). The<br>
problem is when the four special Narrowing matchers (anyOf, allOf,<br>
anything, unless) are passed as argument to `forEachDescendant`.<br></blockquote><div><br></div><div>Previously there were limits with return type deduction, which we do with expression templates that have a templated conversion operator. I think Sam (cc'ed) fixed that at some point. If this doesn't work with gcc, it's either a clang or gcc bug. We need to reduce this in a way that doesn't require the AST matchers.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On 7/4/16, Manuel Klimek <<a href="mailto:klimek@google.com" target="_blank">klimek@google.com</a>> wrote:<br>
> (cfe-dev back in)<br>
><br>
> On Mon, Jul 4, 2016 at 10:26 AM Farzad Sadeghi <<a href="mailto:thabogre@gmail.com" target="_blank">thabogre@gmail.com</a>> wrote:<br>
><br>
>> Are you using clang as the compiler?<br>
>> I'm using g++ and the library built using g++. maybe that's what's<br>
>> causing<br>
>> this.<br>
>><br>
><br>
> Yea, I'm using a recent enough clang. My system GCC is unfortunately super<br>
> old (ubuntu LTS). The interesting part would be to reduce it so we can see<br>
> which compiler has the bug.<br>
><br>
><br>
> 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>
>> >><br>
>> `functionDecl(forEachDescendant(expr(allOf(forEachDescendant(callExpr(anyOf(hasDescendant(declRefExpr(to(varDecl(anything()))).bind("args")),<br>
>> >> unless(hasDescendant(declRefExpr(to(varDecl(anything()))))))<br>
>> >><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>
>> >><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>
>> >><br>
>> ).bind("callee")),unless(hasAncestor(binaryOperator())))).bind("expression"),<br>
>> >><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>
>> -----------------------------------------------------------------------------------------------------------------------------<br>
>> >> tokenizer.cpp: In constructor<br>
>> >> ‘TokenizerASTConsumer::TokenizerASTConsumer(clang::Rewriter&)’:<br>
>> >> tokenizer.cpp:544:348: error: no match for call to ‘(const<br>
>> >><br>
>> >><br>
>> clang::ast_matchers::internal::ArgumentAdaptingMatcherFunc<clang::ast_matchers::internal::ForEachDescendantMatcher>)<br>
>> >><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>
>> >><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>
>> >><br>
>> clang::ast_matchers::internal::ArgumentAdaptingMatcherFunc<ArgumentAdapterT,<br>
>> >> FromTypes, ToTypes>::Adaptor<T><br>
>> >><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>
>> >><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>
>> >><br>
>> ).bind("callee")),unless(hasAncestor(binaryOperator())))).bind("expression"),<br>
>> >> callExpr(unless(hasAncestor(expr())))))).bind("sc<br>
>> >><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>
>><br>
><br>
<br>
<br>
--<br>
Farzad Sadeghi<br>
</blockquote></div></div>