Apply [[standalone_debug]] to some types in the STL.

Add this attribute to some types to ensure that they have
debug info.
The debug info for these classes are required for debuggers to display
some STL types. With constructor homing (a new debug info optimization)
their debug info isn't emitted because their constructors are never
called.

The list of types with the attribute added are __hash_value_type,
__value_type, __tree_node_base, __tree_node, __hash_node, __list_node,
and __forward_list_node.

Differential Revision: https://reviews.llvm.org/D98750
This commit is contained in:
Amy Huang 2021-03-15 14:20:49 -07:00
parent 06b40e80ae
commit 7c2f58278e
7 changed files with 13 additions and 7 deletions

View File

@ -1342,6 +1342,12 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
#endif
#endif // !defined(_LIBCPP_NODEBUG_TYPE)
#if __has_attribute(__standalone_debug__)
#define _LIBCPP_STANDALONE_DEBUG __attribute__((__standalone_debug__))
#else
#define _LIBCPP_STANDALONE_DEBUG
#endif
#if __has_attribute(__preferred_name__)
#define _LIBCPP_PREFERRED_NAME(x) __attribute__((__preferred_name__(x)))
#else

View File

@ -89,7 +89,7 @@ struct __hash_node_base
};
template <class _Tp, class _VoidPtr>
struct __hash_node
struct _LIBCPP_STANDALONE_DEBUG __hash_node
: public __hash_node_base
<
typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, _VoidPtr> >::type

View File

@ -714,7 +714,7 @@ public:
};
template <class _VoidPtr>
class __tree_node_base
class _LIBCPP_STANDALONE_DEBUG __tree_node_base
: public __tree_node_base_types<_VoidPtr>::__end_node_type
{
typedef __tree_node_base_types<_VoidPtr> _NodeBaseTypes;
@ -742,7 +742,7 @@ private:
};
template <class _Tp, class _VoidPtr>
class __tree_node
class _LIBCPP_STANDALONE_DEBUG __tree_node
: public __tree_node_base<_VoidPtr>
{
public:

View File

@ -272,7 +272,7 @@ struct _LIBCPP_HIDDEN __begin_node_of
};
template <class _Tp, class _VoidPtr>
struct __forward_list_node
struct _LIBCPP_STANDALONE_DEBUG __forward_list_node
: public __begin_node_of<_Tp, _VoidPtr>::type
{
typedef _Tp value_type;

View File

@ -267,7 +267,7 @@ struct __list_node_base
};
template <class _Tp, class _VoidPtr>
struct __list_node
struct _LIBCPP_STANDALONE_DEBUG __list_node
: public __list_node_base<_Tp, _VoidPtr>
{
_Tp __value_;

View File

@ -667,7 +667,7 @@ template <class _TreeIterator> class __map_const_iterator;
#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Tp>
struct __value_type
struct _LIBCPP_STANDALONE_DEBUG __value_type
{
typedef _Key key_type;
typedef _Tp mapped_type;

View File

@ -702,7 +702,7 @@ public:
#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Tp>
struct __hash_value_type
struct _LIBCPP_STANDALONE_DEBUG __hash_value_type
{
typedef _Key key_type;
typedef _Tp mapped_type;