[all-commits] [llvm/llvm-project] 2f4a80: [clang-tidy] Add new check `llvm-prefer-static-ove...

Baranov Victor via All-commits all-commits at lists.llvm.org
Fri Jul 11 23:56:51 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2f4a804e6eb597e792cf069726c6190127c478fb
      https://github.com/llvm/llvm-project/commit/2f4a804e6eb597e792cf069726c6190127c478fb
  Author: Baranov Victor <bar.victor.2002 at gmail.com>
  Date:   2025-07-12 (Sat, 12 Jul 2025)

  Changed paths:
    M clang-tools-extra/clang-tidy/llvm/CMakeLists.txt
    M clang-tools-extra/clang-tidy/llvm/LLVMTidyModule.cpp
    A clang-tools-extra/clang-tidy/llvm/PreferStaticOverAnonymousNamespaceCheck.cpp
    A clang-tools-extra/clang-tidy/llvm/PreferStaticOverAnonymousNamespaceCheck.h
    M clang-tools-extra/docs/ReleaseNotes.rst
    M clang-tools-extra/docs/clang-tidy/checks/list.rst
    A clang-tools-extra/docs/clang-tidy/checks/llvm/prefer-static-over-anonymous-namespace.rst
    A clang-tools-extra/test/clang-tidy/checkers/llvm/prefer-static-over-anonymous-namespace.cpp

  Log Message:
  -----------
  [clang-tidy] Add new check `llvm-prefer-static-over-anonymous-namespace` (#142839)

Finds function and variable declarations inside anonymous namespace and
suggests replacing them with ``static`` declarations.

The check will enforce that
[restrict-visibility](https://llvm.org/docs/CodingStandards.html#restrict-visibility)
rule in LLVM Coding Standards is followed correctly (by adding `static`
to functions instead of putting them in anonimous namespace).

The check has additional levels of "strictness" represented by Options.
By default, the check works in the most relaxed way by giving warning
only for methods and functions defined in anonymous namespaces. Also, It
finds `static` functions that are placed inside anonymous namespace -
there is no point in keeping them inside.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list