<div dir="ltr">I am building most recent debug build right now, but what I saw in the code, there was no chanes in ASTTypeTraits.* files since so I don't excpect it will make a difference.</div><div class="gmail_extra"><br><div class="gmail_quote">2016-04-12 20:23 GMT+02:00 Alexander Kornienko <span dir="ltr"><<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I use an assertions-enabled build of clang-query built just a few hours ago.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 12, 2016 at 8:00 PM, Piotr Padlewski <span dir="ltr"><<a href="mailto:piotr.padlewski@gmail.com" target="_blank">piotr.padlewski@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Are you using debug build?<div>when I use the second matcher that you have send I got core dump.</div><div><br></div><div><a href="http://pastebin.com/Z6V3jC3X" target="_blank">http://pastebin.com/Z6V3jC3X</a><br></div><div><br></div><div>I am not using the most recent clang trunk, but someting about 2 weeks old, but I don't think it is the case.</div><div>BTW on other build it works perfectly, it doesn;t crash etc, but it has asserts disabled.</div><div><br></div><div><br></div><div><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2016-04-12 19:50 GMT+02:00 Alexander Kornienko <span dir="ltr"><<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">FWIW, a larger part of your matcher also works fine in clang-query:<div><span><div>$ cat /tmp/q.cc </div><div>namespace boost {</div><div>template <typename T, typename C></div><div>T lexical_cast(const C&) {</div><div>  return T();</div><div>}</div><div>}</div><div><br></div><div>namespace std {</div><div>template <typename T></div><div>class basic_string {};</div><div>using string = basic_string<char>;</div><div>}</div><div><br></div><div>int g();</div><div>long long f(int p);</div><div>using namespace boost;</div><div><br></div><div>template <typename T></div><div>void string_as_T() {</div><div>  boost::lexical_cast<T>(42);</div><div>}</div><div><br></div><div>int main() {</div><div>  string_as_T<std::string>();</div></span><div>  boost::lexical_cast<std::string>(24);</div><div>}</div></div><div><br></div><div><span><div>$ clang-query /tmp/q.cc -- -std=c++11</div></span><div>clang-query> m callExpr(hasDeclaration(functionDecl(returns(hasDeclaration(classTemplateSpecializationDecl(hasName("std::basic_string"),hasTemplateArgument(0,templateArgument().bind("char_type"))))),hasName("boost::lexical_cast"),hasParameter(0, hasType(qualType())))),argumentCountIs(1))<br></div><span><div><br></div><div>Match #1:</div><div><br></div><div>/tmp/q.cc:20:3: note: "root" binds here</div><div>  boost::lexical_cast<T>(42);</div><div>  ^~~~~~~~~~~~~~~~~~~~~~~~~~</div><div><br></div><div>Match #2:</div><div><br></div></span><div>/tmp/q.cc:25:3: note: "root" binds here</div><div>  boost::lexical_cast<std::string>(24);</div><div>  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</div><div>2 matches.</div><div>clang-query> m callExpr(hasDeclaration(functionDecl(returns(hasDeclaration(classTemplateSpecializationDecl(hasName("std::basic_string"),hasTemplateArgument(0,templateArgument().bind("char_type"))))),hasName("boost::lexical_cast"),hasParameter(0, hasType(qualType())))),argumentCountIs(1),unless(isInTemplateInstantiation()))</div><div><br></div><div>Match #1:</div><div><br></div><div>/tmp/q.cc:25:3: note: "root" binds here</div><div>  boost::lexical_cast<std::string>(24);</div><div>  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</div><div>1 match.</div><div>clang-query> ^D</div></div><div><br></div><div><br></div><div>(the first matcher lacks the `unless(isInTemplateInstantiation())` part, the second one has it, hence it skips the match in a template instantiation).</div><div><br></div><div>The only part of your matcher that is missing from this example is `has(substTemplateTypeParmType(isStrictlyInteger()))` that needs a locally-defined matcher `isStrictlyInteger()`.</div><div><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Apr 12, 2016 at 7:44 PM, Piotr Padlewski <span dir="ltr"><<a href="mailto:piotr.padlewski@gmail.com" target="_blank">piotr.padlewski@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">It requires this patch:<div><a href="http://reviews.llvm.org/D18274" target="_blank">http://reviews.llvm.org/D18274</a><br></div><div><br></div><div>I am trying to reproduce it right now with clang-query</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2016-04-12 19:27 GMT+02:00 Alexander Kornienko <span dir="ltr"><<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I can't reproduce the issue (how I understand it) using clang-query, and <a href="http://reviews.llvm.org/D18136" target="_blank">http://reviews.llvm.org/D18136</a> doesn't apply cleanly, since it depends on some other patch.<div><br></div><div><div>$ cat /tmp/q.cc </div><div>namespace boost {</div><div>template <typename T, typename C></div><div>T lexical_cast(const C&) {</div><div>  return T();</div><div>}</div><div>}</div><div><br></div><div>namespace std {</div><div>template <typename T></div><div>class basic_string {};</div><div>using string = basic_string<char>;</div><div>}</div><div><br></div><div>int g();</div><div>long long f(int p);</div><div>using namespace boost;</div><div><br></div><div>template <typename T></div><div>void string_as_T() {</div><div>  boost::lexical_cast<T>(42);</div><div>}</div><div><br></div><div>int main() { string_as_T<std::string>(); }</div></div><div><br></div><div><div>$ clang-query /tmp/q.cc -- -std=c++11</div><div>clang-query> m callExpr()</div><div><br></div><div>Match #1:</div><div><br></div><div>/tmp/q.cc:20:3: note: "root" binds here</div><div>  boost::lexical_cast<T>(42);</div><div>  ^~~~~~~~~~~~~~~~~~~~~~~~~~</div><div><br></div><div>Match #2:</div><div><br></div><div>/tmp/q.cc:20:3: note: "root" binds here</div><div>  boost::lexical_cast<T>(42);</div><div>  ^~~~~~~~~~~~~~~~~~~~~~~~~~</div><div><br></div><div>Match #3:</div><div><br></div><div>/tmp/q.cc:23:14: note: "root" binds here</div><div>int main() { string_as_T<std::string>(); }</div><div>             ^~~~~~~~~~~~~~~~~~~~~~~~~~</div><div>3 matches.</div><div>clang-query> m callExpr(unless(isInTemplateInstantiation()))</div><div><br></div><div>Match #1:</div><div><br></div><div>/tmp/q.cc:20:3: note: "root" binds here</div><div>  boost::lexical_cast<T>(42);</div><div>  ^~~~~~~~~~~~~~~~~~~~~~~~~~</div><div><br></div><div>Match #2:</div><div><br></div><div>/tmp/q.cc:23:14: note: "root" binds here</div><div>int main() { string_as_T<std::string>(); }</div><div>             ^~~~~~~~~~~~~~~~~~~~~~~~~~</div><div>2 matches.</div><div>clang-query> </div></div><div><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 7, 2016 at 8:25 PM, Piotr Padlewski <span dir="ltr"><<a href="mailto:piotr.padlewski@gmail.com" target="_blank">piotr.padlewski@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This should be enough to break this matcher<div><a href="http://pastebin.com/CH7a3hur" target="_blank">http://pastebin.com/CH7a3hur</a><br></div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2016-04-07 18:56 GMT+02:00 Alexander Kornienko <span dir="ltr"><<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Can you provide a minimal test for this?</div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 7, 2016 at 4:04 PM, Piotr Padlewski <span dir="ltr"><<a href="mailto:piotr.padlewski@gmail.com" target="_blank">piotr.padlewski@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">bump.</div><div><div><div class="gmail_extra"><br><div class="gmail_quote">2016-04-04 20:48 GMT+02:00 Piotr Padlewski <span dir="ltr"><<a href="mailto:piotr.padlewski@gmail.com" target="_blank">piotr.padlewski@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br></div><div>Hi guys,</div><div>I am having trobles with isInTemplateInstantiation matcher. When I run my matcher (<a href="http://reviews.llvm.org/D18136" target="_blank">http://reviews.llvm.org/D18136</a>), it fails on the assert in ASTTypeTraits.h:299, when KindId is NodeKindId::NKI_TemplateArgument.</div><div><br></div><div>I think my matcher is fine, and there is bug somewhere. Can someone please tell me if I am doing something wrong, and if not, why it doesn't work and what I should fix?</div><div><br></div><div>Here is my backtrace <a href="http://4programmers.net/Pastebin/5347" target="_blank">http://4programmers.net/Pastebin/5347</a></div><div><br></div><div>Best</div><span><font color="#888888"><div>Piotr</div></font></span></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>