<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi, thanks for your answer!
<div class="">Your second matcher proposal captures the right behavior: I want to match </div>
<div class="">declarations that are of any kind but that specific one.</div>
<div class="">On the internet I read to use clang-query to prototype matchers, so I was pretty surprised</div>
<div class="">that it didn't work when I copied it over.</div>
<div class="">Best,</div>
<div class="">Siegfried</div>
<div class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 17Nov, 2020, at 13:01, Stephen Kelly <<a href="mailto:steveire@gmail.com" class="">steveire@gmail.com</a>> wrote:</div>
<div class="">
<div class="">
<p class="">clang-query parsing is less strict than the c++ language, so there are probably a few of these differences.</p>
<p class="">I assume you realize that you should instead use either <br class="">
</p>
<p class="">unless(has()) <br class="">
</p>
<p class="">or <br class="">
</p>
<p class="">has(decl(unless(cxxRecordDecl())))<br class="">
</p>
<p class="">depending on what you are trying to achieve?</p>
<p class=""><br class="">
</p>
<div class="moz-cite-prefix">On 16/11/2020 17:33, Hartogs Siegfried via cfe-dev wrote:<br class="">
</div>
<blockquote type="cite" cite="mid:310C304E-9E8A-4A2D-BDB2-771ACFC83306@student.ethz.ch" class="">
A minimal code sample to trigger the error:<br class="">
<div class=""><br class="">
<div class="">
<div class="">#include "clang/ASTMatchers/ASTMatchers.h"</div>
<div class=""><br class="">
</div>
<div class="">using namespace clang::ast_matchers;</div>
<div class=""><br class="">
</div>
<div class="">int main(int argc, char** argv){</div>
<div class=""> auto m = cxxRecordDecl(has(unless(cxxRecordDecl())));</div>
<div class=""> return 0;</div>
<div class=""><br class="">
</div>
<div class="">}</div>
<div class=""><br class="">
</div>
<div class="">Best, Siegfried</div>
<div class=""><br class="">
<blockquote type="cite" class="">
<div class="">On 16Nov, 2020, at 16:57, Hartogs Siegfried <<a href="mailto:hartogss@student.ethz.ch" class="" moz-do-not-send="true">hartogss@student.ethz.ch</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode:
space; line-break: after-white-space;" class="">
Hello everyone,
<div class=""><br class="">
</div>
<div class="">Why is it that the following matcher </div>
<div class=""><br class="">
</div>
<div class="">
<div style="margin: 0px; font-stretch: normal;
line-height: normal;" class="">
<font class="" face="Ubuntu Mono">cxxRecordDecl(has(unless(cxxRecordDecl())))</font></div>
</div>
<div style="margin: 0px; font-stretch: normal;
line-height: normal;" class="">
<font class="" face="Ubuntu Mono"><br class="">
</font></div>
<div style="margin: 0px; font-stretch: normal;
line-height: normal;" class="">
works in clang-query, but when copied to to a .cpp file, it won't compile the matcher:</div>
<div style="margin: 0px; font-stretch: normal;
line-height: normal;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal;
line-height: normal;" class="">
<div style="margin: 0px; font-stretch: normal;
line-height: normal; font-family: "Ubuntu
Mono";" class="">
<span style="font-variant-ligatures:
no-common-ligatures;" class="">../lib/UsingAnalysis.cpp:46:29:
</span><span style="font-variant-ligatures:
no-common-ligatures;" class="">error:
</span><span style="font-variant-ligatures:
no-common-ligatures;" class="">no matching function for call to object of type 'const internal::ArgumentAdaptingMatcherFunc<internal::HasMatcher>'</span></div>
<div style="margin: 0px; font-stretch: normal;
line-height: normal; font-family: "Ubuntu
Mono";" class="">
<span style="font-variant-ligatures:
no-common-ligatures" class=""> auto m = cxxRecordDecl(has(unless(cxxRecordDecl())));</span></div>
<div style="margin: 0px; font-stretch: normal;
line-height: normal; font-family: "Ubuntu
Mono";" class="">
<span style="font-variant-ligatures:
no-common-ligatures" class=""> ^~~</span></div>
<div style="margin: 0px; font-stretch: normal;
line-height: normal; font-family: "Ubuntu
Mono";" class="">
<span style="font-variant-ligatures:
no-common-ligatures;" class="">/usr/local/include/clang/ASTMatchers/ASTMatchersInternal.h:1183:3:
</span><span style="font-variant-ligatures:
no-common-ligatures;" class="">note:
</span><span style="font-variant-ligatures:
no-common-ligatures" class="">candidate template ignored: could not match 'Matcher' against 'VariadicOperatorMatcher'</span></div>
<div style="margin: 0px; font-stretch: normal;
line-height: normal; font-family: "Ubuntu
Mono";" class="">
<span style="font-variant-ligatures:
no-common-ligatures;" class=""> operator()(const Matcher<T> &InnerMatcher) const {</span></div>
<div style="margin: 0px; font-stretch: normal;
line-height: normal; font-family: "Ubuntu
Mono";" class="">
<span style="font-variant-ligatures:
no-common-ligatures;" class=""><br class="">
</span></div>
<div style="margin: 0px; font-stretch: normal;
line-height: normal;" class="">
Tried on macOS 10.13 & Ubuntu 20.04 with LLVM 11.0.0.</div>
<div style="margin: 0px; font-stretch: normal;
line-height: normal;" class="">
<br class="">
</div>
<div style="margin: 0px; font-stretch: normal;
line-height: normal;" class="">
Best,</div>
<div style="margin: 0px; font-stretch: normal;
line-height: normal;" class="">
Siegfried</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
<br class="">
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</div>
</body>
</html>