<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 3, 2015 at 10:19 AM, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank" class="cremed">klimek@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br><br><div class="gmail_quote"><span class="">On Thu Dec 25 2014 at 8:50:46 PM mobi phil <<a href="mailto:mobi@mobiphil.com" target="_blank" class="cremed">mobi@mobiphil.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>On the page,</div><div><br></div><div><br></div><div><br></div><div><a href="http://clang.llvm.org/docs/LibASTMatchers.html" target="_blank" class="cremed">http://clang.llvm.org/docs/LibASTMatchers.html</a><br></div><div><br></div><div>it is stated </div><div><br></div><div><span style="color:rgb(51,51,51);font-family:'DejaVu Sans',Arial,Helvetica,sans-serif;font-size:14px;line-height:21.6000003814697px;text-align:justify">"By default, matchers that accept multiple inner matchers use an implicit </span><a href="http://clang.llvm.org/docs/LibASTMatchersReference.html#allOf0Anchor" style="font-weight:bold;text-decoration:none;color:rgb(137,38,1);font-family:'DejaVu Sans',Arial,Helvetica,sans-serif;font-size:14px;line-height:21.6000003814697px;text-align:justify" target="_blank" class="cremed">allOf()</a><span style="color:rgb(51,51,51);font-family:'DejaVu Sans',Arial,Helvetica,sans-serif;font-size:14px;line-height:21.6000003814697px;text-align:justify">. This allows further narrowing down the match, for example to match all classes that are derived from “</span><tt style="font-size:1em;color:rgb(51,51,51);text-align:justify;background-color:rgb(226,226,226)"><span>Bar</span></tt><span style="color:rgb(51,51,51);font-family:'DejaVu Sans',Arial,Helvetica,sans-serif;font-size:14px;line-height:21.6000003814697px;text-align:justify">”: </span><tt style="font-size:1em;color:rgb(51,51,51);text-align:justify;background-color:rgb(226,226,226)"><span>recordDecl(hasName("Foo"),</span> <span>isDerivedFrom("Bar"))</span></tt><span style="color:rgb(51,51,51);font-family:'DejaVu Sans',Arial,Helvetica,sans-serif;font-size:14px;line-height:21.6000003814697px;text-align:justify">."</span></div></div></blockquote><div><br></div></span><div>This works because isDerivedFrom has an overload that takes a StringRef.</div><span class=""><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>trying that with text based matchers, no result is returned. The correct would be</div><div><br></div><div><tt style="font-size:1em;color:rgb(51,51,51);text-align:justify;background-color:rgb(226,226,226)"><span>recordDecl(hasName("Foo"),</span> <span>isDerivedFrom(recordDecl(hasName("Bar")))</span></tt><br></div><div><tt style="font-size:1em;color:rgb(51,51,51);text-align:justify;background-color:rgb(226,226,226)"><span><br></span></tt></div><div>Or the text based matchers do not behave exactly as the equivalent C++ matchers?<br></div><div><br></div><div>do not care that much about this little mistake in the docu. (if it is a mistake). I care more to know if the string based matchers should behave exactly as the C++ matchers.</div><div><br></div></div></blockquote><div><br></div></span><div>I'm not sure that this is possible (cc'ed Sam); generally, the text based AST matchers will always be a simplified version, as they cannot rely on all the template magic going on.</div></div></blockquote><div><br></div><div>This case is a simple function overloading, no templates involved. It is supported in the dynamic matchers.</div><div>If isDerivedFrom() didn't accept a string it would give you an error instead of "0 matches".</div><div>The problem here is that matchers created with the macros should not take StringRef. This is causing a dangling pointer because the string passed to the matcher constructor is destroyed before the matcher is executed. Running under ASan shows the problem.</div><div><br></div><div>I'll send a fix for it.</div><div>Thanks for the report!</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><div dir="ltr"><div></div><div><br></div><div><div>rgrds,<br>mobi phil<br><br>being mobile, but including technology<br><a href="http://mobiphil.com" target="_blank" class="cremed">http://mobiphil.com</a></div>
</div></div></span>
______________________________<u></u>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu" target="_blank" class="cremed">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank" class="cremed">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/cfe-dev</a><br>
</blockquote></div>
</blockquote></div><br></div></div>