public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* Add clang-format for libstdc++
@ 2023-02-07 20:38 Dimitrij Mijoski
  2023-02-07 21:01 ` Thomas Rodgers
  2023-02-07 21:17 ` Jonathan Wakely
  0 siblings, 2 replies; 9+ messages in thread
From: Dimitrij Mijoski @ 2023-02-07 20:38 UTC (permalink / raw)
  To: libstdc++

Is there interest to add a clang-format file for libstdc++?

The basic idea is to take the existing clang format located at contrib/clang-format,
copy it to contrib/clang-format-libstdc++, and modify it according to libstdc++ rules
https://gcc.gnu.org/onlinedocs/libstdc++/manual/source_code_style.html .
Similarly to the first clang-format, it will be optional and it will be enabled if the developer
calls the command:

make clang-format

inside the build tree. That will create the symbolic link srcdir/libstdc++-v3/.clang-format .
Alternatively, it can be put directly where it is required without the need for the invocation
of make.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Add clang-format for libstdc++
  2023-02-07 20:38 Add clang-format for libstdc++ Dimitrij Mijoski
@ 2023-02-07 21:01 ` Thomas Rodgers
  2023-02-07 21:19   ` Jonathan Wakely
  2023-02-10 22:05   ` Stephan Bergmann
  2023-02-07 21:17 ` Jonathan Wakely
  1 sibling, 2 replies; 9+ messages in thread
From: Thomas Rodgers @ 2023-02-07 21:01 UTC (permalink / raw)
  To: Dimitrij Mijoski; +Cc: libstdc++

