[clang-tools-extra] [clang-tidy] new check readability-mark-static (PR #90830)

Oliver Stöneberg via cfe-commits cfe-commits at lists.llvm.org
Thu May 2 03:10:15 PDT 2024


================
@@ -0,0 +1,26 @@
+.. title:: clang-tidy - readability-mark-static
+
+readability-mark-static
+=======================
+
+Detects variable and function can be marked as static.
+
+Static functions and variables are scoped to a single file. Marking functions
+and variables as static helps to better remove dead code. In addition, it gives
+the compiler more information and can help compiler make more aggressive
+optimizations.
+
----------------
firewave wrote:

AFAIK `static` doesn't prevent ODR violations (unfortunately I do not have specifics - it is just from experience). You need to use anonymous namespaces for that.
Also Clang has a bug where you might still encounter issues although the symbols should be internal (resulting in a crash) #75275.

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


More information about the cfe-commits mailing list