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

llvm-svn: 286793
This commit is contained in:
Saleem Abdulrasool 2016-11-14 03:07:47 +00:00
parent 209a397060
commit 4d7f90b064
2 changed files with 11 additions and 6 deletions

View File

@ -4980,11 +4980,14 @@ __cxa_demangle(const char *mangled_name, char *buf, size_t *n, int *status) {
}
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;

View File

@ -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]);