root/src/tools/cppunit/cppunit/TypeInfoHelper.cpp
#include <cppunit/Portability.h>

#if CPPUNIT_USE_TYPEINFO_NAME

#include <string>
#include <cppunit/extensions/TypeInfoHelper.h>
#if __GNUC__ > 2
#include <cxxabi.h>
#endif


using std::string;
using std::type_info;

namespace CppUnit {

string
TypeInfoHelper::getClassName( const type_info &info )
{
    static const string classPrefix( "class " );
    string name( info.name() );

#if __GNUC__ > 2
    int status = 0;
    char* demangled_ptr = abi::__cxa_demangle(info.name(), NULL, NULL, &status);
    if (status == 0) {
        name = demangled_ptr;
    }
#endif

    bool has_class_prefix = 0 ==
#if CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
        name.compare( classPrefix, 0, classPrefix.length() );
#else
    name.compare( 0, classPrefix.length(), classPrefix );
#endif

    return has_class_prefix ? name.substr( classPrefix.length() ) : name;
}


} //  namespace CppUnit

#endif