[-- Attachment #1: Type: text/plain, Size: 2179 bytes --]

I am potentially interested in this, with an additional twist -

Is it possible to get clang-format to enforce the libstdc++ uglification
rules (probably requires a clang-format plugin though)?

The concrete example I am thinking of here is when we adopt something like
the PSTL. It was a substantial manual effort to do the uglification on that
code in the first place, and despite multiple reviews by myself and
jwakely, we still managed to miss some identifiers. To complicate matters,
the upstream also makes ongoing changes while making a best effort to
preserve the uglifcation. They also miss some uglfications. The main
contributors in this case are shipping the PSTL as part of oneTBB and so
don't have the same requirements to 'get it right' as libstdc++, so this
often goes undetected.

I am looking to rebase libstdc++'s PSTL in the near future so I'd be
willing to try something based on clang-format, if it existed, for this
particular purpose (I'm less interested in enforcing the indentation rules
in this case, as I want to preserve the upstream's formatting).

I also think it is potentially useful to have both the uglification and
indentation combined. The case I'm thinking of is something like the <simd>
contribution (or ranges) which are similarly large and need to get the
uglification checks and in those cases, the correct libstdc++ formatting as
part of the adoption process.



On Tue, Feb 7, 2023 at 12:39 PM Dimitrij Mijoski via Libstdc++ <
libstdc++@gcc.gnu.org> wrote:

> Is there interest to add a clang-format file for libstdc++?
>
> The basic idea is to take the existing clang format located at
> contrib/clang-format,
> copy it to contrib/clang-format-libstdc++, and modify it according to
> libstdc++ rules
> https://gcc.gnu.org/onlinedocs/libstdc++/manual/source_code_style.html .
> Similarly to the first clang-format, it will be optional and it will be
> enabled if the developer
> calls the command:
>
> make clang-format
>
> inside the build tree. That will create the symbolic link
> srcdir/libstdc++-v3/.clang-format .
> Alternatively, it can be put directly where it is required without the
> need for the invocation
> of make.
>
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Add clang-format for libstdc++
  2023-02-07 20:38 Add clang-format for libstdc++ Dimitrij Mijoski
  2023-02-07 21:01 ` Thomas Rodgers
@ 2023-02-07 21:17 ` Jonathan Wakely
  2023-02-08 20:04   ` Björn Schäpers
  1 sibling, 1 reply; 9+ messages in thread
From: Jonathan Wakely @ 2023-02-07 21:17 UTC (permalink / raw)
  To: Dimitrij Mijoski; +Cc: libstdc++

On Tue, 7 Feb 2023 at 20:39, Dimitrij Mijoski via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> Is there interest to add a clang-format file for libstdc++?
>
> The basic idea is to take the existing clang format located at contrib/clang-format,
> copy it to contrib/clang-format-libstdc++, and modify it according to libstdc++ rules
> https://gcc.gnu.org/onlinedocs/libstdc++/manual/source_code_style.html .
> Similarly to the first clang-format, it will be optional and it will be enabled if the developer
> calls the command:
>
> make clang-format
>
> inside the build tree. That will create the symbolic link srcdir/libstdc++-v3/.clang-format .
> Alternatively, it can be put directly where it is required without the need for the invocation
> of make.

If you want to do the work and contribute it, please go ahead. But
last time somebody looked into it, clang-format doesn't support our
code style conventions. There was something in our template
indentation that clang-format doesn't support, and can't be configured
to support.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Add clang-format for libstdc++
  2023-02-07 21:01 ` Thomas Rodgers
@ 2023-02-07 21:19   ` Jonathan Wakely
  2023-02-07 21:24     ` Thomas Rodgers
  2023-02-10 22:05   ` Stephan Bergmann
  1 sibling, 1 reply; 9+ messages in thread
From: Jonathan Wakely @ 2023-02-07 21:19 UTC (permalink / raw)
  To: Thomas Rodgers; +Cc: Dimitrij Mijoski, libstdc++

On Tue, 7 Feb 2023 at 21:02, Thomas Rodgers via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> I am potentially interested in this, with an additional twist -
>
> Is it possible to get clang-format to enforce the libstdc++ uglification
> rules (probably requires a clang-format plugin though)?
>
> The concrete example I am thinking of here is when we adopt something like
> the PSTL. It was a substantial manual effort to do the uglification on that
> code in the first place, and despite multiple reviews by myself and
> jwakely, we still managed to miss some identifiers. To complicate matters,
> the upstream also makes ongoing changes while making a best effort to
> preserve the uglifcation. They also miss some uglfications. The main
> contributors in this case are shipping the PSTL as part of oneTBB and so
> don't have the same requirements to 'get it right' as libstdc++, so this
> often goes undetected.
>
> I am looking to rebase libstdc++'s PSTL in the near future so I'd be
> willing to try something based on clang-format, if it existed, for this
> particular purpose (I'm less interested in enforcing the indentation rules
> in this case, as I want to preserve the upstream's formatting).
>
> I also think it is potentially useful to have both the uglification and
> indentation combined. The case I'm thinking of is something like the <simd>
> contribution (or ranges) which are similarly large and need to get the
> uglification checks and in those cases, the correct libstdc++ formatting as
> part of the adoption process.


The best we have for this right now is the 17_intro/names.cc test.
Names that are used in the PSTL (e.g. "binary_op", "exec", etc.)
should be added to that file, so that if they appear without the "__"
prefix we get test failures.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Add clang-format for libstdc++
  2023-02-07 21:19   ` Jonathan Wakely
@ 2023-02-07 21:24     ` Thomas Rodgers
  0 siblings, 0 replies; 9+ messages in thread
From: Thomas Rodgers @ 2023-02-07 21:24 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: Dimitrij Mijoski, libstdc++

[-- Attachment #1: Type: text/plain, Size: 2001 bytes --]

On Tue, Feb 7, 2023 at 1:20 PM Jonathan Wakely <jwakely@redhat.com> wrote:

> On Tue, 7 Feb 2023 at 21:02, Thomas Rodgers via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
> >
> > I am potentially interested in this, with an additional twist -
> >
> > Is it possible to get clang-format to enforce the libstdc++ uglification
> > rules (probably requires a clang-format plugin though)?
> >
> > The concrete example I am thinking of here is when we adopt something
> like
> > the PSTL. It was a substantial manual effort to do the uglification on
> that
> > code in the first place, and despite multiple reviews by myself and
> > jwakely, we still managed to miss some identifiers. To complicate
> matters,
> > the upstream also makes ongoing changes while making a best effort to
> > preserve the uglifcation. They also miss some uglfications. The main
> > contributors in this case are shipping the PSTL as part of oneTBB and so
> > don't have the same requirements to 'get it right' as libstdc++, so this
> > often goes undetected.
> >
> > I am looking to rebase libstdc++'s PSTL in the near future so I'd be
> > willing to try something based on clang-format, if it existed, for this
> > particular purpose (I'm less interested in enforcing the indentation
> rules
> > in this case, as I want to preserve the upstream's formatting).
> >
> > I also think it is potentially useful to have both the uglification and
> > indentation combined. The case I'm thinking of is something like the
> <simd>
> > contribution (or ranges) which are similarly large and need to get the
> > uglification checks and in those cases, the correct libstdc++ formatting
> as
> > part of the adoption process.
>
>
> The best we have for this right now is the 17_intro/names.cc test.
> Names that are used in the PSTL (e.g. "binary_op", "exec", etc.)
> should be added to that file, so that if they appear without the "__"
> prefix we get test failures.
>
>
Thanks, I hate it. I'll add them with the upcoming PSTL rebase work.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Add clang-format for libstdc++
  2023-02-07 21:17 ` Jonathan Wakely
@ 2023-02-08 20:04   ` Björn Schäpers
  0 siblings, 0 replies; 9+ messages in thread
From: Björn Schäpers @ 2023-02-08 20:04 UTC (permalink / raw)
  To: Jonathan Wakely, Dimitrij Mijoski; +Cc: libstdc++

Am 07.02.2023 um 22:17 schrieb Jonathan Wakely via Libstdc++:
> On Tue, 7 Feb 2023 at 20:39, Dimitrij Mijoski via Libstdc++
> <libstdc++@gcc.gnu.org> wrote:
>>
>> Is there interest to add a clang-format file for libstdc++?
>>
>> The basic idea is to take the existing clang format located at contrib/clang-format,
>> copy it to contrib/clang-format-libstdc++, and modify it according to libstdc++ rules
>> https://gcc.gnu.org/onlinedocs/libstdc++/manual/source_code_style.html .
>> Similarly to the first clang-format, it will be optional and it will be enabled if the developer
>> calls the command:
>>
>> make clang-format
>>
>> inside the build tree. That will create the symbolic link srcdir/libstdc++-v3/.clang-format .
>> Alternatively, it can be put directly where it is required without the need for the invocation
>> of make.
> 
> If you want to do the work and contribute it, please go ahead. But
> last time somebody looked into it, clang-format doesn't support our
> code style conventions. There was something in our template
> indentation that clang-format doesn't support, and can't be configured
> to support.
> 

As someone who develops on clang-format: That could be changed.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Add clang-format for libstdc++
  2023-02-07 21:01 ` Thomas Rodgers
  2023-02-07 21:19   ` Jonathan Wakely
@ 2023-02-10 22:05   ` Stephan Bergmann
  2023-02-10 23:02     ` Jonathan Wakely
  1 sibling, 1 reply; 9+ messages in thread
From: Stephan Bergmann @ 2023-02-10 22:05 UTC (permalink / raw)
  To: libstdc++

[-- Attachment #1: Type: text/plain, Size: 36993 bytes --]

On 2/7/23 22:01, Thomas Rodgers via Libstdc++ wrote:
> Is it possible to get clang-format to enforce the libstdc++ uglification
> rules (probably requires a clang-format plugin though)?

I'm not sure clang-format can do that, but it wouldn't be too hard to 
come up with a clang-tidy checker to report missing uglification.

With the attached Makefile, input.cc, and stdlibunreserved.cc, which 
should work at least against a recent LLVM 17 trunk, and run against a 
recent libstdc++ 13 trunk,

> $ make
> g++ -fPIC $(/home/sbergman/llvm/inst/bin/llvm-config --cxxflags) stdlibunreserved.cc -shared \
>             $(/home/sbergman/llvm/inst/bin/llvm-config --ldflags) -o stdlibunreserved.so
> /home/sbergman/llvm/inst/bin/clang-tidy --load=./stdlibunreserved.so \
>             --checks='-*,stdlibunreserved' --header-filter='.*' \
>             --system-headers --extra-arg=--gcc-install-dir=/home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1 \
>             --extra-arg=-std=c++2b --extra-arg=-D_GLIBCXX_DEBUG input.cc --
> 139 warnings generated.
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/cxxabi_init_exception.h:70:42: warning: ParmVar uses unreserved identifier 'object' [stdlibunreserved]
>       __cxa_init_primary_exception(void *object, std::type_info *tinfo,
>                                    ~~~~~~^~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/cxxabi_init_exception.h:70:66: warning: ParmVar uses unreserved identifier 'tinfo' [stdlibunreserved]
>       __cxa_init_primary_exception(void *object, std::type_info *tinfo,
>                                                  ~~~~~~~~~~~~~~~~^~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/cxxabi_init_exception.h:71:47: warning: ParmVar uses unreserved identifier 'dest' [stdlibunreserved]
>                 void (_GLIBCXX_CDTOR_CALLABI *dest) (void *)) _GLIBCXX_NOTHROW;
>                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/fs_ops.h:93:54: warning: ParmVar uses unreserved identifier 'attributes' [stdlibunreserved]
>   bool create_directory(const path& __p, const path& attributes);
>                                          ~~~~~~~~~~~~^~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/fs_ops.h:94:54: warning: ParmVar uses unreserved identifier 'attributes' [stdlibunreserved]
>   bool create_directory(const path& __p, const path& attributes,
>                                          ~~~~~~~~~~~~^~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/fs_path.h:523:41: warning: ParmVar uses unreserved identifier 'base' [stdlibunreserved]
>     path lexically_relative(const path& base) const;
>                             ~~~~~~~~~~~~^~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/fs_path.h:524:42: warning: ParmVar uses unreserved identifier 'base' [stdlibunreserved]
>     path lexically_proximate(const path& base) const;
>                              ~~~~~~~~~~~~^~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/iterator_concepts.h:968:21: warning: TemplateTypeParm uses unreserved identifier 'auto:1' [stdlibunreserved]
>     void begin(auto&) = delete;
>                ~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/iterator_concepts.h:969:27: warning: TemplateTypeParm uses unreserved identifier 'auto:1' [stdlibunreserved]
>     void begin(const auto&) = delete;
>                      ~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/memory_resource.h:85:5: warning: CXXMethod uses unreserved identifier 'do_allocate' [stdlibunreserved]
>     do_allocate(size_t __bytes, size_t __alignment) = 0;
> ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/memory_resource.h:88:5: warning: CXXMethod uses unreserved identifier 'do_deallocate' [stdlibunreserved]
>     do_deallocate(void* __p, size_t __bytes, size_t __alignment) = 0;
> ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/memory_resource.h:91:5: warning: CXXMethod uses unreserved identifier 'do_is_equal' [stdlibunreserved]
>     do_is_equal(const memory_resource& __other) const noexcept = 0;
> ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_algo.h:3493:16: warning: TemplateTypeParm uses unreserved identifier 'Proj1' [stdlibunreserved]
>              typename Proj1 = identity, typename Proj2 = identity>
>              ~~~~~~~~~^~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_algo.h:3493:43: warning: TemplateTypeParm uses unreserved identifier 'Proj2' [stdlibunreserved]
>              typename Proj1 = identity, typename Proj2 = identity>
>                                         ~~~~~~~~~^~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_algo.h:3571:74: warning: TemplateTypeParm uses unreserved identifier 'T' [stdlibunreserved]
>     template<forward_iterator _Iter, sentinel_for<_Iter> _Sent, typename T, typename _Proj = identity>
>                                                                 ~~~~~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_algo.h:3602:45: warning: TemplateTypeParm uses unreserved identifier 'T' [stdlibunreserved]
>     template<forward_range _Range, typename T, typename _Proj = identity>
>                                    ~~~~~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_base.h:136:19: warning: TemplateTypeParm uses unreserved identifier 'auto:1' [stdlibunreserved]
>     void end(auto&) = delete;
>              ~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_base.h:137:25: warning: TemplateTypeParm uses unreserved identifier 'auto:1' [stdlibunreserved]
>     void end(const auto&) = delete;
>                    ~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_base.h:225:22: warning: TemplateTypeParm uses unreserved identifier 'auto:1' [stdlibunreserved]
>     void rbegin(auto&) = delete;
>                 ~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_base.h:226:28: warning: TemplateTypeParm uses unreserved identifier 'auto:1' [stdlibunreserved]
>     void rbegin(const auto&) = delete;
>                       ~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_base.h:289:20: warning: TemplateTypeParm uses unreserved identifier 'auto:1' [stdlibunreserved]
>     void rend(auto&) = delete;
>               ~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_base.h:290:26: warning: TemplateTypeParm uses unreserved identifier 'auto:1' [stdlibunreserved]
>     void rend(const auto&) = delete;
>                     ~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_base.h:373:20: warning: TemplateTypeParm uses unreserved identifier 'auto:1' [stdlibunreserved]
>     void size(auto&) = delete;
>               ~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_base.h:374:26: warning: TemplateTypeParm uses unreserved identifier 'auto:1' [stdlibunreserved]
>     void size(const auto&) = delete;
>                     ~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/regex.h:1762:52: warning: Typedef uses unreserved identifier 'match_flag_type' [stdlibunreserved]
>       typedef regex_constants::match_flag_type             match_flag_type;
>       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/regex_automaton.h:113:28: warning: ParmVar uses unreserved identifier 'ostr' [stdlibunreserved]
>     _M_print(std::ostream& ostr) const;
>              ~~~~~~~~~~~~~~^~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/regex_automaton.tcc:39:39: warning: ParmVar uses unreserved identifier 'ostr' [stdlibunreserved]
>   _State_base::_M_print(std::ostream& ostr) const
>                         ~~~~~~~~~~~~~~^~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/regex_error.h:139:11: warning: TypeAlias uses unreserved identifier 'error_type' [stdlibunreserved]
>     using error_type = regex_constants::error_type;
>     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/regex_scanner.tcc:487:28: warning: ParmVar uses unreserved identifier 'ostr' [stdlibunreserved]
>     _M_print(std::ostream& ostr)
>              ~~~~~~~~~~~~~~^~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/shared_ptr_atomic.h:377:13: warning: TypeAlias uses unreserved identifier 'value_type' [stdlibunreserved]
>       using value_type = _Tp;
>       ~~~~~~^~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/shared_ptr_atomic.h:539:7: warning: CXXMethod uses unreserved identifier 'load' [stdlibunreserved]
>       load(memory_order __o) const noexcept
> ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/shared_ptr_atomic.h:557:7: warning: CXXMethod uses unreserved identifier 'swap' [stdlibunreserved]
>       swap(value_type& __r, memory_order __o) noexcept
> ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/shared_ptr_atomic.h:565:7: warning: CXXMethod uses unreserved identifier 'compare_exchange_strong' [stdlibunreserved]
>       compare_exchange_strong(value_type& __expected, value_type __desired,
> ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/shared_ptr_atomic.h:589:7: warning: CXXMethod uses unreserved identifier 'wait' [stdlibunreserved]
>       wait(value_type __old, memory_order __o) const noexcept
> ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/shared_ptr_atomic.h:599:7: warning: CXXMethod uses unreserved identifier 'notify_one' [stdlibunreserved]
>       notify_one() noexcept
> ~~~~~~^~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/shared_ptr_atomic.h:605:7: warning: CXXMethod uses unreserved identifier 'notify_all' [stdlibunreserved]
>       notify_all() noexcept
> ~~~~~~^~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/shared_ptr_base.h:828:13: warning: TypeAlias uses unreserved identifier 'pointer' [stdlibunreserved]
>       using pointer = typename allocator_traits<_Alloc>::pointer;
>       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/std_mutex.h:145:11: warning: TypeAlias uses unreserved identifier 'timespec' [stdlibunreserved]
>     using timespec = __gthread_time_t;
>     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/unordered_map.h:2177:8: warning: TypeAlias uses unreserved identifier 'unordered_map' [stdlibunreserved]
>         using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>;
>         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/unordered_map.h:2179:8: warning: TypeAlias uses unreserved identifier 'unordered_multimap' [stdlibunreserved]
>         using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>;
>         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/unordered_map.h:2201:8: warning: TypeAlias uses unreserved identifier 'unordered_map' [stdlibunreserved]
>         using unordered_map = _GLIBCXX_STD_C::unordered_map<_Tp...>;
>         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/unordered_map.h:2203:8: warning: TypeAlias uses unreserved identifier 'unordered_multimap' [stdlibunreserved]
>         using unordered_multimap = _GLIBCXX_STD_C::unordered_multimap<_Tp...>;
>         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/unordered_set.h:1846:8: warning: TypeAlias uses unreserved identifier 'unordered_set' [stdlibunreserved]
>         using unordered_set = _GLIBCXX_STD_C::unordered_set<_Tp...>;
>         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/unordered_set.h:1848:8: warning: TypeAlias uses unreserved identifier 'unordered_multiset' [stdlibunreserved]
>         using unordered_multiset = _GLIBCXX_STD_C::unordered_multiset<_Tp...>;
>         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/unordered_set.h:1870:8: warning: TypeAlias uses unreserved identifier 'unordered_set' [stdlibunreserved]
>         using unordered_set = _GLIBCXX_STD_C::unordered_set<_Tp...>;
>         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/unordered_set.h:1872:8: warning: TypeAlias uses unreserved identifier 'unordered_multiset' [stdlibunreserved]
>         using unordered_multiset = _GLIBCXX_STD_C::unordered_multiset<_Tp...>;
>         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/chrono:2966:8: warning: TypeAlias uses unreserved identifier 'string_view' [stdlibunreserved]
>         using string_view = type_identity_t<std::string_view>;
>         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/compare:736:13: warning: TypeAlias uses unreserved identifier 'int64_t' [stdlibunreserved]
>       using int64_t = __INT64_TYPE__;
>       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/compare:737:13: warning: TypeAlias uses unreserved identifier 'int32_t' [stdlibunreserved]
>       using int32_t = __INT32_TYPE__;
>       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/compare:738:13: warning: TypeAlias uses unreserved identifier 'int16_t' [stdlibunreserved]
>       using int16_t = __INT16_TYPE__;
>       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/compare:739:13: warning: TypeAlias uses unreserved identifier 'uint64_t' [stdlibunreserved]
>       using uint64_t = __UINT64_TYPE__;
>       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/compare:740:13: warning: TypeAlias uses unreserved identifier 'uint16_t' [stdlibunreserved]
>       using uint16_t = __UINT16_TYPE__;
>       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/condition_variable:72:11: warning: TypeAlias uses unreserved identifier 'steady_clock' [stdlibunreserved]
>     using steady_clock = chrono::steady_clock;
>     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/condition_variable:73:11: warning: TypeAlias uses unreserved identifier 'system_clock' [stdlibunreserved]
>     using system_clock = chrono::system_clock;
>     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/debug/safe_local_iterator.h:71:45: warning: Typedef uses unreserved identifier 'size_type' [stdlibunreserved]
>       typedef typename _Sequence::size_type size_type;
>       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/debug/safe_sequence.h:77:7: warning: Typedef uses unreserved identifier 'difference_type' [stdlibunreserved]
>       difference_type;
> ~~~~~~^~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/debug/vector:56:49: warning: Typedef uses unreserved identifier 'size_type' [stdlibunreserved]
>       typedef typename _BaseSequence::size_type size_type;
>       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/ext/concurrence.h:288:24: warning: ParmVar uses unreserved identifier 'mutex' [stdlibunreserved]
>     void wait(__mutex *mutex)
>               ~~~~~~~~~^~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/ext/concurrence.h:298:44: warning: ParmVar uses unreserved identifier 'mutex' [stdlibunreserved]
>     void wait_recursive(__recursive_mutex *mutex)
>                         ~~~~~~~~~~~~~~~~~~~^~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/format:291:10: warning: Binding uses unreserved identifier 'ptr' [stdlibunreserved]
>           auto [ptr, ec] = std::from_chars(__first, __last, __val);
>                 ^~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/format:291:15: warning: Binding uses unreserved identifier 'ec' [stdlibunreserved]
>           auto [ptr, ec] = std::from_chars(__first, __last, __val);
>                      ^~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/format:2532:13: warning: TypeAlias uses unreserved identifier 'uint64_t' [stdlibunreserved]
>       using uint64_t = __UINTPTR_TYPE__;
>       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/format:3159:13: warning: TypeAlias uses unreserved identifier 'uint64_t' [stdlibunreserved]
>       using uint64_t = __UINT64_TYPE__;
>       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/format:3532:13: warning: TypeAlias uses unreserved identifier 'iterator' [stdlibunreserved]
>       using iterator = typename _Scanner<_CharT>::iterator;
>       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/memory_resource:126:5: warning: CXXMethod uses unreserved identifier 'allocate' [stdlibunreserved]
>     allocate(size_t __bytes, size_t __alignment);
> ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/memory_resource:130:5: warning: CXXMethod uses unreserved identifier 'deallocate' [stdlibunreserved]
>     deallocate(void* __p, size_t __bytes, size_t __alignment);
> ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/memory_resource:134:10: warning: CXXMethod uses unreserved identifier 'release' [stdlibunreserved]
>     void release() noexcept;
>     ~~~~~^~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/memory_resource:136:22: warning: CXXMethod uses unreserved identifier 'resource' [stdlibunreserved]
>     memory_resource* resource() const noexcept
>     ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/mutex:297:30: warning: ParmVar uses unreserved identifier 'clockid' [stdlibunreserved]
>       _M_clocklock(clockid_t clockid, const __gthread_time_t& __ts)
>                    ~~~~~~~~~~^~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/mutex:375:30: warning: ParmVar uses unreserved identifier 'clockid' [stdlibunreserved]
>       _M_clocklock(clockid_t clockid, const __gthread_time_t& __ts)
>                    ~~~~~~~~~~^~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_fwd.h:367:17: warning: TemplateTypeParm uses unreserved identifier 'IsVector' [stdlibunreserved]
>           class IsVector>
>           ~~~~~~^~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_fwd.h:374:17: warning: TemplateTypeParm uses unreserved identifier 'IsVector' [stdlibunreserved]
>           class IsVector>
>           ~~~~~~^~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_fwd.h:531:41: warning: TemplateTypeParm uses unreserved identifier 'OutputIterator' [stdlibunreserved]
> template <class _ForwardIterator, class OutputIterator, class _BinaryPredicate>
>                                   ~~~~~~^~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_fwd.h:923:17: warning: TemplateTypeParm uses unreserved identifier 'OutputIterator' [stdlibunreserved]
> template <class OutputIterator, class Size, class _Generator>
>           ~~~~~~^~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_fwd.h:923:39: warning: TemplateTypeParm uses unreserved identifier 'Size' [stdlibunreserved]
> template <class OutputIterator, class Size, class _Generator>
>                                 ~~~~~~^~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_fwd.h:927:17: warning: TemplateTypeParm uses unreserved identifier 'OutputIterator' [stdlibunreserved]
> template <class OutputIterator, class Size, class _Generator>
>           ~~~~~~^~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_fwd.h:927:39: warning: TemplateTypeParm uses unreserved identifier 'Size' [stdlibunreserved]
> template <class OutputIterator, class Size, class _Generator>
>                                 ~~~~~~^~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_fwd.h:931:41: warning: TemplateTypeParm uses unreserved identifier 'OutputIterator' [stdlibunreserved]
> template <class _ExecutionPolicy, class OutputIterator, class Size, class _Generator, class _IsVector>
>                                   ~~~~~~^~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_fwd.h:931:63: warning: TemplateTypeParm uses unreserved identifier 'Size' [stdlibunreserved]
> template <class _ExecutionPolicy, class OutputIterator, class Size, class _Generator, class _IsVector>
>                                                         ~~~~~~^~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_fwd.h:936:41: warning: TemplateTypeParm uses unreserved identifier 'OutputIterator' [stdlibunreserved]
> template <class _ExecutionPolicy, class OutputIterator, class Size, class _Generator, class _IsVector>
>                                   ~~~~~~^~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_fwd.h:936:63: warning: TemplateTypeParm uses unreserved identifier 'Size' [stdlibunreserved]
> template <class _ExecutionPolicy, class OutputIterator, class Size, class _Generator, class _IsVector>
>                                                         ~~~~~~^~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_impl.h:1296:41: warning: TemplateTypeParm uses unreserved identifier 'OutputIterator' [stdlibunreserved]
> template <class _ForwardIterator, class OutputIterator, class _BinaryPredicate>
>                                   ~~~~~~^~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_impl.h:1304:46: warning: TemplateTypeParm uses unreserved identifier 'OutputIterator' [stdlibunreserved]
> template <class _RandomAccessIterator, class OutputIterator, class _BinaryPredicate>
>                                        ~~~~~~^~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_impl.h:1452:29: warning: ParmVar uses unreserved identifier '_is_vector' [stdlibunreserved]
>                   _IsVector _is_vector,
>                   ~~~~~~~~~~^~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_impl.h:2517:17: warning: TemplateTypeParm uses unreserved identifier 'OutputIterator' [stdlibunreserved]
> template <class OutputIterator, class Size, class _Generator>
>           ~~~~~~^~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_impl.h:2517:39: warning: TemplateTypeParm uses unreserved identifier 'Size' [stdlibunreserved]
> template <class OutputIterator, class Size, class _Generator>
>                                 ~~~~~~^~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_impl.h:2524:17: warning: TemplateTypeParm uses unreserved identifier 'OutputIterator' [stdlibunreserved]
> template <class OutputIterator, class Size, class _Generator>
>           ~~~~~~^~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/algorithm_impl.h:2524:39: warning: TemplateTypeParm uses unreserved identifier 'Size' [stdlibunreserved]
> template <class OutputIterator, class Size, class _Generator>
>                                 ~~~~~~^~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/execution_defs.h:17:11: warning: Namespace uses unreserved identifier 'execution' [stdlibunreserved]
> namespace execution
> ~~~~~~~~~~^~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/execution_defs.h:19:18: warning: Namespace uses unreserved identifier 'v1' [stdlibunreserved]
> inline namespace v1
> ~~~~~~~~~~~~~~~~~^~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/execution_impl.h:142:20: warning: TemplateTypeParm uses unreserved identifier 'policy' [stdlibunreserved]
> template <typename policy, typename... _IteratorTypes>
>           ~~~~~~~~~^~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/execution_impl.h:150:20: warning: TemplateTypeParm uses unreserved identifier 'policy' [stdlibunreserved]
> template <typename policy, typename... _IteratorTypes>
>           ~~~~~~~~~^~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/glue_algorithm_defs.h:142:107: warning: ParmVar uses unreserved identifier 'result' [stdlibunreserved]
> copy_if(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last, _ForwardIterator2 result,
>                                                                                         ~~~~~~~~~~~~~~~~~~^~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/glue_algorithm_defs.h:204:71: warning: ParmVar uses unreserved identifier 'count' [stdlibunreserved]
> generate_n(_ExecutionPolicy&& __exec, _ForwardIterator __first, _Size count, _Generator __g);
>                                                                 ~~~~~~^~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/glue_algorithm_defs.h:487:98: warning: ParmVar uses unreserved identifier 'result' [stdlibunreserved]
>                          _ForwardIterator2 __first2, _ForwardIterator2 __last2, _ForwardIterator result,
>                                                                                 ~~~~~~~~~~~~~~~~~^~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/glue_algorithm_impl.h:343:28: warning: ParmVar uses unreserved identifier 'x' [stdlibunreserved]
>         [__op](_Input1Type x, _Input2Type y, _OutputType z) mutable { z = __op(x, y); },
>                ~~~~~~~~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/glue_algorithm_impl.h:343:43: warning: ParmVar uses unreserved identifier 'y' [stdlibunreserved]
>         [__op](_Input1Type x, _Input2Type y, _OutputType z) mutable { z = __op(x, y); },
>                               ~~~~~~~~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/glue_algorithm_impl.h:343:58: warning: ParmVar uses unreserved identifier 'z' [stdlibunreserved]
>         [__op](_Input1Type x, _Input2Type y, _OutputType z) mutable { z = __op(x, y); },
>                                              ~~~~~~~~~~~~^
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/glue_numeric_defs.h:108:67: warning: ParmVar uses unreserved identifier 'op' [stdlibunreserved]
>                     _ForwardIterator2 __d_first, _BinaryOperation op);
>                                                  ~~~~~~~~~~~~~~~~~^~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/numeric_impl.h:300:67: warning: TemplateTypeParm uses unreserved identifier 'BinaryOperation' [stdlibunreserved]
> template <class _ForwardIterator1, class _ForwardIterator2, class BinaryOperation>
>                                                             ~~~~~~^~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/unseq_backend_simd.h:535:26: warning: ParmVar uses unreserved identifier 'value' [stdlibunreserved]
>     _Combiner(const _Tp& value, const _BinaryOp* bin_op) : __value(value), __bin_op(const_cast<_BinaryOp*>(bin_op)) {}
>               ~~~~~~~~~~~^~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/unseq_backend_simd.h:535:50: warning: ParmVar uses unreserved identifier 'bin_op' [stdlibunreserved]
>     _Combiner(const _Tp& value, const _BinaryOp* bin_op) : __value(value), __bin_op(const_cast<_BinaryOp*>(bin_op)) {}
>                                 ~~~~~~~~~~~~~~~~~^~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/unseq_backend_simd.h:627:40: warning: ParmVar uses unreserved identifier 'val' [stdlibunreserved]
>         _ComplexType(const _ValueType& val, const _Compare* comp)
>                      ~~~~~~~~~~~~~~~~~~^~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/unseq_backend_simd.h:627:61: warning: ParmVar uses unreserved identifier 'comp' [stdlibunreserved]
>         _ComplexType(const _ValueType& val, const _Compare* comp)
>                                             ~~~~~~~~~~~~~~~~^~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/unseq_backend_simd.h:688:40: warning: ParmVar uses unreserved identifier 'min_val' [stdlibunreserved]
>         _ComplexType(const _ValueType& min_val, const _ValueType& max_val, const _Compare* comp)
>                      ~~~~~~~~~~~~~~~~~~^~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/unseq_backend_simd.h:688:67: warning: ParmVar uses unreserved identifier 'max_val' [stdlibunreserved]
>         _ComplexType(const _ValueType& min_val, const _ValueType& max_val, const _Compare* comp)
>                                                 ~~~~~~~~~~~~~~~~~~^~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/pstl/unseq_backend_simd.h:688:92: warning: ParmVar uses unreserved identifier 'comp' [stdlibunreserved]
>         _ComplexType(const _ValueType& min_val, const _ValueType& max_val, const _Compare* comp)
>                                                                            ~~~~~~~~~~~~~~~~^~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/source_location:45:11: warning: TypeAlias uses unreserved identifier 'uint_least32_t' [stdlibunreserved]
>     using uint_least32_t = __UINT_LEAST32_TYPE__;
>     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/sstream:84:13: warning: TypeAlias uses unreserved identifier 'allocator_traits' [stdlibunreserved]
>       using allocator_traits = std::allocator_traits<_Alloc>;
>       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/tuple:2331:30: warning: TemplateTemplateParm uses unreserved identifier 'TQual' [stdlibunreserved]
>            template<typename> class TQual, template<typename> class UQual>
>            ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/tuple:2331:62: warning: TemplateTemplateParm uses unreserved identifier 'UQual' [stdlibunreserved]
>            template<typename> class TQual, template<typename> class UQual>
>                                            ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
> /usr/include/pthread.h:412:30: warning: ParmVar uses unreserved identifier 'sigmask' [stdlibunreserved]
>                                        const __sigset_t *sigmask);
>                                        ~~~~~~~~~~~~~~~~~~^~~~~~~
> /usr/include/pthread.h:418:24: warning: ParmVar uses unreserved identifier 'sigmask' [stdlibunreserved]
>                                        __sigset_t *sigmask);
>                                        ~~~~~~~~~~~~^~~~~~~
> /usr/include/semaphore.h:82:16: warning: ParmVar uses unreserved identifier 'clock' [stdlibunreserved]
>                           clockid_t clock,
>                           ~~~~~~~~~~^~~~~
> Suppressed 12 warnings (12 with check filters).


[-- Attachment #2: input.cc --]
[-- Type: text/x-c++src, Size: 3109 bytes --]

#include <algorithm>
#include <any>
#include <array>
#include <assert.h>
#include <atomic>
#include <barrier>
#include <bit>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfenv>
#include <cfloat>
#include <charconv>
#include <chrono>
#include <cinttypes>
#include <climits>
#include <clocale>
#include <cmath>
#include <codecvt>
#include <compare>
#include <complex>
#include <complex.h>
#include <concepts>
#include <condition_variable>
#include <coroutine>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ctype.h>
#include <cuchar>
#include <cwchar>
#include <cwctype>
#include <deque>
#include <errno.h>
#include <exception>
#include <execution>
#include <expected>
#include <filesystem>
#include <fenv.h>
#if __has_include(<flat_map>) // missing from recent libstdc++ 13 trunk
#include <flat_map>
#endif
#if __has_include(<flat_set>) // missing from recent libstdc++ 13 trunk
#include <flat_set>
#endif
#include <float.h>
#include <format>
#include <forward_list>
#include <fstream>
#include <functional>
#include <future>
#if __has_include(<generator>) // missing from recent libstdc++ 13 trunk
#include <generator>
#endif
#include <initializer_list>
#include <inttypes.h>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <iso646.h>
#include <istream>
#include <iterator>
#include <latch>
#include <limits>
#include <limits.h>
#include <list>
#include <locale>
#include <locale.h>
#include <map>
#include <math.h>
#if __has_include(<mdspan>) // missing from recent libstdc++ 13 trunk
#include <mdspan>
#endif
#include <memory>
#include <memory_resource>
#include <mutex>
#include <new>
#include <numbers>
#include <numeric>
#include <optional>
#include <ostream>
#if __has_include(<print>) // missing from recent libstdc++ 13 trunk
#include <print>
#endif
#include <queue>
#include <random>
#if !defined __clang__
    // error: requires clause differs in template redeclaration
#include <ranges>
#endif
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <semaphore>
#include <set>
#include <setjmp.h>
#include <shared_mutex>
#include <signal.h>
#include <source_location>
#include <span>
#include <spanstream>
#include <sstream>
#include <stack>
#include <stacktrace>
#include <stdalign.h>
#include <stdarg.h>
#include <stdatomic.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdexcept>
#include <stdfloat>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <stop_token>
#include <streambuf>
#include <string>
#include <string.h>
#include <string_view>
#include <strstream>
#include <syncstream>
#include <system_error>
#include <tgmath.h>
#include <thread>
#include <time.h>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <typeinfo>
#include <uchar.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <variant>
#include <vector>
#include <version>
#include <wchar.h>
#include <wctype.h>

[-- Attachment #3: Makefile --]
[-- Type: text/plain, Size: 624 bytes --]

GCC_INSTALL_DIR=/home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1
LLVM_BIN_DIR=/home/sbergman/llvm/inst/bin

.PHONY: check
check: input.cc stdlibunreserved.so
	$(LLVM_BIN_DIR)/clang-tidy --load=./stdlibunreserved.so \
            --checks='-*,stdlibunreserved' --header-filter='.*' \
            --system-headers --extra-arg=--gcc-install-dir=$(GCC_INSTALL_DIR) \
            --extra-arg=-std=c++2b --extra-arg=-D_GLIBCXX_DEBUG input.cc --

stdlibunreserved.so: stdlibunreserved.cc
	g++ -fPIC $$($(LLVM_BIN_DIR)/llvm-config --cxxflags) $< -shared \
            $$($(LLVM_BIN_DIR)/llvm-config --ldflags) -o $@

[-- Attachment #4: stdlibunreserved.cc --]
[-- Type: text/x-c++src, Size: 5785 bytes --]

// clang-tidy checker reporting uses of unreserved identifiers in a standard
// library implementation (and which should better use reserved identifiers to
// avoid potential conflicts with user-defined macros).  It uses heuristics to
// decide whether uses of unreserved identifiers are actually private to the
// implementation (rather than declarations of standard entities like
// std::vector), so may produce false negatives.

#include <algorithm>

#include "clang-tidy/ClangTidyCheck.h"
#include "clang-tidy/ClangTidyDiagnosticConsumer.h"
#include "clang-tidy/ClangTidyModule.h"
#include "clang-tidy/ClangTidyModuleRegistry.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Basic/Specifiers.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"

namespace {

bool hasCxxReservedIdentifier(clang::NamedDecl const * decl) {
    auto const id = decl->getIdentifier();
    if (id == nullptr) {
        return false;
    }
    auto const name = id->getName();
    if (name.find("__") != llvm::StringRef::npos) {
        return true;
    }
    if (!name.starts_with("_")) {
        return false;
    }
    if (name.size() >= 2 && (name[1] >= 'A' && name[1] <= 'Z'))
        //TODO: any XID_Continue uppercase letter?
    {
        return true;
    }
    return decl->getDeclContext()->isTranslationUnit();
}

class Check: public clang::tidy::ClangTidyCheck {
public:
    Check(llvm::StringRef name, clang::tidy::ClangTidyContext * context):
        ClangTidyCheck(name, context) {}

    void registerMatchers(clang::ast_matchers::MatchFinder * Finder) override {
        Finder->addMatcher(clang::ast_matchers::namedDecl().bind("x"), this);
    }

    void check(clang::ast_matchers::MatchFinder::MatchResult const & Result)
        override
    {
        auto const decl = Result.Nodes.getNodeAs<clang::NamedDecl>("x");
        if (decl->getLocation().isInvalid()) {
            return;
        }
        if (decl->getIdentifier() == nullptr) {
            return;
        }
        if (hasCxxReservedIdentifier(decl)) {
            return;
        }
        // Use some heuristics to decide whether certain declarations could
        // legitimately use unreserved identifiers because they are part the
        // standard:
        switch (decl->getKind()) {
        case clang::Decl::CXXMethod:
        case clang::Decl::CXXRecord:
        case clang::Decl::Concept:
        case clang::Decl::Enum:
        case clang::Decl::EnumConstant:
        case clang::Decl::Field:
        case clang::Decl::Function:
        case clang::Decl::IndirectField:
        case clang::Decl::TypeAlias:
        case clang::Decl::Typedef:
        case clang::Decl::Var:
            // The heuristic is that any definition that is not a private class
            // member could be part of the standard:
            if (decl->getAccess() != clang::AS_private) {
                return;
            }
            break;
        case clang::Decl::Namespace:
            // The heuristic is that any namespace nested in one of the
            // standard's reserved std* and posix namespaces could be part of
            // the standard:
            for (auto ns = llvm::cast<clang::NamespaceDecl>(decl);;)
            {
                auto const parent = ns->getParent()->getRedeclContext();
                if (parent->isTranslationUnit()) {
                    if (auto const id = ns->getIdentifier()) {
                        auto const name = id->getName();
                        if (name.starts_with("std")) {
                            if (std::all_of(
                                    name.begin() + 3, name.end(),
                                    [](auto c) { return llvm::isDigit(c); }))
                            {
                                return;
                            }
                        } else if (name == "posix") {
                            return;
                        }
                    }
                    break;
                }
                ns = llvm::cast<clang::NamespaceDecl>(parent);
            }
            break;
        case clang::Decl::ClassTemplatePartialSpecialization:
        case clang::Decl::ClassTemplateSpecialization:
        case clang::Decl::ConstructorUsingShadow:
        case clang::Decl::Using:
        case clang::Decl::UsingPack:
        case clang::Decl::UsingShadow:
        case clang::Decl::UnresolvedUsingTypename:
        case clang::Decl::UnresolvedUsingValue:
        case clang::Decl::VarTemplatePartialSpecialization:
        case clang::Decl::VarTemplateSpecialization:
            // These are reuses of identifiers already defined elsewhere:
            return;
        case clang::Decl::ClassTemplate:
        case clang::Decl::FunctionTemplate:
        case clang::Decl::TypeAliasTemplate:
        case clang::Decl::VarTemplate:
            // These Template nodes always wrap non-template declaration nodes,
            // so avoid duplicate warnings:
            return;
        }
        diag(decl->getLocation(), "%0 uses unreserved identifier '%1'")
            << decl->getDeclKindName() << decl->getName()
            << decl->getSourceRange();
    }
};

class Module: public clang::tidy::ClangTidyModule {
public:
    void addCheckFactories(
        clang::tidy::ClangTidyCheckFactories & CheckFactories) override
    {
        CheckFactories.registerCheck<Check>("stdlibunreserved");
    }
};

static clang::tidy::ClangTidyModuleRegistry::Add<Module> registry(
    "stdlibunreserved",
    "report uses of unreserved identifiers in a standard library"
        " implementation");

}

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Add clang-format for libstdc++
  2023-02-10 22:05   ` Stephan Bergmann
@ 2023-02-10 23:02     ` Jonathan Wakely
  2023-02-13 10:18       ` Stephan Bergmann
  0 siblings, 1 reply; 9+ messages in thread
From: Jonathan Wakely @ 2023-02-10 23:02 UTC (permalink / raw)
  To: Stephan Bergmann; +Cc: libstdc++

On Fri, 10 Feb 2023 at 22:05, Stephan Bergmann via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> On 2/7/23 22:01, Thomas Rodgers via Libstdc++ wrote:
> > Is it possible to get clang-format to enforce the libstdc++ uglification
> > rules (probably requires a clang-format plugin though)?
>
> I'm not sure clang-format can do that, but it wouldn't be too hard to
> come up with a clang-tidy checker to report missing uglification.
>
> With the attached Makefile, input.cc, and stdlibunreserved.cc, which
> should work at least against a recent LLVM 17 trunk, and run against a
> recent libstdc++ 13 trunk,
>
> > $ make
> > g++ -fPIC $(/home/sbergman/llvm/inst/bin/llvm-config --cxxflags) stdlibunreserved.cc -shared \
> >             $(/home/sbergman/llvm/inst/bin/llvm-config --ldflags) -o stdlibunreserved.so
> > /home/sbergman/llvm/inst/bin/clang-tidy --load=./stdlibunreserved.so \
> >             --checks='-*,stdlibunreserved' --header-filter='.*' \
> >             --system-headers --extra-arg=--gcc-install-dir=/home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1 \
> >             --extra-arg=-std=c++2b --extra-arg=-D_GLIBCXX_DEBUG input.cc --
> > 139 warnings generated.
> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/cxxabi_init_exception.h:70:42: warning: ParmVar uses unreserved identifier 'object' [stdlibunreserved]
> >       __cxa_init_primary_exception(void *object, std::type_info *tinfo,
> >                                    ~~~~~~^~~~~~
> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/cxxabi_init_exception.h:70:66: warning: ParmVar uses unreserved identifier 'tinfo' [stdlibunreserved]
> >       __cxa_init_primary_exception(void *object, std::type_info *tinfo,
> >                                                  ~~~~~~~~~~~~~~~~^~~~~
> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/cxxabi_init_exception.h:71:47: warning: ParmVar uses unreserved identifier 'dest' [stdlibunreserved]
> >                 void (_GLIBCXX_CDTOR_CALLABI *dest) (void *)) _GLIBCXX_NOTHROW;
> >                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/fs_ops.h:93:54: warning: ParmVar uses unreserved identifier 'attributes' [stdlibunreserved]
> >   bool create_directory(const path& __p, const path& attributes);
> >                                          ~~~~~~~~~~~~^~~~~~~~~~
> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/fs_ops.h:94:54: warning: ParmVar uses unreserved identifier 'attributes' [stdlibunreserved]
> >   bool create_directory(const path& __p, const path& attributes,
> >                                          ~~~~~~~~~~~~^~~~~~~~~~

Those are all bugs.

> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/fs_path.h:523:41: warning: ParmVar uses unreserved identifier 'base' [stdlibunreserved]
> >     path lexically_relative(const path& base) const;
> >                             ~~~~~~~~~~~~^~~~
> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/fs_path.h:524:42: warning: ParmVar uses unreserved identifier 'base' [stdlibunreserved]
> >     path lexically_proximate(const path& base) const;
> >                              ~~~~~~~~~~~~^~~~

'base' is reserved since C++98, due to std::reverse_iterator::base().

From a quick glance at the code, I don't see where it figures out
which non-reserved names (i.e. not _[A-Z_]*) are actually reserved and
which to warn about.


> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/iterator_concepts.h:968:21: warning: TemplateTypeParm uses unreserved identifier 'auto:1' [stdlibunreserved]
> >     void begin(auto&) = delete;
> >                ~~~~~^
> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/iterator_concepts.h:969:27: warning: TemplateTypeParm uses unreserved identifier 'auto:1' [stdlibunreserved]
> >     void begin(const auto&) = delete;
> >                      ~~~~~^

That's a keyword :-)

> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/memory_resource.h:85:5: warning: CXXMethod uses unreserved identifier 'do_allocate' [stdlibunreserved]
> >     do_allocate(size_t __bytes, size_t __alignment) = 0;
> > ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/memory_resource.h:88:5: warning: CXXMethod uses unreserved identifier 'do_deallocate' [stdlibunreserved]
> >     do_deallocate(void* __p, size_t __bytes, size_t __alignment) = 0;
> > ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/memory_resource.h:91:5: warning: CXXMethod uses unreserved identifier 'do_is_equal' [stdlibunreserved]
> >     do_is_equal(const memory_resource& __other) const noexcept = 0;
> > ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Those are standard APIs, so reserved.

> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_algo.h:3493:16: warning: TemplateTypeParm uses unreserved identifier 'Proj1' [stdlibunreserved]
> >              typename Proj1 = identity, typename Proj2 = identity>
> >              ~~~~~~~~~^~~~~~~~~~~~~~~~
> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_algo.h:3493:43: warning: TemplateTypeParm uses unreserved identifier 'Proj2' [stdlibunreserved]
> >              typename Proj1 = identity, typename Proj2 = identity>
> >                                         ~~~~~~~~~^~~~~~~~~~~~~~~~

Those are bugs.

> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_algo.h:3571:74: warning: TemplateTypeParm uses unreserved identifier 'T' [stdlibunreserved]
> >     template<forward_iterator _Iter, sentinel_for<_Iter> _Sent, typename T, typename _Proj = identity>
> >                                                                 ~~~~~~~~~^
> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/ranges_algo.h:3602:45: warning: TemplateTypeParm uses unreserved identifier 'T' [stdlibunreserved]
> >     template<forward_range _Range, typename T, typename _Proj = identity>
> >                                    ~~~~~~~~~^

I fixed those on Monday.


> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/regex.h:1762:52: warning: Typedef uses unreserved identifier 'match_flag_type' [stdlibunreserved]
> >       typedef regex_constants::match_flag_type             match_flag_type;
> >       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~

That's a standard type.

> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/regex_automaton.h:113:28: warning: ParmVar uses unreserved identifier 'ostr' [stdlibunreserved]
> >     _M_print(std::ostream& ostr) const;
> >              ~~~~~~~~~~~~~~^~~~
> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/regex_automaton.tcc:39:39: warning: ParmVar uses unreserved identifier 'ostr' [stdlibunreserved]
> >   _State_base::_M_print(std::ostream& ostr) const
> >                         ~~~~~~~~~~~~~~^~~~

Bugs

> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/regex_error.h:139:11: warning: TypeAlias uses unreserved identifier 'error_type' [stdlibunreserved]
> >     using error_type = regex_constants::error_type;
> >     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/regex_scanner.tcc:487:28: warning: ParmVar uses unreserved identifier 'ostr' [stdlibunreserved]
> >     _M_print(std::ostream& ostr)
> >              ~~~~~~~~~~~~~~^~~~
> > /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/shared_ptr_atomic.h:377:13: warning: TypeAlias uses unreserved identifier 'value_type' [stdlibunreserved]
> >       using value_type = _Tp;
> >       ~~~~~~^~~~~~~~~~~~~~~~

Erm ... :-)

There are a lot of false positives here, but it's already found a lot
of real bugs, thanks!


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Add clang-format for libstdc++
  2023-02-10 23:02     ` Jonathan Wakely
@ 2023-02-13 10:18       ` Stephan Bergmann
  0 siblings, 0 replies; 9+ messages in thread
From: Stephan Bergmann @ 2023-02-13 10:18 UTC (permalink / raw)
  To: libstdc++; +Cc: Jonathan Wakely

On 11/02/2023 00:02, Jonathan Wakely wrote:
> On Fri, 10 Feb 2023 at 22:05, Stephan Bergmann via Libstdc++
>>> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/fs_path.h:523:41: warning: ParmVar uses unreserved identifier 'base' [stdlibunreserved]
>>>      path lexically_relative(const path& base) const;
>>>                              ~~~~~~~~~~~~^~~~
>>> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/fs_path.h:524:42: warning: ParmVar uses unreserved identifier 'base' [stdlibunreserved]
>>>      path lexically_proximate(const path& base) const;
>>>                               ~~~~~~~~~~~~^~~~
> 
> 'base' is reserved since C++98, due to std::reverse_iterator::base().
> 
>  From a quick glance at the code, I don't see where it figures out
> which non-reserved names (i.e. not _[A-Z_]*) are actually reserved and
> which to warn about.

It doesn't do that at all for now.  (But we could of course add an 
exclude list to filter out known false positives.  Short of adding all 
identifiers used by the standard library to such an exclude list.)  So 
it currently warns about all function parameters that are using 
unreserved identifiers, even if those identifiers happen to be safe, 
like in this case.  For some other kinds of declarations, it uses the 
heuristic of only warning if the declaration is a private class member 
(and all others are assumed to be part of the standard); that's why 
things like a private member function do_allocate, a private typedef 
match_flag_type, or a private alias value_type showed up.

>>> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/iterator_concepts.h:968:21: warning: TemplateTypeParm uses unreserved identifier 'auto:1' [stdlibunreserved]
>>>      void begin(auto&) = delete;
>>>                 ~~~~~^
>>> /home/sbergman/gcc/trunk/inst/lib/gcc/x86_64-pc-linux-gnu/13.0.1/../../../../include/c++/13.0.1/bits/iterator_concepts.h:969:27: warning: TemplateTypeParm uses unreserved identifier 'auto:1' [stdlibunreserved]
>>>      void begin(const auto&) = delete;
>>>                       ~~~~~^
> 
> That's a keyword :-)

almost (note the trailing ":1"); I'd failed to filter out implicit Decls

> There are a lot of false positives here, but it's already found a lot
> of real bugs, thanks!

If there's interest, maybe we could put this into some auxiliary tool 
directory in the GCC git repo, to be manually run on demand?


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2023-02-13 10:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-07 20:38 Add clang-format for libstdc++ Dimitrij Mijoski
2023-02-07 21:01 ` Thomas Rodgers
2023-02-07 21:19   ` Jonathan Wakely
2023-02-07 21:24     ` Thomas Rodgers
2023-02-10 22:05   ` Stephan Bergmann
2023-02-10 23:02     ` Jonathan Wakely
2023-02-13 10:18       ` Stephan Bergmann
2023-02-07 21:17 ` Jonathan Wakely
2023-02-08 20:04   ` Björn Schäpers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).