debug mode maintenance patch

François Dumont frs.dumont@gmail.com
Thu May 28 20:33:00 GMT 2015


On 25/05/2015 20:41, Jonathan Wakely wrote:
> On 25/05/15 15:31 +0200, François Dumont wrote:
>> Hi
>>
>>    This is a patch to clean the debug mode code.
>>
>>    I have introduced a new debug header, assertions.h, so that 
>> headers that only need _GLIBCXX_DEBUG_ASSERT do not have to include 
>> the big debug.h. I also introduce functions.tcc to isolate 
>> implementation of __foreign_iterator which require a number of other 
>> headers.
>
> All other uses of .tcc extensions are headers included automatically
> at the bottom of the corresponding .h header, so other headers never
> need to do #include <foo.tcc> because that appears at the end of
> <foo.h> (or <foo> for standard headers).
>
> Also, .tcc is meant to be for definitions of non-inline templates that
> are declared (but not defined) in the header that includes the .tcc
> file, but all the functions you're moving to <debug/functions.tcc> are
> still small and inline.
>
> If the point is just to move some functions to a different header
> because not all consumers of functions.h need those functions then I
> think it should have a different name, not pretend to be related to
> functions.h

Ok, then I kept __foreign_iterator within functions.h. I checked and 
none of the headers included are themselves including debug headers, as 
long as it is like that it is fine.

>
> I'm not convinced moving them to a separate header is even a good
> idea. Surely most headers that include <debug/functions.h> already end
> up including <bits/move.h> and <type_traits> anyway?
>
>
>>    * include/debug/debug.h ([_GLIBCXX_DEBUG_ASSERT,
>>    _GLIBCXX_DEBUG_PEDASSERT, _GLIBCXX_DEBUG_ONLY]): Move definition...
>
> These names should not be in square brackets (square brackets are used
> to indicate conditional changes, see
> http://www.gnu.org/prep/standards/html_node/Conditional-Changes.html)

Sorry, I saw it used so many times for macros that I though it was the 
right way to report macro modifications.

I also replicate Copyrights from debug.h to assertions.h.

     * include/debug/debug.h (_GLIBCXX_DEBUG_ASSERT,
     _GLIBCXX_DEBUG_PEDASSERT, _GLIBCXX_DEBUG_ONLY): Move definition...
     * include/debug/assertions.h: ...here, new.
     * include/debug/formatter.h
     (struct _Error_formatter::_Is_iterator_value_type): New.
     (struct _Error_formatter::_Is_instance): New.
     (struct _Error_formatter::_Parameter): Make public and not friend
     anymore.
     (_Error_formatter::_Parameter::__instance): New _M_kind enum entry.
     (_Error_formatter::_Parameter::__iterator_value_type): New _M_kind enum
     entry.
     (struct _Error_formatter::_Parameter::_Type): New.
     (struct _Error_formatter::_Parameter::_Instance): New, inherit from
     latter.
     (union _Error_formatter::_Parameter::_M_variant): Reorganize.
     (_Parameter(_Iterator const&, const char*, _Is_iterator)): Make all
     overloads take iterator through a const reference.
     (_Parameter(const _Iterator&, const char*, _Is_iterator_value_type)):
     New.
     (_Parameter(const _Type&, const char*, _Is_instance)): New.
     (_Error_formatter::_M_print_type): Delete.
     (_Error_formatter::_M_iterator_value_type): New.
     (_Error_formatter::_M_instance): New.
     * include/Makefile.am: Add new above debug file.
     * include/Makefile.in: Regenerate.
     * include/debug/functions.h
     (__check_dereferenceable(const _Safe_iterator<>&),
     __valid_range(const _Safe_iterator<>&),
     struct __is_safe_random_iterator<_Safe_iterator<>>): Move...
     * include/debug/safe_iterator.h: ... here.
     Replace debug.h include with assertions.h.
     (__check_singular_aux): Move...
     * include/debug/safe_base.h: ... here.
     * include/debug/functions.h
     (__check_dereferenceable(const _Safe_local_iterator<>&),
     __valid_range(const _Safe_local_iterator<>&): Move...
     * include/debug/safe_local_iterator.h: ...here.
     * include/debug/safe_sequence.h: Replace debug.h with assertions.h.
     Remove _Safe_iterator declaration.
     * include/debug/safe_unordered_container.h: Replace debug.h with
     assertions.h.
     * include/debug/array: Replace safe_sequence.h include with
     formatter.h and macros.h.
     * include/debug/deque: Include functions.tcc.
     * include/debug/forward_list: Likewise.
     * include/debug/list: Likewise.
     * include/debug/string: Likewise.
     * include/debug/vector: Likewise.
     * include/bits/unique_ptr.h: Replace debug.h include with new
     assertions.h.
     * include/bits/stl_iterator_base_funcs.h: Likewise.
     * testsuite/23_containers/array/tuple_interface/get_debug_neg.cc:
     Adjust dg-error line number.
     * testsuite/23_containers/array/tuple_interface/
     tuple_element_debug_neg.cc: Likewise.
     * src/c++11/debug.cc: Adapt.

Tested under Linux x86_64.

Ok to commit ?

François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: debug.patch
Type: text/x-patch
Size: 31128 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20150528/9eb5e2ea/attachment.bin>


More information about the Libstdc++ mailing list