[clang-tools-extra] [clang-tidy] Implement alphabetical order test (PR #166072)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 2 12:58:50 PST 2025


================
@@ -0,0 +1,298 @@
+#!/usr/bin/env python3
+#
+# ===-----------------------------------------------------------------------===#
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+# ===-----------------------------------------------------------------------===#
+
+"""
+
+ClangTidy Alphabetical Order Checker
+====================================
+
+Normalize clang-tidy docs with deterministic sorting for linting/tests.
+
+Subcommands:
+  - checks-list: Sort entries in docs/clang-tidy/checks/list.rst csv-table.
+  - release-notes: Sort key sections in docs/ReleaseNotes.rst and de-duplicate
+                   entries in "Changes in existing checks".
+
+Usage:
+  clang-tidy-alphabetical-order-check.py <subcommand> [-i <input rst>] [-o <output rst>] [--fix]
+
+Flags:
+  -i/--input   Input file.
+  -o/--output  Write normalized content here; omit to write to stdout.
+  --fix        Rewrite the input file in place. Cannot be combined with -o/--output.
----------------
vbvictor wrote:

I think we don't need any flags and subcommands expect `-o` flag (for testing reasons).
Let it always try to fix by default.
Since we know that we are in LLVM repo, just locate the needed files.
See how https://github.com/llvm/llvm-project/blob/main/clang/docs/tools/dump_format_style.py is implemented, our script structure should be similar to it. 

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


More information about the cfe-commits mailing list