[cfe-commits] [libcxxabi] r168052 - /libcxxabi/trunk/src/private_typeinfo.cpp

Howard Hinnant hhinnant at apple.com
Thu Nov 15 10:00:42 PST 2012


Author: hhinnant
Date: Thu Nov 15 12:00:42 2012
New Revision: 168052

URL: http://llvm.org/viewvc/llvm-project?rev=168052&view=rev
Log:
Remove aborts under __dynamic_cast which were under _LIBCXX_DYNAMIC_FALLBACK.  Change all type_info comparisons to use an inlined is_equal helper.  However no change in functionality for this latter change at this time.  This is just to encapsulate the comparison and make it a little easier to switch back and forth for testing/debugging.

Modified:
    libcxxabi/trunk/src/private_typeinfo.cpp

Modified: libcxxabi/trunk/src/private_typeinfo.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/private_typeinfo.cpp?rev=168052&r1=168051&r2=168052&view=diff
==============================================================================
--- libcxxabi/trunk/src/private_typeinfo.cpp (original)
+++ libcxxabi/trunk/src/private_typeinfo.cpp Thu Nov 15 12:00:42 2012
@@ -172,7 +172,7 @@
 __fundamental_type_info::can_catch(const __shim_type_info* thrown_type,
                                    void*&) const
 {
-    return this == thrown_type;
+    return is_equal(this, thrown_type, false);
 }
 
 bool
@@ -200,7 +200,7 @@
 __enum_type_info::can_catch(const __shim_type_info* thrown_type,
                             void*&) const
 {
-    return this == thrown_type;
+    return is_equal(this, thrown_type, false);
 }
 
 #pragma clang diagnostic push
@@ -212,7 +212,7 @@
                              void*& adjustedPtr) const
 {
     // bullet 1
-    if (this == thrown_type)
+    if (is_equal(this, thrown_type, false))
         return true;
     const __class_type_info* thrown_class_type =
         dynamic_cast<const __class_type_info*>(thrown_type);
@@ -265,7 +265,7 @@
                                                void* adjustedPtr,
                                                int path_below) const
 {
-    if (this == info->static_type)
+    if (is_equal(this, info->static_type, false))
         process_found_base_class(info, adjustedPtr, path_below);
 }
 
@@ -274,7 +274,7 @@
                                                   void* adjustedPtr,
                                                   int path_below) const
 {
-    if (this == info->static_type)
+    if (is_equal(this, info->static_type, false))
         process_found_base_class(info, adjustedPtr, path_below);
     else
         __base_type->has_unambiguous_public_base(info, adjustedPtr, path_below);
@@ -303,7 +303,7 @@
                                                    void* adjustedPtr,
                                                    int path_below) const
 {
-    if (this == info->static_type)
+    if (is_equal(this, info->static_type, false))
         process_found_base_class(info, adjustedPtr, path_below);
     else
     {
@@ -328,9 +328,9 @@
 __pbase_type_info::can_catch(const __shim_type_info* thrown_type,
                              void*&) const
 {
-    if (this == thrown_type)
+    if (is_equal(this, thrown_type, false))
         return true;
-    return thrown_type == &typeid(std::nullptr_t);
+    return is_equal(thrown_type, &typeid(std::nullptr_t), false);
 }
 
 #pragma clang diagnostic push
@@ -354,10 +354,10 @@
     // bullet 3B
     if (thrown_pointer_type->__flags & ~__flags)
         return false;
-    if (__pointee == thrown_pointer_type->__pointee)
+    if (is_equal(__pointee, thrown_pointer_type->__pointee, false))
         return true;
     // bullet 3A
-    if (__pointee == &typeid(void))
+    if (is_equal(__pointee, &typeid(void), false))
         return true;
     const __class_type_info* catch_class_type =
         dynamic_cast<const __class_type_info*>(__pointee);
@@ -484,7 +484,7 @@
     __dynamic_cast_info info = {dst_type, static_ptr, static_type, src2dst_offset, 0};
 
     // Find out if we can use a giant short cut in the search
-    if (dynamic_type == dst_type)
+    if (is_equal(dynamic_type, dst_type, false))
     {
         // Using giant short cut.  Add that information to info.
         info.number_of_dst_type = 1;
@@ -504,12 +504,6 @@
             info = {dst_type, static_ptr, static_type, src2dst_offset, 0};
             info.number_of_dst_type = 1;
             dynamic_type->search_above_dst(&info, dynamic_ptr, dynamic_ptr, public_path, true);
-            if (info.path_dst_ptr_to_static_ptr == unknown)
-            {
-                abort_message("dynamic_cast error: Unable to compute dynamic "
-                              "cast from %s to %s\n", static_type->name(),
-                              dynamic_type->name());
-            }
         }
 #endif  // _LIBCXX_DYNAMIC_FALLBACK
         // Query the search.
@@ -533,14 +527,6 @@
             // Redo the search comparing type_info's using strcmp
             info = {dst_type, static_ptr, static_type, src2dst_offset, 0};
             dynamic_type->search_below_dst(&info, dynamic_ptr, public_path, true);
-            if (info.path_dst_ptr_to_static_ptr == unknown &&
-                info.path_dynamic_ptr_to_static_ptr == unknown)
-            {
-                abort_message("dynamic_cast error: Unable to compute dynamic "
-                              "cast from %s to %s with a dynamic type of %s\n",
-                              static_type->name(), dst_type->name(),
-                              dynamic_type->name());
-            }
         }
 #endif  // _LIBCXX_DYNAMIC_FALLBACK
         // Query the search.





More information about the cfe-commits mailing list