[clang-tools-extra] [llvm] [clang-tidy] New check `misc-header-guard` (PR #177315)
Thorsten Klein via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 5 09:04:45 PST 2026
================
@@ -134,6 +134,11 @@ New checks
Checks for presence or absence of trailing commas in enum definitions and
initializer lists.
+- New :doc:`misc-header-guard <clang-tidy/checks/misc/header-guard>` check.
----------------
thorsten-klein wrote:
The check fails if I place it at your suggested place:
```
+ llvm-lit infrastructure/alphabetical-order.test --verbose
-- Testing: 1 tests, 1 workers --
FAIL: Clang Tools :: clang-tidy/infrastructure/alphabetical-order.test (1 of 1)
******************** TEST 'Clang Tools :: clang-tidy/infrastructure/alphabetical-order.test' FAILED ********************
Exit Code: 1
Command Output (stdout):
--
# RUN: at line 1
/home/user/.local/bin/python3.12 /home/user/work/GIT/llvm-project/clang-tools-extra/test/clang-tidy/infrastructure/../../../clang-tidy/tool/check_alphabetical_order.py -o /home/user/work/GIT/llvm-project/build-ninja/tools/clang/tools/extra/test/clang-tidy/infrastructure/Output/alphabetical-order.test.tmp.clang-tidy-checks-list.rst
# executed command: /home/user/.local/bin/python3.12 /home/user/work/GIT/llvm-project/clang-tools-extra/test/clang-tidy/infrastructure/../../../clang-tidy/tool/check_alphabetical_order.py -o /home/user/work/GIT/llvm-project/build-ninja/tools/clang/tools/extra/test/clang-tidy/infrastructure/Output/alphabetical-order.test.tmp.clang-tidy-checks-list.rst
# RUN: at line 2
diff --strip-trailing-cr /home/user/work/GIT/llvm-project/clang-tools-extra/test/clang-tidy/infrastructure/../../../docs/clang-tidy/checks/list.rst /home/user/work/GIT/llvm-project/build-ninja/tools/clang/tools/extra/test/clang-tidy/infrastructure/Output/alphabetical-order.test.tmp.clang-tidy-checks-list.rst
# executed command: diff --strip-trailing-cr /home/user/work/GIT/llvm-project/clang-tools-extra/test/clang-tidy/infrastructure/../../../docs/clang-tidy/checks/list.rst /home/user/work/GIT/llvm-project/build-ninja/tools/clang/tools/extra/test/clang-tidy/infrastructure/Output/alphabetical-order.test.tmp.clang-tidy-checks-list.rst
# RUN: at line 4
/home/user/.local/bin/python3.12 /home/user/work/GIT/llvm-project/clang-tools-extra/test/clang-tidy/infrastructure/../../../clang-tidy/tool/check_alphabetical_order.py -o /home/user/work/GIT/llvm-project/build-ninja/tools/clang/tools/extra/test/clang-tidy/infrastructure/Output/alphabetical-order.test.tmp.ReleaseNotes.rst
# executed command: /home/user/.local/bin/python3.12 /home/user/work/GIT/llvm-project/clang-tools-extra/test/clang-tidy/infrastructure/../../../clang-tidy/tool/check_alphabetical_order.py -o /home/user/work/GIT/llvm-project/build-ninja/tools/clang/tools/extra/test/clang-tidy/infrastructure/Output/alphabetical-order.test.tmp.ReleaseNotes.rst
# .---command stderr------------
# |
# | Entries in 'clang-tools-extra/docs/ReleaseNotes.rst' are not alphabetically sorted.
# | Fix the ordering by applying diff printed below.
# |
# `-----------------------------
# RUN: at line 5
diff --strip-trailing-cr /home/user/work/GIT/llvm-project/clang-tools-extra/test/clang-tidy/infrastructure/../../../docs/ReleaseNotes.rst /home/user/work/GIT/llvm-project/build-ninja/tools/clang/tools/extra/test/clang-tidy/infrastructure/Output/alphabetical-order.test.tmp.ReleaseNotes.rst
# executed command: diff --strip-trailing-cr /home/user/work/GIT/llvm-project/clang-tools-extra/test/clang-tidy/infrastructure/../../../docs/ReleaseNotes.rst /home/user/work/GIT/llvm-project/build-ninja/tools/clang/tools/extra/test/clang-tidy/infrastructure/Output/alphabetical-order.test.tmp.ReleaseNotes.rst
# .---command stdout------------
# | *** /home/user/work/GIT/llvm-project/clang-tools-extra/test/clang-tidy/infrastructure/../../../docs/ReleaseNotes.rst
# | --- /home/user/work/GIT/llvm-project/build-ninja/tools/clang/tools/extra/test/clang-tidy/infrastructure/Output/alphabetical-order.test.tmp.ReleaseNotes.rst
# | ***************
# | *** 110,120 ****
# | ``llvm::to_vector(llvm::make_filter_range(...))`` that can be replaced with
# | ``llvm::map_to_vector`` and ``llvm::filter_to_vector``.
# |
# | - - New :doc:`misc-header-guard <clang-tidy/checks/misc/header-guard>` check.
# | -
# | - Finds and fixes header guards that do not conform to the configured style
# | - options from this check.
# | -
# | - New :doc:`modernize-use-string-view
# | <clang-tidy/checks/modernize/use-string-view>` check.
# |
# | --- 110,115 ----
# | ***************
# | *** 140,145 ****
# | --- 135,145 ----
# | initializer lists.
# |
# |
# | + - New :doc:`misc-header-guard <clang-tidy/checks/misc/header-guard>` check.
# | +
# | + Finds and fixes header guards that do not conform to the configured style
# | + options from this check.
# | +
# | New check aliases
# | ^^^^^^^^^^^^^^^^^
# |
# `-----------------------------
# error: command failed with exit status: 1
--
********************
********************
Failed Tests (1):
Clang Tools :: clang-tidy/infrastructure/alphabetical-order.test
```
https://github.com/llvm/llvm-project/pull/177315
More information about the cfe-commits
mailing list