<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 Jan 18, 2018, at 6:57 PM, George Karpenkov 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 class="">Hi,<br class=""><br class="">Declarations for callable objects: BlockDecl, FunctionDecl, ObjCMethodDecl share quite a few methods:<br class=""><br class=""> - parameters()<br class=""> - getSourceRange()<br class=""> - getBody()<br class=""><br class="">and some others.<br class="">Despite that, they don’t have any super-interface (CallableDecl?).<br class=""></div></div></blockquote><div><br class=""></div>CodeGenFunction has AbstractCallee. Maybe that could be extended to suit your needs?</div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><div class=""><br class="">As a result, I often find myself writing duplicating code. Clang static analyzer has a CallEvent struct which partially mitigates the issue, but<br class="">1) In some cases, it’s not suitable<br class="">2) CallEvent itself has duplication<br class=""><br class="">Would anyone be against introducing a common interface for those classes?<br class="">It could be as tiny change as just adding an inheritance, and then users would be able to do<br class=""><br class="">if (auto *CD = dyn_cast<CallableDecl>(D))<br class=""> D->parameters() // …<br class=""><br class="">instead of duplicating code<br class=""></div></div></blockquote><div><br class=""></div><div>+ 1, I'd be happy to review that.</div><div><br class=""></div><div>If anyone else is interested, there's a similar patch for llvm under review: <a href="https://reviews.llvm.org/D40727" class="">https://reviews.llvm.org/D40727</a>.</div><div><br class=""></div><div>vedant</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><br class="">Regards,<br class="">George<br class="">_______________________________________________<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></div></blockquote></div><br class=""></body></html>