[libc-commits] [PATCH] D144161: [libc] Introduce a libc internal assertion macro named LIBC_ASSERT.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Feb 15 21:32:34 PST 2023


sivachandra added inline comments.


================
Comment at: libc/src/__support/float_to_string.h:67
+  LIBC_ASSERT(e >= 0 && e <= 1650 &&
+              "Incorrect exponent to perform log10_pow2 approximation.");
   return (e * 78913) >> 18;
----------------
sivachandra wrote:
> lntue wrote:
> > I don't see anywhere in the `LIBC_ASSERT` definition that can take the error message.  Also, this is `&&` with the conditions in the previous line?
> That is just the conventional way to attach messages to asserts: https://stackoverflow.com/questions/5867834/assert-with-message
> But, I am OK with adding a real message argument to the macro, which is probably nicer?
FWIW, there are many many examples of such uses with plain `assert` in LLVM. Example: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Analysis/AssumptionCache.cpp#L175


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144161



More information about the libc-commits mailing list