[libc-commits] [libc] [libc] Add LIBC_NAMESPACE_HIDDEN_DECL macro (PR #97109)

Roland McGrath via libc-commits libc-commits at lists.llvm.org
Wed Jul 3 15:07:08 PDT 2024


================
@@ -27,4 +27,8 @@
 #define LIBC_HAS_FEATURE(f) 0
 #endif
 
+// Declare a LIBC_NAMESPACE with hidden visibility. This can be used on a
+// case-by-case basis where sets of symbols within this declaration are hidden.
+#define LIBC_NAMESPACE_HIDDEN_DECL [[gnu::visibility("hidden")]] LIBC_NAMESPACE
----------------
frobtech wrote:

Let's just call it `LIBC_NAMESPACE_DECL`.  There is no case-by-case.

We also need some updates to various docs/ files to clearly explain that `namespace LIBC_NAMESPACE_DECL {` and only that formulation must be used around all declarations and definitions.  We then need to update the existing clang-tidy checks to require and enforce that.

I think the natural order of operations is:
 1. Define new macro and update docs to say how to use it correctly.  That can land without other blockers.
 2. Update clang-tidy checks to enforce the new standard, making sure they have full fixit implementation.  That shouldn't land quite yet because then the libc linter bot will start complaining anew.
 3. Use clang-tidy to apply fixups to all libc code so it now conforms.  No manual edits should be needed, but manual audit is needed to be sure it caught everything and the fixit edits were correct.
 4. Land 2. & 3. either in quick succession or as one commit, not sure how much it matters if everybody who would look at the libc linter bot knows what's being done.


https://github.com/llvm/llvm-project/pull/97109


More information about the libc-commits mailing list