From b11bd9019deef39ed969fab8b85771946b83d17b Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Wed, 18 Feb 2004 19:45:44 +0000 Subject: Configure. configure.in: * config/ax_cxx_gcc_abi_demangle.m4: * src/cppunit/TypeInfoHelper.cpp: added patch from Neil Ferguson to use gcc c++ abi to demangle typeinfo name when available. --- src/cppunit/TypeInfoHelper.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/cppunit') diff --git a/src/cppunit/TypeInfoHelper.cpp b/src/cppunit/TypeInfoHelper.cpp index 39356d6..bd01001 100644 --- a/src/cppunit/TypeInfoHelper.cpp +++ b/src/cppunit/TypeInfoHelper.cpp @@ -5,6 +5,10 @@ #include +#if CPPUNIT_HAVE_GCC_ABI_DEMANGLE +#include +#endif + CPPUNIT_NS_BEGIN @@ -12,6 +16,18 @@ CPPUNIT_NS_BEGIN std::string TypeInfoHelper::getClassName( const std::type_info &info ) { +#if defined(CPPUNIT_HAVE_GCC_ABI_DEMANGLE) && CPPUNIT_HAVE_GCC_ABI_DEMANGLE + + int status = 0; + char* c_name = 0; + + c_name = abi::__cxa_demangle( info.name(), 0, 0, &status ); + + std::string name( c_name ); + free( c_name ); + +#else // CPPUNIT_HAVE_GCC_ABI_DEMANGLE + static std::string classPrefix( "class " ); std::string name( info.name() ); @@ -25,6 +41,9 @@ TypeInfoHelper::getClassName( const std::type_info &info ) if ( name.substr( 0, classPrefix.length() ) == classPrefix ) return name.substr( classPrefix.length() ); + +#endif // CPPUNIT_HAVE_GCC_ABI_DEMANGLE + return name; } -- cgit v1.2.1