[RFC PATCH] testsuite, v3: Add C++ plugin to check for libstdc++ header uglification
Jonathan Wakely
jwakely@redhat.com
Wed Mar 18 10:53:50 GMT 2026
On Tue, 17 Mar 2026 at 20:39, Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> I found 2 bugs in the plugin.
> It wasn't walking class template members (that fixes e.g. the atomic_base.h
> stuff but shows other stuff) and it didn't ignore auto:NN names (I guess
> DECL_ARTIFICIAL check would leave those out maybe too but I was afraid of
> using it just in case something based on the source gets DECL_ARTIFICIAL
> flag).
>
> Interdiff from previous patch is:
> @@ -79,6 +79,9 @@
> + return;
> +
> + const char *cname = IDENTIFIER_POINTER (name);
> ++ if (memcmp (cname, "auto:", 5) == 0)
> ++ return;
> ++
> + if (cname[0] != '_'
> + || (cname[1] != '_'
> + && !ISUPPER (cname[1])
> @@ -183,6 +186,8 @@
> + if (DECL_FUNCTION_TEMPLATE_P (decl))
> + plugin_check_fn (DECL_TEMPLATE_RESULT (decl));
> +
> ++ if (DECL_CLASS_TEMPLATE_P (decl))
> ++ decl = DECL_TEMPLATE_RESULT (decl);
> + if (TREE_CODE (decl) == TYPE_DECL
> + && DECL_IMPLICIT_TYPEDEF_P (decl))
> + {
> With this what I get is (only mentioning the non-whitelisted stuff now).
>
> subs is IMHO a bug in the headers, /ext/ is up to Jonathan to decide what to
> do (comment out <bits/extc++.h>, blacklist those 2 headers, fix them).
I think we should not run this plugin on <bits/extc++.h>. It contains
extensions that use non-reserved names intentionally, which is OK
because those extensions (and the extc++.h header) aren't used by
conforming C++ programs.
Running the plugin on <bits/stdc++.h> covers all the parts of the
library that are supposed to be usable by conforming C++ programs,
including the pieces like __gnu_cxx::__alloc_traits which are in
ext/*.h headers but still used by standard headers.
>
> set_debug_format is in https://eel.is/c++draft/libraryindex and so
> are the <generator> ones, and max_load_factor is too, haven't figured out
> yet what's going on with those.
>
> submdspan_mapping is something weird, not in the index, but mentioned in
> https://eel.is/c++draft/mdspan.sub.map#sliceable-2 so probably needs to be
> whitelisted directly in the plugin for cxx_dialect >= cxx26.
That should get added to the index via
https://github.com/cplusplus/draft/issues/8792
>
> libstdc++-v3/include/bits/chrono_io.h:1885:47: note: non-uglified name 'subs'
Fixed by r16-8143-g62dec39dbd6724
> libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp:145:34: note: non-uglified name 'n'
> libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp:157:35: note: non-uglified name 'n'
> libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp:159:28: note: non-uglified name 'p_upper'
> libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp:170:36: note: non-uglified name 'n'
> libstdc++-v3/include/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp:172:22: note: non-uglified name 'p_lower'
> libstdc++-v3/include/ext/throw_allocator.h:116:22: note: non-uglified name 'l'
> libstdc++-v3/include/ext/throw_allocator.h:126:18: note: non-uglified name 'entry'
> libstdc++-v3/include/ext/throw_allocator.h:134:49: note: non-uglified name 'inserted'
> libstdc++-v3/include/ext/throw_allocator.h:159:12: note: non-uglified name 'inserted'
> libstdc++-v3/include/ext/throw_allocator.h:178:32: note: non-uglified name 'found'
> libstdc++-v3/include/ext/throw_allocator.h:201:18: note: non-uglified name 'label'
> libstdc++-v3/include/ext/throw_allocator.h:203:19: note: non-uglified name 'found'
> libstdc++-v3/include/ext/throw_allocator.h:240:19: note: non-uglified name 'found'
> libstdc++-v3/include/ext/throw_allocator.h:275:12: note: non-uglified name 'found'
> libstdc++-v3/include/ext/throw_allocator.h:288:30: note: non-uglified name 'label'
> libstdc++-v3/include/ext/throw_allocator.h:292:19: note: non-uglified name 'found'
> libstdc++-v3/include/ext/throw_allocator.h:318:32: note: non-uglified name 's'
> libstdc++-v3/include/ext/throw_allocator.h:324:12: note: non-uglified name 'buf'
> libstdc++-v3/include/ext/throw_allocator.h:325:18: note: non-uglified name 'tab'
> libstdc++-v3/include/ext/throw_allocator.h:327:21: note: non-uglified name 'l'
> libstdc++-v3/include/ext/throw_allocator.h:350:12: note: non-uglified name 'buf'
> libstdc++-v3/include/ext/throw_allocator.h:351:18: note: non-uglified name 'tab'
> libstdc++-v3/include/ext/throw_allocator.h:353:21: note: non-uglified name 'l'
> libstdc++-v3/include/ext/throw_allocator.h:389:28: note: non-uglified name 'os'
> libstdc++-v3/include/ext/throw_allocator.h:392:27: note: non-uglified name 'base_type'
> libstdc++-v3/include/ext/throw_allocator.h:574:31: note: non-uglified name 'distribution'
> libstdc++-v3/include/ext/throw_allocator.h:575:19: note: non-uglified name 'generator'
> libstdc++-v3/include/ext/throw_allocator.h:578:75: note: non-uglified name 'gen_t'
> libstdc++-v3/include/ext/throw_allocator.h:580:20: note: non-uglified name 'generator'
> libstdc++-v3/include/ext/throw_allocator.h:587:14: note: non-uglified name 'random'
> libstdc++-v3/include/ext/throw_allocator.h:593:16: note: non-uglified name 'buf'
All the ext/pb_ds/* and ext/throw_allocator.h ones will go away with extc++.h
> libstdc++-v3/include/format:1477:7: note: non-uglified name 'set_debug_format'
> libstdc++-v3/include/format:5783:7: note: non-uglified name 'set_debug_format'
> libstdc++-v3/include/format:5913:11: note: non-uglified name 'set_debug_format'
> libstdc++-v3/include/generator:130:9: note: non-uglified name 'initial_suspend'
> libstdc++-v3/include/generator:134:9: note: non-uglified name 'yield_value'
> libstdc++-v3/include/generator:141:9: note: non-uglified name 'yield_value'
> libstdc++-v3/include/generator:152:9: note: non-uglified name 'yield_value'
> libstdc++-v3/include/generator:162:9: note: non-uglified name 'yield_value'
> libstdc++-v3/include/generator:169:9: note: non-uglified name 'yield_value'
> libstdc++-v3/include/generator:186:9: note: non-uglified name 'final_suspend'
> libstdc++-v3/include/generator:190:9: note: non-uglified name 'unhandled_exception'
> libstdc++-v3/include/generator:203:14: note: non-uglified name 'await_transform'
> libstdc++-v3/include/generator:204:14: note: non-uglified name 'return_void'
> libstdc++-v3/include/mdspan:3385:10: note: non-uglified name 'submdspan_mapping'
> libstdc++-v3/include/tr1/hashtable_policy.h:387:5: note: non-uglified name 'max_load_factor'
That's not a reserved name in C++98, but is specified by TR1 instead.
But if you stop testing extc++.h then that header won't be checked
anyway.
More information about the Libstdc++
mailing list