__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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@286793 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/src/cxa_demangle.cpp b/src/cxa_demangle.cpp
index 8b9dfc9..4aeed1b 100644
--- a/src/cxa_demangle.cpp
+++ b/src/cxa_demangle.cpp
@@ -4980,11 +4980,14 @@
     }
 
     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;
diff --git a/test/test_demangle.pass.cpp b/test/test_demangle.pass.cpp
index bc27181..af16b56 100644
--- a/test/test_demangle.pass.cpp
+++ b/test/test_demangle.pass.cpp
@@ -29478,7 +29478,6 @@
     {"_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 @@
     {"_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]);