[llvm] [clang-tools-extra] [clang] Add clang-tidy check to suggest replacement of conditional statement with std::min/std::max (PR #77816)

Julian Schmidt via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 19 06:11:01 PST 2024


https://github.com/5chmidti requested changes to this pull request.

I found some things that should be addressed.

@PiotrZSL you had a comment about "improving readability and promoting the use of standard library functions." in `ReleaseNotes.rst`, I just want to mention that this sentence is also present in the header and check documentation. I don't know if your comment is meant to be scoped to `ReleaseNotes.rst` or this (partial) sentence itself. 

As @felix642 noticed in a review comment, and @PiotrZSL wrote in the linked issue, the check should also detect
```c++
if (value1 < value2)
  value = value2;
else
  value = value1;
```
and `value = (value1 < value2) ? value1 : value2;`.

I would want to see these cases be handled by this check, the question I have is if this functionality should be added in this pr or in a follow-up pr (the issue should not be closed in this case). Thoughts? IMO, a follow-up pr is fine.

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


More information about the cfe-commits mailing list