<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FR" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hello,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-US">I’m trying to write a matcher for a break in a for loop. I’m writing it that way:<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">        breakStmt</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:teal">(</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">            hasAncestor(anyOf</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:teal">(</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">                forStmt</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:teal">()</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">.bind(breakForParent),
</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:green">// A break can happen in a for</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">                doStmt</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:teal">()</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">,
</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:green">// or in another loop</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">                whileStmt</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:teal">()</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">,<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">                cxxForRangeStmt</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:teal">()</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">,<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">                switchStmt</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:teal">()</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">
</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:green">// or in a switch</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black">           
</span><span style="font-size:9.5pt;font-family:Consolas;color:teal">)</span><span style="font-size:9.5pt;font-family:Consolas;color:black">)<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">The goal is to match the closest ancestor that can have some meaning for a break statement, and detect if it is a for loop or another statement.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">This looks to work fine when I’m in clang-query, but when I try to compile the code (with visual C++), I have the following error:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:red">1>c:\dev\klangation\caip\src\analyzers\ccpp\klang\cppqr.cpp(149): error C2784: 'clang::ast_matchers::internal::ArgumentAdaptingMatcherFunc<clang::ast_matchers::internal::HasAncestorMatcher,clang::ast_matchers::internal::TypeList<clang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc>,clang::ast_matchers::internal::TypeList<clang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc>>::Adaptor<T>
 clang::ast_matchers::internal::ArgumentAdaptingMatcherFunc<clang::ast_matchers::internal::HasAncestorMatcher,clang::ast_matchers::internal::TypeList<clang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc>,clang::ast_matchers::internal::TypeList<clang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc>>::operator
 ()(const clang::ast_matchers::internal::Matcher<From> &) const' : could not deduce template argument for 'const clang::ast_matchers::internal::Matcher<From> &' from 'clang::ast_matchers::internal::VariadicOperatorMatcher<clang::ast_matchers::internal::Matcher<clang::Stmt>,ResultT,ResultT,ResultT,ResultT>'</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:gray">1>        with</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:gray">1>        [</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:gray">1>            ResultT=clang::ast_matchers::internal::BindableMatcher<clang::Stmt></span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:gray">1>        ]</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:gray">1>        c:\users\ljo\.conan\data\llvm\3.9.0.5\yle\stable\package\2c0843cc59ff2d07e33c808b3398bc624e6b54e4\include\clang\astmatchers\astmatchersinternal.h(1054)
 : see declaration of 'clang::ast_matchers::internal::ArgumentAdaptingMatcherFunc<clang::ast_matchers::internal::HasAncestorMatcher,clang::ast_matchers::internal::TypeList<clang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc>,clang::ast_matchers::internal::TypeList<clang::Decl,clang::NestedNameSpecifierLoc,clang::Stmt,clang::TypeLoc>>::operator
 ()'</span><span lang="EN-US" style="font-size:9.5pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Is this something I’m not supposed to do, or is it more something like a bug in clang or in my compiler?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thank you,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">--- <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Loïc Joly<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
</body>
</html>