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

via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 2 08:28:38 PST 2025


zeyi2 wrote:

Currently, the deduplication process has issues. For example:

```
Changes in existing checks
^^^^^^^^^^^^^^^^^^^^^^^^^^

- Improved :doc:`bugprone-easily-swappable-parameters
  <clang-tidy/checks/bugprone/easily-swappable-parameters>` check by
  correcting a spelling mistake on its option
  ``NamePrefixSuffixSilenceDissimilarityTreshold``.

- Improved :doc:`bugprone-easily-swappable-parameters
  <clang-tidy/checks/bugprone/easily-swappable-parameters>` check
  this is just an example test.
```

the check will hint:
```
# executed command: diff --strip-trailing-cr - /home/mitchell/Documents/projects/llvm-project/clang-tools-extra/test/clang-tidy/infrastructure/../../../docs/ReleaseNotes.rst
# .---command stdout------------
# | *** -
# | --- /home/mitchell/Documents/projects/llvm-project/clang-tools-extra/test/clang-tidy/infrastructure/../../../docs/ReleaseNotes.rst
# | ***************
# | *** 272,277 ****
# | --- 272,281 ----
# |     correcting a spelling mistake on its option
# |     ``NamePrefixSuffixSilenceDissimilarityTreshold``.
# |   
# | + - Improved :doc:`bugprone-easily-swappable-parameters
# | +   <clang-tidy/checks/bugprone/easily-swappable-parameters>` check
# | +   this is just an example test.
# | + 
# |   - Improved :doc:`bugprone-exception-escape
# |     <clang-tidy/checks/bugprone/exception-escape>` check's handling of lambdas:
# |     exceptions from captures are now diagnosed, exceptions in the bodies of
# `-----------------------------
# error: command failed with exit status: 1
```

The intent is to surface duplicates so developers can merge them manually. However, when run with the `--fix` flag, the tool deletes the later duplicate entry outright, leaving the file as:

```
Changes in existing checks
^^^^^^^^^^^^^^^^^^^^^^^^^^

- Improved :doc:`bugprone-easily-swappable-parameters
  <clang-tidy/checks/bugprone/easily-swappable-parameters>` check by
  correcting a spelling mistake on its option
  ``NamePrefixSuffixSilenceDissimilarityTreshold``.
```

This causes unintended content loss.

I'm not sure how to deal with this, perhaps emits a warning instead of deleting entries?

Any suggestions are welcome.

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


More information about the cfe-commits mailing list