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

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 24 07:24:33 PST 2025


================
@@ -0,0 +1,416 @@
+#!/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
+#
+# ===-----------------------------------------------------------------------===#
+
+"""
+
+Clang-Tidy Alphabetical Order Checker
+=====================================
+
+Normalize Clang-Tidy documentation with deterministic sorting for linting/tests.
+
+Behavior:
+- Sort entries in docs/clang-tidy/checks/list.rst csv-table.
+- Sort key sections in docs/ReleaseNotes.rst.
+- Detect duplicated entries in 'Changes in existing checks'.
+
+Flags:
+  -o/--output  Write normalized content to this path instead of updating docs.
+"""
+
+import argparse
+from collections import defaultdict
+import io
+from operator import itemgetter
+import os
+import re
+import sys
+from typing import (
+    List,
+    Optional,
+    Sequence,
+    Tuple,
+    NamedTuple,
+    DefaultDict,
+    Final,
+    Pattern,
+)
+
+# Matches a :doc:`label <path>` or :doc:`label` reference anywhere in text and
+# captures the label. Used to sort bullet items alphabetically in ReleaseNotes
+# items by their label.
+DOC_LABEL_RN_RE: Final[Pattern[str]] = re.compile(
----------------
EugeneZelenko wrote:

You don't need to specify types for `Final`, because they are inferred from expression.

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


More information about the cfe-commits mailing list