[clang-tools-extra] [clang-tidy] add check to suggest replacement of nested std::min or std::max with initializer lists (PR #85572)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Sat Apr 13 12:21:30 PDT 2024


PiotrZSL wrote:

@sopyb 
Check is for modernize, not performance, so:
- Add entry in documentation that due to need of copy object into initialization list check may cause performance degradation, add entry that using std::ref, std::cref is recommended in such case:
`b = std::max({std::ref(i), std::ref(j), std::ref(k)});`
- Add option - IgnoreNonTrivialTypes - set by default to true
- Add option - IgnoreTrivialTypesOfSizeAbove - set by default to 32 bytes
Options should be easy to add, check other checks.
If you want quickly deliver version 1.0, then just limit check to built-in types.

As for copies of large types, that's more a thing for new performance check.

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


More information about the cfe-commits mailing list