<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 2, 2016, at 5:08 AM, George Kollias via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi all,</div><div class="">I'm interested into developing a static analyzer checker that detects exceptions that escape a destructor. It even seems there is a similar suggestion in <a href="http://clang-analyzer.llvm.org/potential_checkers.html" class="">http://clang-analyzer.llvm.org/potential_checkers.html</a> (ctordtor.ExptInsideDtor).</div><div class=""><br class=""></div><div class="">As a first step, I modified the alpha.cplusplus.VirtualCall checker to walk call hierarchies under destructors searching for throw statements (CXXThrowExpr). It works fine for many cases but there are also some limitations. One of them is that when we want to visit the body of a virtual method call "foo.bar()", the call (IIUC) is resolved statically -according to foo's static type-. Is there any way/API to walk/get all possible "bar" method implementations? Any examples to look at?</div></div></div></blockquote><div><br class=""></div><div>You want to warn if a destructor calls “foo.bar()” and any implementation of “bar()” can throw, correct? That would include implementations that do not get called from the destructor and make the warning more aggressive, which could potentially lead to false positives. Although, I am not sure how common those cases would happen in real code.</div><div><br class=""></div><div>Sounds like you would be able to build on top of this method to find all implementations:</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>/// \brief Find the method in \p RD that corresponds to this one.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>///</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>/// Find if \p RD or one of the classes it inherits from override this method.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>/// If so, return it. \p RD is assumed to be a subclass of the class defining</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 143, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>/// this method (or be the class itself), unless \p MayBeBase is set to true.</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(52, 149, 175);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> </span>CXXMethodDecl<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""> *</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> getCorrespondingMethodInClass(<span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">const</span> <span style="font-variant-ligatures: no-common-ligatures; color: #3495af" class="">CXXRecordDecl</span> *RD,</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">bool</span> MayBeBase = <span style="font-variant-ligatures: no-common-ligatures; color: #0433ff" class="">false</span>);</div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class="">Of course, any other implementation suggestions are welcome.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">George</div></div>
_______________________________________________<br class="">cfe-dev mailing list<br class=""><a href="mailto:cfe-dev@lists.llvm.org" class="">cfe-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev<br class=""></div></blockquote></div><br class=""></body></html>