[libcxxabi] r286793 - __cxa_demangle: allow demangling invocation blocks

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 13 19:07:47 PST 2016


Author: compnerd
Date: Sun Nov 13 21:07:47 2016
New Revision: 286793

URL: http://llvm.org/viewvc/llvm-project?rev=286793&view=rev
Log:
__cxa_demangle: allow demangling invocation blocks

The block invocation function uses an extension where the prefix is ___Z
as opposed to _Z.  This should make the tests pass again.

Disable a negative test which was testing a crasher.  The symbol being
demangled is not a valid mangled symbol and will return a nullptr.

Adjust the type info decoding test to be a valid symbol name.

Modified:
    libcxxabi/trunk/src/cxa_demangle.cpp
    libcxxabi/trunk/test/test_demangle.pass.cpp

Modified: libcxxabi/trunk/src/cxa_demangle.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=286793&r1=286792&r2=286793&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Sun Nov 13 21:07:47 2016
@@ -4980,11 +4980,14 @@ __cxa_demangle(const char *mangled_name,
     }
 
     size_t len = std::strlen(mangled_name);
-    if (len < 2 || mangled_name[0] != '_' || mangled_name[1] != 'Z')
+    if (len < 2 || strncmp(mangled_name, "_Z", 2))
     {
-        if (status)
-            *status = invalid_mangled_name;
-        return nullptr;
+        if (len < 4 || strncmp(mangled_name, "___Z", 4))
+        {
+            if (status)
+                *status = invalid_mangled_name;
+            return nullptr;
+        }
     }
 
     size_t internal_size = buf != nullptr ? *n : 0;

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=286793&r1=286792&r2=286793&view=diff
==============================================================================
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Sun Nov 13 21:07:47 2016
@@ -29478,7 +29478,6 @@ const char* cases[][2] =
     {"_Z1fPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP1XS13_S12_S11_S10_SZ_SY_SX_SW_SV_SU_ST_SS_SR_SQ_SP_SO_SN_SM_SL_SK_SJ_SI_SH_SG_SF_SE_SD_SC_SB_SA_S9_S8_S7_S6_S5_S4_S3_S2_S1_S0_S_", "f(X****************************************, X****************************************, X***************************************, X**************************************, X*************************************, X************************************, X***********************************, X**********************************, X*********************************, X********************************, X*******************************, X******************************, X*****************************, X****************************, X***************************, X**************************, X*************************, X************************, X***********************, X**********************, X*********************, X********************, X*******************, X******************, X*****************, X*************
 ***, X***************, X**************, X*************, X************, X***********, X**********, X*********, X********, X*******, X******, X*****, X****, X***, X**, X*, X)"},
     {"_ZZN1J1KEvENK1C1FEv", "J::K()::C::F() const"},
     {"_ZZNVK1J1KEvENK1C1FEv", "J::K() const volatile::C::F() const"},
-    {"U4_farrVKPi", "int* const volatile restrict _far"},
     {"_Z1fM1AKFvvE", "f(void (A::*)() const)"},
     {"_ZNR1X1fEv", "X::f() &"},
     {"_ZNKO1X1hEv", "X::h() const &&"},
@@ -29591,7 +29590,10 @@ const char* cases[][2] =
     {"_ZZ4testvEN1g3fooE5Point", "test()::g::foo(Point)"},
     {"_ZThn12_NSt9strstreamD0Ev",   "non-virtual thunk to std::strstream::~strstream()"},
     {"_ZTv0_n12_NSt9strstreamD0Ev",     "virtual thunk to std::strstream::~strstream()"},
-    {"\x6D", "unsigned long"}, 	// This use to crash with ASAN
+
+    // NOTE: disable this test since it is a negative test case, you cannot demangle a non-mangled symbol
+    // {"\x6D", nullptr}, 	// This use to crash with ASAN
+    {"_ZTIU4_farrVKPi", "typeinfo for int* const volatile restrict _far"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);




More information about the cfe-commits mailing list