Add clang-format for libstdc++

Stephan Bergmann sbergman@redhat.com
Mon Feb 13 10:18:51 GMT 2023


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?



More information about the Libstdc++ mailing list