Closed HertzDevil closed 3 years ago
I was sure that this worked at some point. But then, I'm amazed that the Clang parser part works with so many Clang versions without too many ifdefs. Wouldn't surprise me if Clang just broke it on their end like they like to do.
Thanks for the patch!
Currently the
DefaultConstructor
processor checks for private default constructors, but misses out other situations where the default ctor would be deleted (= delete
, const / reference data member etc.), and Clang doesn't report these cases either. This patch fixes it by usingstd::is_default_constructible
itself to check whether a given type is default-constructible. The steps are:BindgenTypeInfo<T>
class template contains all compile-time type info necessary for a given type; it is never used during runtime. Currently it only holds a single member indicating whetherT
is default-constructible.#include
s this class template, and explicitly instantiates the template for every class considered by the config files.T
is truly default-constructible or not.For example, the temporary file for
basic_spec.cpp
will look like:This avoids the need to reimplement default ctor detection on the Crystal side (not even private ctor checking). The same technique may be used to check for other C++ compile-time properties inside
BindgenTypeInfo
.This PR also ensures that methods marked with
= delete
are not generated by the Clang parser, as otherwise classes with explicitly deleted ctors will still have those ctors wrapped.