From cee977fc84338038b71ea59e1485f514ee45bb9e Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Fri, 6 Jun 2014 23:30:32 +0300 Subject: [PATCH] Lift core::detail::demange to core, move demangled_name to typeinfo.hpp. --- .../core/{demangled_name.hpp => demangle.hpp} | 27 +++---------------- include/boost/core/lightweight_test_trait.hpp | 1 - include/boost/core/typeinfo.hpp | 11 ++++++++ test/Jamfile.v2 | 5 ++++ test/demangle_test.cpp | 23 ++++++++++++++++ test/demangled_name_test.cpp | 1 - 6 files changed, 43 insertions(+), 25 deletions(-) rename include/boost/core/{demangled_name.hpp => demangle.hpp} (73%) create mode 100644 test/demangle_test.cpp diff --git a/include/boost/core/demangled_name.hpp b/include/boost/core/demangle.hpp similarity index 73% rename from include/boost/core/demangled_name.hpp rename to include/boost/core/demangle.hpp index c2de377..0ceca6b 100644 --- a/include/boost/core/demangled_name.hpp +++ b/include/boost/core/demangle.hpp @@ -1,5 +1,5 @@ -#ifndef BOOST_CORE_DEMANGLED_NAME_HPP_INCLUDED -#define BOOST_CORE_DEMANGLED_NAME_HPP_INCLUDED +#ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED +#define BOOST_CORE_DEMANGLE_HPP_INCLUDED // MS compatible compilers support #pragma once @@ -7,7 +7,7 @@ # pragma once #endif -// core::demangled_name( BOOST_CORE_TYPEID(T) ) +// core::demangle // // Copyright 2014 Peter Dimov // @@ -16,7 +16,6 @@ // http://www.boost.org/LICENSE_1_0.txt #include -#include #include #if defined(__GLIBCXX__) || defined(__GLIBCPP__) @@ -32,9 +31,6 @@ namespace boost namespace core { -namespace detail -{ - #if defined( BOOST_CORE_HAS_CXXABI_H ) // lifted from boost/exception/detail/type_info.hpp @@ -79,25 +75,10 @@ inline std::string demangle( char const * name ) #endif -} // namespace detail - -inline std::string demangled_name( core::typeinfo const & ti ) -{ -#if defined( BOOST_NO_TYPEID ) - - return ti.name(); - -#else - - return core::detail::demangle( ti.name() ); - -#endif -} - } // namespace core } // namespace boost #undef BOOST_CORE_HAS_CXXABI_H -#endif // #ifndef BOOST_CORE_DEMANGLED_NAME_HPP_INCLUDED +#endif // #ifndef BOOST_CORE_DEMANGLE_HPP_INCLUDED diff --git a/include/boost/core/lightweight_test_trait.hpp b/include/boost/core/lightweight_test_trait.hpp index d8e756c..ff03e37 100644 --- a/include/boost/core/lightweight_test_trait.hpp +++ b/include/boost/core/lightweight_test_trait.hpp @@ -19,7 +19,6 @@ #include #include -#include namespace boost { diff --git a/include/boost/core/typeinfo.hpp b/include/boost/core/typeinfo.hpp index 49d7731..e67b4a3 100644 --- a/include/boost/core/typeinfo.hpp +++ b/include/boost/core/typeinfo.hpp @@ -64,6 +64,11 @@ public: } }; +inline char const * demangled_name( core::typeinfo const & ti ) +{ + return ti.name(); +} + } // namespace core namespace detail @@ -111,6 +116,7 @@ template struct core_typeid_< T const volatile >: core_typeid_< T > #else +#include #include namespace boost @@ -129,6 +135,11 @@ typedef std::type_info typeinfo; #endif +inline std::string demangled_name( core::typeinfo const & ti ) +{ + return core::demangle( ti.name() ); +} + } // namespace core } // namespace boost diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index a1fdd4a..40c374e 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -59,7 +59,9 @@ run-fail lightweight_test_fail4.cpp ; run-fail lightweight_test_fail5.cpp ; run-fail lightweight_test_fail6.cpp ; run-fail lightweight_test_fail7.cpp ; +run-fail lightweight_test_fail7.cpp : : : off : lightweight_test_fail7_no_rtti ; run-fail lightweight_test_fail8.cpp ; +run-fail lightweight_test_fail8.cpp : : : off : lightweight_test_fail8_no_rtti ; run is_same_test.cpp ; @@ -69,4 +71,7 @@ run typeinfo_test.cpp : : : off : typeinfo_test_no_rtti ; run iterator_test.cpp ; run detail_iterator_test.cpp ; +run demangle_test.cpp : : : always_show_run_output ; + run demangled_name_test.cpp : : : always_show_run_output ; +run demangled_name_test.cpp : : : off always_show_run_output : demangled_name_test_no_rtti ; diff --git a/test/demangle_test.cpp b/test/demangle_test.cpp new file mode 100644 index 0000000..a54e743 --- /dev/null +++ b/test/demangle_test.cpp @@ -0,0 +1,23 @@ +// +// Trivial test for core::demangle +// +// Copyright (c) 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 +#include + +template struct Y1 +{ +}; + +int main() +{ + typedef Y1 T; + std::cout << boost::core::demangle( typeid( T ).name() ); + return 0; +} diff --git a/test/demangled_name_test.cpp b/test/demangled_name_test.cpp index 06da694..e975ea2 100644 --- a/test/demangled_name_test.cpp +++ b/test/demangled_name_test.cpp @@ -8,7 +8,6 @@ // http://www.boost.org/LICENSE_1_0.txt // -#include #include #include