Author: pcc Date: Thu Jan 25 17:22:17 2018 New Revision: 323491 URL: http://llvm.org/viewvc/llvm-project?rev=323491&view=rev Log: libcxx: Use vcruntime declarations for typeinfo on Windows.
We need to use the vcruntime declarations on Windows to avoid an ODR violation involving rtti.obj, which provides the definition of the runtime function implementing dynamic_cast and depends on the vcruntime implementations of bad_cast and bad_typeid. Differential Revision: https://reviews.llvm.org/D42220 Modified: libcxx/trunk/include/typeinfo libcxx/trunk/src/support/runtime/exception_msvc.ipp libcxx/trunk/src/typeinfo.cpp Modified: libcxx/trunk/include/typeinfo URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/typeinfo?rev=323491&r1=323490&r2=323491&view=diff ============================================================================== --- libcxx/trunk/include/typeinfo (original) +++ libcxx/trunk/include/typeinfo Thu Jan 25 17:22:17 2018 @@ -69,6 +69,10 @@ public: #pragma GCC system_header #endif +#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) +#include <vcruntime_typeinfo.h> +#else + #if !defined(_LIBCPP_ABI_MICROSOFT) #if defined(_LIBCPP_NONUNIQUE_RTTI_BIT) #define _LIBCPP_HAS_NONUNIQUE_TYPEINFO @@ -219,6 +223,8 @@ public: } // std +#endif // defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME) + _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_NORETURN inline _LIBCPP_ALWAYS_INLINE void __throw_bad_cast() Modified: libcxx/trunk/src/support/runtime/exception_msvc.ipp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/runtime/exception_msvc.ipp?rev=323491&r1=323490&r2=323491&view=diff ============================================================================== --- libcxx/trunk/src/support/runtime/exception_msvc.ipp (original) +++ libcxx/trunk/src/support/runtime/exception_msvc.ipp Thu Jan 25 17:22:17 2018 @@ -97,6 +97,7 @@ bad_array_length::what() const _NOEXCEPT return "bad_array_length"; } +#if defined(_LIBCPP_NO_VCRUNTIME) bad_cast::bad_cast() _NOEXCEPT { } @@ -125,7 +126,6 @@ bad_typeid::what() const _NOEXCEPT return "std::bad_typeid"; } -#if defined(_LIBCPP_NO_VCRUNTIME) exception::~exception() _NOEXCEPT { } Modified: libcxx/trunk/src/typeinfo.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/typeinfo.cpp?rev=323491&r1=323490&r2=323491&view=diff ============================================================================== --- libcxx/trunk/src/typeinfo.cpp (original) +++ libcxx/trunk/src/typeinfo.cpp Thu Jan 25 17:22:17 2018 @@ -9,7 +9,7 @@ #include "typeinfo" -#if defined(_LIBCPP_ABI_MICROSOFT) +#if defined(_LIBCPP_ABI_MICROSOFT) && defined(_LIBCPP_NO_VCRUNTIME) #include <string.h> int std::type_info::__compare(const type_info &__rhs) const _NOEXCEPT { @@ -49,7 +49,8 @@ size_t std::type_info::hash_code() const // FIXME: Remove __APPLE__ default here once buildit is gone. // FIXME: Remove the _LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY configuration. #if (!defined(LIBCXX_BUILDING_LIBCXXABI) && !defined(LIBCXXRT) && \ - !defined(__GLIBCXX__) && !defined(__APPLE__)) || \ + !defined(__GLIBCXX__) && !defined(__APPLE__) && \ + !(defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME))) || \ defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) std::type_info::~type_info() { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits