I needed to hunt down code that uses explicit global constructors.  I was able to do this, for example, identifing global1 in the following:<div><br></div><div><div>struct withConstructor</div><div>{</div><div>   int x ;</div>
<div><br></div><div>   withConstructor() : x(3) {}</div><div>} ;</div><div><br></div><div>struct noConstructor</div><div>{</div><div>   int x ;</div><div>} ;</div><div><br></div><div>void foo()</div><div>{</div><div>   withConstructor local1 ;</div>
<div>   noConstructor local2 ;</div><div>}</div><div><br></div><div>withConstructor global1 ;</div><div>noConstructor global2 ;</div><div><br></div><div>However, my AST visitor function for this contained the following very clumsy seeming check:</div>
<div><br></div><div><div>   bool VisitCXXRecordDecl( CXXRecordDecl* r )<br></div><div>   {</div><div>      if ( r->isThisDeclarationADefinition() )</div><div>      {</div><div>         //cout << "VisitCXXRecordDecl:: CLASS: " << r->getName().str() << endl ;</div>
<div><br></div><div>         if ( r->hasConstCopyConstructor() ||</div><div>              r->hasUserDeclaredConstructor() ||</div><div>              r->hasUserProvidedDefaultConstructor() ||</div><div>              r->hasUserDeclaredCopyConstructor() ||</div>
<div>              r->hasNonTrivialDefaultConstructor() ||</div><div>              r->hasConstexprDefaultConstructor() ||</div><div>              r->hasNonTrivialCopyConstructor() ||</div><div>              r->hasUserDeclaredMoveConstructor()  ||</div>
<div>              r->hasFailedImplicitMoveConstructor()  ||</div><div>              r->hasConstexprNonCopyMoveConstructor()  ||</div><div>              r->hasNonTrivialMoveConstructor()   )</div><div>         {</div>
<div>            cout << r->getName().str() << " : CONSTRUCTOR" << endl ;</div><div>         }</div></div><div>...</div><div><br></div><div>Is there any easier way to look for constructors, but exclude the ones that will be defined internally by the compiler for default initialization, or is this as good as it gets?</div>
<div><br></div><div>-- <br></div>Peeter<br>
</div>