diff options
author | Howard Hinnant <hhinnant@apple.com> | 2012-09-28 04:05:34 +0400 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2012-09-28 04:05:34 +0400 |
commit | 2d0352cbf84fca28cce4cc50beb1799e279c2b06 (patch) | |
tree | 5d531568d71623c2fb73da5e5b8a4cc4b5b943f3 /libcxxabi/src/private_typeinfo.cpp | |
parent | 21b51062db405967aebcbd65af3873ae73b64c90 (diff) |
Two changes: 1) I still didn't have the ABI correct to match the gcc-4.2 std::string under the exception classes. I think the changes to stdexcept.cpp have got that down now. 2) On Apple platforms I'm seeing visibility bugs in applications with respect to type_info's being hidden. This is causing dynamic_cast to malfunction because there are multiple type_info's running around for one type within an application, making dynamic_cast believe that one type is actually multiple types. As a stop gap measure I'm trying to detect this error, print out an error message, but continue with the most likely desired result. This is all under __APPLE__. This behavior can be expanded to other platforms if desired.
llvm-svn: 164809
Diffstat (limited to 'libcxxabi/src/private_typeinfo.cpp')
-rw-r--r-- | libcxxabi/src/private_typeinfo.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/libcxxabi/src/private_typeinfo.cpp b/libcxxabi/src/private_typeinfo.cpp index 04ce90133767..d15b952b9ecb 100644 --- a/libcxxabi/src/private_typeinfo.cpp +++ b/libcxxabi/src/private_typeinfo.cpp @@ -9,6 +9,10 @@ #include "private_typeinfo.h" +#if __APPLE__ +#include <sys/syslog.h> +#endif + namespace __cxxabiv1 { @@ -437,6 +441,19 @@ __dynamic_cast(const void* static_ptr, info.number_of_dst_type = 1; // Do the search dynamic_type->search_above_dst(&info, dynamic_ptr, dynamic_ptr, public_path); +#if __APPLE__ + // The following if should always be false because we should definitely + // find (static_ptr, static_type), either on a public or private path + if (info.path_dst_ptr_to_static_ptr == unknown) + { + // We get here only if there is some kind of visibility problem + // in client code. + syslog(LOG_ERR, "dynamic_cast error 1: There is a hidden visibility " + "problem associated with the type_info's of %s" + " and/or %s.\n", static_type->name(), dynamic_type->name()); + info.path_dst_ptr_to_static_ptr = public_path; + } +#endif // __APPLE__ // Query the search. if (info.path_dst_ptr_to_static_ptr == public_path) dst_ptr = dynamic_ptr; @@ -445,6 +462,18 @@ __dynamic_cast(const void* static_ptr, { // Not using giant short cut. Do the search dynamic_type->search_below_dst(&info, dynamic_ptr, public_path); + #if __APPLE__ + // The following if should always be false because we should definitely + // find (static_ptr, static_type), either on a public or private path + if (info.path_dst_ptr_to_static_ptr == unknown && + info.path_dynamic_ptr_to_static_ptr == unknown) + { + syslog(LOG_ERR, "dynamic_cast error 2: There is a hidden visibility " + "problem associated with the type_info's of %s" + " and/or %s and/or %s.\n", static_type->name(), dynamic_type->name(), + dst_type->name()); + } +#endif // __APPLE__ // Query the search. switch (info.number_to_static_ptr) { |