This is an archive of the discontinued LLVM Phabricator instance.

[libc] Introduce a libc internal assertion macro named LIBC_ASSERT.
ClosedPublic

Authored by sivachandra on Feb 15 2023, 9:07 PM.

Details

Summary

Few existing call-sites have been modified to use LIBC_ASSERT.

Diff Detail

Event Timeline

sivachandra created this revision.Feb 15 2023, 9:07 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 15 2023, 9:07 PM
sivachandra requested review of this revision.Feb 15 2023, 9:07 PM
sivachandra edited the summary of this revision. (Show Details)Feb 15 2023, 9:10 PM
lntue added inline comments.Feb 15 2023, 9:16 PM
libc/src/__support/float_to_string.h
67

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?

sivachandra added inline comments.Feb 15 2023, 9:29 PM
libc/src/__support/float_to_string.h
67

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?

sivachandra added inline comments.Feb 15 2023, 9:32 PM
libc/src/__support/float_to_string.h
67

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

lntue accepted this revision.Feb 15 2023, 9:44 PM
lntue added inline comments.
libc/src/__support/float_to_string.h
67

Thanks, I see how the message is printed. It basically comes together with the whole condition in #COND

This revision is now accepted and ready to land.Feb 15 2023, 9:44 PM