[libcxx-commits] [libcxxabi] r361916 - Update private_typeinfo's `is_equal` implementation after r361913

Eric Fiselier via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 28 19:33:11 PDT 2019


Author: ericwf
Date: Tue May 28 19:33:11 2019
New Revision: 361916

URL: http://llvm.org/viewvc/llvm-project?rev=361916&view=rev
Log:
Update private_typeinfo's `is_equal` implementation after r361913

The libc++ typeinfo implementation is being improved to better
handle non-merged type names.

This patch takes advantage of that more correct behavior by delegating
to std::type_infos default operator== instead of doing pointer equality
ourselves.

However, libc++ still expects unique RTTI by default, and so we
should still fall back to strcmp when explicitly requested.

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=361916&r1=361915&r2=361916&view=diff
==============================================================================
--- libcxxabi/trunk/src/private_typeinfo.cpp (original)
+++ libcxxabi/trunk/src/private_typeinfo.cpp Tue May 28 19:33:11 2019
@@ -58,14 +58,12 @@ static inline
 bool
 is_equal(const std::type_info* x, const std::type_info* y, bool use_strcmp)
 {
-#ifndef _WIN32
+    // Use std::type_info's default comparison unless we've explicitly asked
+    // for strcmp.
     if (!use_strcmp)
-        return x == y;
-    return strcmp(x->name(), y->name()) == 0;
-#else
-    (void) use_strcmp;
-    return (x == y) || (strcmp(x->name(), y->name()) == 0);
-#endif
+        return *x == *y;
+    // Still allow pointer equality to short circut.
+    return x == y || strcmp(x->name(), y->name()) == 0;
 }
 
 namespace __cxxabiv1




More information about the libcxx-commits mailing list