Michael Koval
Michael Koval

Reputation: 8377

Testing if class is copy constructable using libtooling

I would like to use libtooling to test whether the defined by a CXXRecordDecl is copy constructable.

I have already tried :

Unfortunately, both of those expressions return true if the class's copy constructor is implicitly deleted. This can occur if the class inherits from a non-copyable class or has a member variable that is non-copyable.

The logic to test whether a class is copy constructable is non-trivial and must be exist somewhere in clang. How can I test if a class is copy constructable with libtooling?

Upvotes: 0

Views: 138

Answers (1)

Jarod42
Jarod42

Reputation: 218138

Turn comment into answer:

You can retrieve the constructor with CXXRecordDecl::ctor_begin

and check CXXConstructorDecl::isDeleted().

Upvotes: 1

Related Questions