1
0
mirror of https://gitlab.gnome.org/GNOME/glib.git synced 2026-10-24 00:49:00 +03:00
Files
glib/gobject
Philip Chimento 0213ee7354 Avoid reserved identifiers in public macros
Clang-tidy has a check to prohibit identifiers that are reserved for the
compiler. Those are identifiers that start with:
  - an underscore plus an uppercase letter
  - two underscores
  - an underscore, and are in the global scope
https://clang.llvm.org/extra/clang-tidy/checks/bugprone/reserved-identifier.html

Many public GLib macros define variables starting with two underscores,
which is technically not allowed. This is probably usually harmless, but
it causes false positives in the abovementioned clang-tidy check when
consumers of GLib use macros like G_VALUE_HOLDS_POINTER or
g_str_has_suffix.

This commit replaces all such names with one-underscore names, which are
not reserved because they're not in the global scope.

Here's the incantation I used to discover which macros needed editing:

git grep -P '\b__(?!builtin|atomic|sync|asm|volatile|pragma)[a-z].*\\$' \
  -- '*.h' | grep -v valgrind.h

This generates a manageable number of false positives. It also fails to
find identifiers on the last line of a macro, but those are generally
already mentioned elsewhere in the macro.

I left valgrind.h untouched.
2026-07-26 14:12:11 -07:00
..
2026-06-25 17:23:46 +01:00
2026-06-25 17:23:46 +01:00
2026-06-25 17:23:46 +01:00
2023-10-16 23:35:05 +01:00
2026-06-25 17:23:46 +01:00
2022-10-13 20:53:56 -04:00
2026-06-25 17:23:46 +01:00
2026-02-23 11:44:02 +00:00
2022-10-13 20:53:56 -04:00
2022-10-13 20:53:56 -04:00
2026-06-25 17:23:46 +01:00
2026-06-25 17:23:46 +01:00
2023-10-23 11:26:53 +01:00
2026-06-25 17:23:46 +01:00
2026-06-25 17:23:46 +01:00