[clang-tools-extra] [clang-tidy] Add new check `llvm-prefer-static-over-anonymous-namespace` (PR #142839)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 20 08:24:04 PDT 2025


================
@@ -0,0 +1,73 @@
+.. title:: clang-tidy - llvm-prefer-static-over-anonymous-namespace
+
+llvm-prefer-static-over-anonymous-namespace
+===========================================
+
+Finds function and variable declarations inside anonymous namespace and
+suggests replacing them with ``static`` declarations.
+
+The `LLVM Coding Standards <https://llvm.org/docs/CodingStandards.html#restrict-visibility>`_
+recommend keeping anonymous namespaces as small as possible and only use them
+for class declarations. For functions and variables, ``static`` specifier
----------------
5chmidti wrote:

nit: `` and variables the ''static'' specifier...`  (couldn't do double `  )

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


More information about the cfe-commits mailing list