<div dir="ltr">Sorry for the late reply.<div><br></div><div>If you want to see an example of flow-sensitive analysis in clang-tidy, take a look at UseAfterMoveCheck.cpp.</div><div><br></div><div>That said, I also don't see yet why a lexical analysis isn't sufficient (i.e. check whether the throw is lexically contained within the catch, with special handling at the boundaries of lambdas) -- though I'm sure I'm just missing something. Can you provide a link to Aaron's review?</div><div><br></div><div>This article has a good overview of some of the intricacies of noexcept:</div><div><br></div><div><a href="https://akrzemi1.wordpress.com/2011/06/10/using-noexcept/">https://akrzemi1.wordpress.com/2011/06/10/using-noexcept/</a><br></div><div><br></div><div>In particular, it has some good examples of functions that can be marked noexcept, even though they call non-noexcept functions, and vice versa (think of a function whose implementation happens not to throw today but which doesn't want to make that guarantee in its contract). So you'll need some way of marking false positives and false negatives as intentional.</div><div><br></div><div>An additional wrinkle is when the argument to noexcept depends on a template argument -- you may want to initially just ignore these cases.</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On 17 March 2017 at 10:17, Manuel Klimek <span dir="ltr"><<a href="mailto:klimek@google.com" target="_blank">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"><div dir="ltr"><div class="gmail_quote"><span class=""><div dir="ltr">On Thu, Mar 16, 2017 at 7:06 PM Devin Coughlin <<a href="mailto:dcoughlin@apple.com" target="_blank">dcoughlin@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="m_5797712198930751463gmail_msg"><div class="m_5797712198930751463gmail_msg"><blockquote type="cite" class="m_5797712198930751463gmail_msg"><div class="m_5797712198930751463gmail_msg">On Mar 16, 2017, at 4:42 AM, Manuel Klimek via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="m_5797712198930751463gmail_msg" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="m_5797712198930751463m_3969686606020480451Apple-interchange-newline m_5797712198930751463gmail_msg"><div class="m_5797712198930751463gmail_msg"><div dir="ltr" class="m_5797712198930751463gmail_msg">Yea, none of these seem to be path sensitive, but only flow sensitive, which clang-tidy supports.</div></div></blockquote><div class="m_5797712198930751463gmail_msg"><br class="m_5797712198930751463gmail_msg"></div></div></div><div style="word-wrap:break-word" class="m_5797712198930751463gmail_msg"><div class="m_5797712198930751463gmail_msg"><div class="m_5797712198930751463gmail_msg">I’m surprised that even flow sensitivity is needed. I would have thought a purely lexical analysis on the AST would be sufficient. What is the case where the analysis would need to compute per-program-point facts?</div></div></div></blockquote><div><br></div></span><div>Well, will depend on whether you'll count analyzing where the "throw" and the corresponding "catch" is as flow sensitive (I would, but I'm no expert :)</div><div><div class="h5"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="m_5797712198930751463gmail_msg"><div class="m_5797712198930751463gmail_msg"><div class="m_5797712198930751463gmail_msg"><br class="m_5797712198930751463gmail_msg"></div><div class="m_5797712198930751463gmail_msg">I could see context sensitivity being useful (to look through calls to unannotated functions) — but with the exception of function pointers and virtual calls I would expect calls to be better handled by analyzing the call graph from the bottom up, inferring the exception behavior for callees before analyzing the caller.</div></div></div><div style="word-wrap:break-word" class="m_5797712198930751463gmail_msg"><div class="m_5797712198930751463gmail_msg"><div class="m_5797712198930751463gmail_msg"><br class="m_5797712198930751463gmail_msg"></div><div class="m_5797712198930751463gmail_msg">Devin</div></div></div><div style="word-wrap:break-word" class="m_5797712198930751463gmail_msg"><div class="m_5797712198930751463gmail_msg"><div class="m_5797712198930751463gmail_msg"><br class="m_5797712198930751463gmail_msg"></div><br class="m_5797712198930751463gmail_msg"><blockquote type="cite" class="m_5797712198930751463gmail_msg"><div class="m_5797712198930751463gmail_msg"><div dir="ltr" class="m_5797712198930751463gmail_msg"><div class="m_5797712198930751463gmail_msg"><br class="m_5797712198930751463gmail_msg"></div></div><br class="m_5797712198930751463gmail_msg"><div class="gmail_quote m_5797712198930751463gmail_msg"><div dir="ltr" class="m_5797712198930751463gmail_msg">On Thu, Mar 16, 2017 at 12:37 PM Jonas Toth via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="m_5797712198930751463gmail_msg" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br class="m_5797712198930751463gmail_msg"></div><blockquote class="gmail_quote m_5797712198930751463gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Why would the second case not be possible?<div class="m_5797712198930751463gmail_msg">What i have in mind by example:</div><div class="m_5797712198930751463gmail_msg"><br class="m_5797712198930751463gmail_msg"></div><div class="m_5797712198930751463gmail_msg">```</div><div class="m_5797712198930751463gmail_msg">void definitly_throws() { // should be marked noexcept(false), maybe as configuration option</div><div class="m_5797712198930751463gmail_msg"><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">        if (some_condition())</span></div><div class="m_5797712198930751463gmail_msg"><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">  </span><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">       throw std::logic_error{"Reasons"};</span></div><div class="m_5797712198930751463gmail_msg"><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">   else</span></div><div class="m_5797712198930751463gmail_msg"><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">   </span><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">       // do unproblematic stuff</span></div><div class="m_5797712198930751463gmail_msg">}</div><div class="m_5797712198930751463gmail_msg"><br class="m_5797712198930751463gmail_msg"></div><div class="m_5797712198930751463gmail_msg">void probably_throws() { // this needs more analysis then AST matching so leave it as is</div><div class="m_5797712198930751463gmail_msg"><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">  try  {</span></div><div class="m_5797712198930751463gmail_msg"><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg"> </span><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">       // operation</span></div><div class="m_5797712198930751463gmail_msg"><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">   </span><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">       if (op_failed())</span></div><div class="m_5797712198930751463gmail_msg"><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">       </span><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">       </span><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">       throw std::runtime_error{"Operation failed"};</span></div><div class="m_5797712198930751463gmail_msg"><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">        } </span></div><div class="m_5797712198930751463gmail_msg"><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">     catch (std::runtime_error& e)</span></div><div class="m_5797712198930751463gmail_msg"><span style="white-space:pre-wrap" class="m_5797712198930751463gmail_msg">      { /* handle */ }</span></div><div class="m_5797712198930751463gmail_msg">}</div><div class="m_5797712198930751463gmail_msg">```</div><div class="m_5797712198930751463gmail_msg"><br class="m_5797712198930751463gmail_msg"></div><div class="m_5797712198930751463gmail_msg">The second one can be noexcept if the operation will not throw. It is not noexcept if operation is not noexcept.</div><div class="m_5797712198930751463gmail_msg">What did I miss?</div><div class="m_5797712198930751463gmail_msg"><br class="m_5797712198930751463gmail_msg"></div><div class="m_5797712198930751463gmail_msg">The deeper analysis will not happen if the analyser does not see all code, but if it can shouldnt there the possibility to decide? Maybe it has bad complexity and is therefor not practical. But maybe in some cases there can be insight gained?</div><div class="m_5797712198930751463gmail_msg"><br class="m_5797712198930751463gmail_msg"></div><div class="m_5797712198930751463gmail_msg">

Am Do, 16. Mär, 2017 um 11:25  schrieb Daniel Marjamäki <<a href="mailto:Daniel.Marjamaki@evidente.se" class="m_5797712198930751463gmail_msg" target="_blank">Daniel.Marjamaki@evidente.se</a>><wbr>:<br class="m_5797712198930751463gmail_msg">
<blockquote type="cite" class="m_5797712198930751463gmail_msg">






<div class="m_5797712198930751463gmail_msg m_5797712198930751463m_3969686606020480451m_-4071199109463940059WordSection1"><p class="MsoNormal m_5797712198930751463gmail_msg"><span lang="EN-US" class="m_5797712198930751463gmail_msg">As far as I see:<u class="m_5797712198930751463gmail_msg"></u><u class="m_5797712198930751463gmail_msg"></u></span></p><p class="MsoNormal m_5797712198930751463gmail_msg"><span lang="EN-US" class="m_5797712198930751463gmail_msg"><u class="m_5797712198930751463gmail_msg"></u> <u class="m_5797712198930751463gmail_msg"></u></span></p><p class="MsoNormal m_5797712198930751463gmail_msg"><span lang="EN-US" class="m_5797712198930751463gmail_msg">- a function calling only `noexcept` operations that does not throw can be marked noexcept<u class="m_5797712198930751463gmail_msg"></u><u class="m_5797712198930751463gmail_msg"></u></span></p><p class="MsoNormal m_5797712198930751463gmail_msg"><span lang="EN-US" class="m_5797712198930751463gmail_msg"><u class="m_5797712198930751463gmail_msg"></u> <u class="m_5797712198930751463gmail_msg"></u></span></p><p class="MsoNormal m_5797712198930751463gmail_msg"><span lang="EN-US" class="m_5797712198930751463gmail_msg">possible<u class="m_5797712198930751463gmail_msg"></u><u class="m_5797712198930751463gmail_msg"></u></span></p><p class="MsoNormal m_5797712198930751463gmail_msg"><span lang="EN-US" class="m_5797712198930751463gmail_msg"><u class="m_5797712198930751463gmail_msg"></u> <u class="m_5797712198930751463gmail_msg"></u></span></p><p class="MsoNormal m_5797712198930751463gmail_msg"><span lang="EN-US" class="m_5797712198930751463gmail_msg">- a function that has a `throw` statement not within a `try/catch` block can be marked noexcept(false)<u class="m_5797712198930751463gmail_msg"></u><u class="m_5797712198930751463gmail_msg"></u></span></p><p class="MsoNormal m_5797712198930751463gmail_msg"><span lang="EN-US" class="m_5797712198930751463gmail_msg"><u class="m_5797712198930751463gmail_msg"></u> <u class="m_5797712198930751463gmail_msg"></u></span></p><p class="MsoNormal m_5797712198930751463gmail_msg"><span lang="EN-US" class="m_5797712198930751463gmail_msg">Not possible<u class="m_5797712198930751463gmail_msg"></u><u class="m_5797712198930751463gmail_msg"></u></span></p><p class="MsoNormal m_5797712198930751463gmail_msg"><span lang="EN-US" class="m_5797712198930751463gmail_msg"><u class="m_5797712198930751463gmail_msg"></u> <u class="m_5797712198930751463gmail_msg"></u></span></p><p class="MsoNormal m_5797712198930751463gmail_msg"><span lang="EN-US" class="m_5797712198930751463gmail_msg">- a function calling a function that is not marked noexcept can not be marked noexcept<u class="m_5797712198930751463gmail_msg"></u><u class="m_5797712198930751463gmail_msg"></u></span></p><p class="MsoNormal m_5797712198930751463gmail_msg"><span lang="EN-US" class="m_5797712198930751463gmail_msg">   but it could be noexecpt with deeper analysis on what exception could be thrown and what exceptions are handled<u class="m_5797712198930751463gmail_msg"></u><u class="m_5797712198930751463gmail_msg"></u></span></p><p class="MsoNormal m_5797712198930751463gmail_msg"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d" class="m_5797712198930751463gmail_msg"><u class="m_5797712198930751463gmail_msg"></u> <u class="m_5797712198930751463gmail_msg"></u></span></p><p class="MsoNormal m_5797712198930751463gmail_msg"><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1f497d" class="m_5797712198930751463gmail_msg">not possible<u class="m_5797712198930751463gmail_msg"></u><u class="m_5797712198930751463gmail_msg"></u></span></p>
</div></blockquote><br class="m_5797712198930751463gmail_msg">
</div>______________________________<wbr>_________________<br class="m_5797712198930751463gmail_msg">
cfe-dev mailing list<br class="m_5797712198930751463gmail_msg">
<a href="mailto:cfe-dev@lists.llvm.org" class="m_5797712198930751463gmail_msg" target="_blank">cfe-dev@lists.llvm.org</a><br class="m_5797712198930751463gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" class="m_5797712198930751463gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br class="m_5797712198930751463gmail_msg">
</blockquote></div>
______________________________<wbr>_________________<br class="m_5797712198930751463gmail_msg">cfe-dev mailing list<br class="m_5797712198930751463gmail_msg"><a href="mailto:cfe-dev@lists.llvm.org" class="m_5797712198930751463gmail_msg" target="_blank">cfe-dev@lists.llvm.org</a><br class="m_5797712198930751463gmail_msg"><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" class="m_5797712198930751463gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br class="m_5797712198930751463gmail_msg"></div></blockquote></div></div></blockquote></div></div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><span><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:16px;font-family:Arial;color:rgb(0,0,0);font-weight:700;vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Martin Böhme</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:13.3333333333333px;font-family:Arial;color:rgb(102,102,102);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Software Engineer</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:13.3333333333333px;font-family:Arial;color:rgb(102,102,102);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><a href="mailto:mboehme@google.com" target="_blank">mboehme@google.com</a></span><br></p><span style="font-size:13.3333333333333px;font-family:Arial;color:rgb(102,102,102);vertical-align:baseline;white-space:pre-wrap;background-color:transparent"><img src="https://lh3.googleusercontent.com/jArLagMFiBykGEq2mtMjIS9RO3ydtGbI1KRMmdY7daBuMP4HQbM7p92vdv8yolHBV9sE4YXu7ORFjsy6mcF6LGJOjQhqkd4PrG43u1U2toF3BQIitx8YMjbU9hqX9u3U8MU=s1600" width="100px;" height="58px;" style="border:none"></span></span><br><div><div style="font-size:13px"><span style="font-family:Arial,Verdana,sans-serif"><font color="#666666">Google Germany GmbH</font></span></div><div><div style="font-size:13px;font-family:Arial,Verdana,sans-serif"><font color="#666666">Erika-Mann-Straße 33</font></div><div style="font-size:13px;font-family:Arial,Verdana,sans-serif"><font color="#666666">80363 München<br></font></div><div style="font-size:13px;font-family:Arial,Verdana,sans-serif"><font color="#666666"><br></font></div><div style="font-family:Arial,Verdana,sans-serif"><span><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:10.6666666666667px;font-family:Arial;color:rgb(183,183,183);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:10.6666666666667px;font-family:Arial;color:rgb(183,183,183);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Registergericht und -nummer: Hamburg, HRB 86891</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:10.6666666666667px;font-family:Arial;color:rgb(183,183,183);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Sitz der Gesellschaft: Hamburg</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:10.6666666666667px;font-family:Arial;color:rgb(183,183,183);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind, leiten Sie diese bitte nicht weiter, informieren Sie den Absender und löschen Sie die E-Mail und alle Anhänge. Vielen Dank.</span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:10.6666666666667px;font-family:Arial;color:rgb(183,183,183);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">       </span></p><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-size:10.6666666666667px;font-family:Arial;color:rgb(183,183,183);vertical-align:baseline;white-space:pre-wrap;background-color:transparent">This e-mail is confidential. If you are not the right addressee please do not forward it, please inform the sender, and please erase this e-mail including any attachments. Thanks.</span></p></span></div></div></div></div></div></div></div></div></div>
</div></div>