[PATCH] D115907: [misexpect] Re-implement MisExpect Diagnostics

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 4 21:55:39 PDT 2022


tejohnson added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/MisExpect.cpp:150
+// TODO: when clang allows c++17, use std::clamp instead
+uint32_t clamp(uint64_t value, uint32_t hi, uint32_t low) {
+  if (value > hi)
----------------
Nit: seems more intuitive to pass low before high. But not sure the low is needed in this case, see comment at callsite.


================
Comment at: llvm/lib/Transforms/Utils/MisExpect.cpp:201
+  auto Tolerance = getMisExpectTolerance(I.getContext());
+  Tolerance = clamp(Tolerance, 99, 0);
+
----------------
Looks like Tolerance is unsigned, as are the arguments to clamp. So it can never go below 0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115907



More information about the llvm-commits mailing list