include-what-you-use / include-what-you-use

A tool for use with clang to analyze #includes in C and C++ source files
https://include-what-you-use.org
Other
4.12k stars 387 forks source link

Forward declarations problem with libc++ <type_traits> #913

Open darkdragon-001 opened 3 years ago

darkdragon-001 commented 3 years ago

IWYU suggests forward declarations which are not compatible with c++ type traits:

/usr/lib/llvm-12/bin/../include/c++/v1/type_traits:2952:38: error: incomplete type 'Types::MyType' used in type trait expression
    : public integral_constant<bool, __is_constructible(_Tp, _Args...)>
                                     ^
/usr/lib/llvm-12/bin/../include/c++/v1/type_traits:3007:14: note: in instantiation of template class 'std::is_constructible<Types::MyType, const Types::MyType &>' requested here
    : public is_constructible<_Tp,
             ^
mycontainer.h:19:24: note: in instantiation of template class 'std::is_copy_constructible<Types::MyType>' requested here
    static_assert(std::is_copy_constructible<T>::value, "MyContainer requires copy-constructible Element_Type");
kimgr commented 3 years ago

Can you provide a reduced example and the include-what-you-use invocation for it? There's probably something wrong with IWYU's template analysis, but without more information it's hard to say what.