[libc-commits] [PATCH] D144161: [libc] Introduce a libc internal assertion macro named LIBC_ASSERT.
Tue Ly via Phabricator via libc-commits
libc-commits at lists.llvm.org
Wed Feb 15 21:44:09 PST 2023
lntue accepted this revision.
lntue added inline comments.
This revision is now accepted and ready to land.
================
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:
> 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
Thanks, I see how the message is printed. It basically comes together with the whole condition in `#COND`
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