[clang-tools-extra] [clang-tidy] Fix alphabetical order check for multiline doc entries (PR #186950)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 16 21:27:24 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tools-extra
Author: Zeyi Xu (zeyi2)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/186950.diff
2 Files Affected:
- (modified) clang-tools-extra/clang-tidy/tool/check_alphabetical_order.py (+2-2)
- (modified) clang-tools-extra/clang-tidy/tool/check_alphabetical_order_test.py (+43)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/tool/check_alphabetical_order.py b/clang-tools-extra/clang-tidy/tool/check_alphabetical_order.py
index 6a200e36b2715..992d644ce2ec3 100644
--- a/clang-tools-extra/clang-tidy/tool/check_alphabetical_order.py
+++ b/clang-tools-extra/clang-tidy/tool/check_alphabetical_order.py
@@ -202,7 +202,7 @@ def find_heading(lines: Sequence[str], title: str) -> Optional[int]:
def extract_label(text: str) -> str:
if m := DOC_LABEL_RN_RE.search(text):
- return m.group("label")
+ return m.group("label").strip()
return text
@@ -221,7 +221,7 @@ def _parse_bullet_blocks(lines: Sequence[str], start: int, end: int) -> BulletBl
blocks: List[BulletItem] = []
res = _scan_bullet_blocks(lines, first_bullet, n)
for _, block in res.blocks_with_pos:
- key: CheckLabel = extract_label(block[0])
+ key: CheckLabel = extract_label("".join(block))
blocks.append((key, block))
suffix: Lines = list(lines[res.next_index : n])
diff --git a/clang-tools-extra/clang-tidy/tool/check_alphabetical_order_test.py b/clang-tools-extra/clang-tidy/tool/check_alphabetical_order_test.py
index fa418e41ee8a8..1cb108016a707 100644
--- a/clang-tools-extra/clang-tidy/tool/check_alphabetical_order_test.py
+++ b/clang-tools-extra/clang-tidy/tool/check_alphabetical_order_test.py
@@ -358,6 +358,49 @@ def test_release_notes_handles_nested_sub_bullets(self) -> None:
)
self.assertEqual(out, expected_out)
+ def test_release_notes_handles_multiline_doc(self) -> None:
+ rn_text = textwrap.dedent(
+ """\
+ Changes in existing checks
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+ - Renamed :doc:`performance-faster-string-find
+ <clang-tidy/checks/performance/faster-string-find>` to
+ :doc:`performance-faster-string-operation
+ <clang-tidy/checks/performance/faster-string-operation>`.
+ The `performance-faster-string-find` name is kept as an alias.
+
+ - Renamed :doc:`hicpp-no-assembler <clang-tidy/checks/hicpp/no-assembler>`
+ to :doc:`portability-no-assembler
+ <clang-tidy/checks/portability/no-assembler>`. The `hicpp-no-assembler`
+ name is kept as an alias.
+
+ """
+ )
+
+ out = _mod.normalize_release_notes(rn_text.splitlines(True))
+
+ expected_out = textwrap.dedent(
+ """\
+ Changes in existing checks
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+ - Renamed :doc:`hicpp-no-assembler <clang-tidy/checks/hicpp/no-assembler>`
+ to :doc:`portability-no-assembler
+ <clang-tidy/checks/portability/no-assembler>`. The `hicpp-no-assembler`
+ name is kept as an alias.
+
+ - Renamed :doc:`performance-faster-string-find
+ <clang-tidy/checks/performance/faster-string-find>` to
+ :doc:`performance-faster-string-operation
+ <clang-tidy/checks/performance/faster-string-operation>`.
+ The `performance-faster-string-find` name is kept as an alias.
+
+
+ """
+ )
+ self.assertEqual(out, expected_out)
+
def test_process_checks_list_normalizes_output(self) -> None:
list_text = textwrap.dedent(
"""\
``````````
</details>
https://github.com/llvm/llvm-project/pull/186950
More information about the cfe-commits
mailing list