2014-06-06 23:30:32 +03:00
|
|
|
#ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED
|
|
|
|
#define BOOST_CORE_DEMANGLE_HPP_INCLUDED
|
2014-06-06 15:49:29 +03:00
|
|
|
|
|
|
|
// MS compatible compilers support #pragma once
|
|
|
|
|
|
|
|
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
|
|
|
# pragma once
|
|
|
|
#endif
|
|
|
|
|
2014-06-06 23:30:32 +03:00
|
|
|
// core::demangle
|
2014-06-06 15:49:29 +03:00
|
|
|
//
|
|
|
|
// Copyright 2014 Peter Dimov
|
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0.
|
|
|
|
// See accompanying file LICENSE_1_0.txt or copy at
|
|
|
|
// http://www.boost.org/LICENSE_1_0.txt
|
|
|
|
|
|
|
|
#include <boost/config.hpp>
|
|
|
|
#include <string>
|
|
|
|
|
2014-06-08 02:22:19 +03:00
|
|
|
#if defined( __clang__ ) && defined( __has_include )
|
|
|
|
# if __has_include(<cxxabi.h>)
|
|
|
|
# define BOOST_CORE_HAS_CXXABI_H
|
|
|
|
# endif
|
|
|
|
#elif defined( __GLIBCXX__ ) || defined( __GLIBCPP__ )
|
|
|
|
# define BOOST_CORE_HAS_CXXABI_H
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined( BOOST_CORE_HAS_CXXABI_H )
|
2014-06-06 15:49:29 +03:00
|
|
|
# include <cxxabi.h>
|
|
|
|
# include <cstdlib>
|
|
|
|
# include <cstddef>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace boost
|
|
|
|
{
|
|
|
|
|
|
|
|
namespace core
|
|
|
|
{
|
|
|
|
|
|
|
|
#if defined( BOOST_CORE_HAS_CXXABI_H )
|
|
|
|
|
|
|
|
// lifted from boost/exception/detail/type_info.hpp
|
|
|
|
|
|
|
|
inline std::string demangle( char const * name )
|
|
|
|
{
|
|
|
|
struct auto_free
|
|
|
|
{
|
|
|
|
explicit auto_free( char * ptr ): p( ptr )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~auto_free()
|
|
|
|
{
|
|
|
|
std::free( p );
|
|
|
|
}
|
|
|
|
|
|
|
|
char * p;
|
|
|
|
};
|
|
|
|
|
|
|
|
int status = 0;
|
|
|
|
std::size_t size = 0;
|
|
|
|
|
|
|
|
auto_free demangled( abi::__cxa_demangle( name, NULL, &size, &status ) );
|
|
|
|
|
|
|
|
if( demangled.p )
|
|
|
|
{
|
|
|
|
return demangled.p;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
inline std::string demangle( char const * name )
|
|
|
|
{
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
} // namespace core
|
|
|
|
|
|
|
|
} // namespace boost
|
|
|
|
|
|
|
|
#undef BOOST_CORE_HAS_CXXABI_H
|
|
|
|
|
2014-06-06 23:30:32 +03:00
|
|
|
#endif // #ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED
|