<div dir="ltr">HI,<div><br></div><div>I'm trying to write a tool that uses the AST to look at all the class declarations in our codebase and get some metrics on our use of special member functions. (How many classes are copyable, how many have ctors without the corresponding assignment operator, etc.) I'm running into some problems with implicitly declared special members. For example:</div><div><br></div><div><div style="color:rgba(0,0,0,0.87)"><div style=""><font face="monospace">class UserDefCopy {</font></div><div style=""><font face="monospace"> public:</font></div><div style=""><font face="monospace">  UserDefCopy(const UserDefCopy&) {}</font></div><div style=""><font face="monospace">  UserDefCopy& operator=(const UserDefCopy&) { return *this; }</font></div><div style=""><font face="monospace">};</font></div></div><div style="color:rgba(0,0,0,0.87)"><div style=""><font face="monospace">class ContainsUserDefCopy {</font></div><div style=""><font face="monospace"> private:</font></div><div style=""><font face="monospace">  UserDefCopy x_;</font></div><div style=""><font face="monospace">};</font></div><div style=""><font face="monospace"><br></font></div><div style=""><font face="monospace">UserDefCopy </font>has a CXXConstructorDecl for its copy constructor and a CXXMethodDecl for the copy-assign operator, so I can use the methods on the decls to get the info I need (isDeleted, isExplicitlyDefaulted, getAccess, etc.) However, <font face="monospace">ContainsUserDefCopy</font>'s copy-assign operator is implicit, so there's no decl for it. Since there's no decl, I can't differentiate between a class with an implicitly defaulted copy-assign and one with an implicitly deleted copy-assign. <font face="monospace">ContainsUserDefCopy </font><font face="arial, sans-serif">does have a declaration for its copy constructor, but AFAICT from looking at </font><a href="https://clang.llvm.org/doxygen/classclang_1_1Sema.html#a2ddba48d645ed86f2f4d11b6e7a9010a" target="_blank" rel="nofollow" style="text-decoration-line:none;color:rgb(41,98,255);font-family:Roboto,RobotoDraft,Helvetica,Arial,sans-serif">clang::Sema::AddImplicitlyDeclaredMembersToClass</a>, that's because special members with the <font face="monospace">needs_overload_resolution</font><font face="arial, sans-serif"> tag are eagerly generated while others are deferred. I don't understand why the ctor has the tag while the assign operator doesn't, though.</font></div></div></div><div><br></div><div>The questions I have are:</div><div><ol><li>What makes a method <font face="monospace">needs_overload_resolution</font>? The docs in <font face="monospace">CXXRecordDecl</font> just say that it "[determines] whether we need to eagerly declare a defaulted [member] for this class."</li><li><font face="arial, sans-serif"><span style="color:rgba(0,0,0,0.87)">Is there a different way I should query the AST so that I see any decls that were deferred during the Sema step? Or some other way to get this information? </span>Trying to use an implicitly deleted c<span style="color:rgba(0,0,0,0.87)">opy assignment operator is a compiler error, so that information is obviously available </span><i style="color:rgba(0,0,0,0.87)">somewhere</i><span style="color:rgba(0,0,0,0.87)">.</span></font></li></ol><div><font color="#000000" face="arial, sans-serif">Thanks,</font></div></div><div><font color="#000000" face="arial, sans-serif">Weston</font></div></div>