-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Open
Labels
clang-tidyenhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing feature
Description
Tried the new check readability-use-std-min-max of the upcoming Clang-Tidy 19.
In one case we had following code:
if (ratio < 0.0F)
{
ratio = 0.0F;
}
if (ratio > 1.0F)
{
ratio = 1.0F;
}Running run-clang-tidy-19 -header-filter='.*' -checks='-*,readability-use-std-min-max' -fix results in:
ratio = std::max(ratio, 0.0F);
ratio = std::min(ratio, 1.0F);But in this case it would be better
ratio = std::clamp(ratio, 0.0F, 1.0F);I don't know how complex it would be to recognize this pattern, i.e. whether it is better to introduce a readability-use-std-clamp, even if this may require a second pass, or whether this can be combined by changing the check to readability-use-std-min-max-clamp.
nicovank and carlosgalvezp
Metadata
Metadata
Assignees
Labels
clang-tidyenhancementImproving things as opposed to bug fixing, e.g. new or missing featureImproving things as opposed to bug fixing, e.g. new or missing feature