[cfe-dev] better way to test for explicit C++ constructor?

Peeter Joot peeter.joot at gmail.com
Tue Dec 11 13:23:35 PST 2012


Thanks Kim, that worked nicely:

         for ( CXXRecordDecl::ctor_iterator b = r->ctor_begin(), e =
r->ctor_end() ;
               b != e ; ++b )
         {
            if ( !b->isImplicitlyDefined() )
            {
               cout << r->getName().str() << " : CONSTRUCTOR" << endl ;

               break ;
            }
         }

and is much cleaner.

Peeter

CXXRecordDecl has a ctor_begin/ctor_end pair, which return iterators
> over all constructors.
>
> They are of type CXXConstructorDecl, and that class in turn has an
> isImplicitlyDefined method you can use to check whether it's
> user-written or not.
>
> You should be able to loop over the RecordDecl's constructors and
> count the ones not implicitly defined.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121211/f411a0f9/attachment.html>


More information about the cfe-dev mailing list