[PATCH] D131869: [llvm] Remove std::clamp equivalent in `Transforms/Utils/MisExpect.cpp`

Paul Kirth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 15 08:00:31 PDT 2022


paulkirth accepted this revision.
paulkirth added a comment.
This revision is now accepted and ready to land.

LGTM.

If you’re up for it, cleaning up how we parse tolerance in clang and how we store it in the context would be nice.

If not, I’ll probably do it later today so no worries.

Thanks for the clean up!



================
Comment at: llvm/lib/Transforms/Utils/MisExpect.cpp:171
   auto Tolerance = getMisExpectTolerance(I.getContext());
-  Tolerance = clamp(Tolerance, 0, 99);
+  Tolerance = std::clamp(static_cast<std::uint32_t>(Tolerance), 0u, 99u);
 
----------------
I don’t know what I was thinking when I implemented the tolerance option. There’s no reason they need to be 64-bit.  

Really, we should fix how we parse and store the tolerance values. 

That would allow us to ditch all these casts here and also choose more reasonable types. 

Especially since they can’t exceed 100 …


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131869/new/

https://reviews.llvm.org/D131869



More information about the llvm-commits mailing list