This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Audit all uses of _LIBCPP_ASSERT and _LIBCPP_DEBUG_ASSERT
ClosedPublic

Authored by ldionne on Mar 24 2022, 6:18 AM.

Details

Summary

I audited all uses of _LIBCPP_ASSERT to make sure that we only used it
for "basic assertions", i.e. assertions with constant-time conditions.
I also audited all uses of _LIBCPP_DEBUG_ASSERT to make sure we used it
only for debug-mode assertions, and in one case had to change for
_LIBCPP_ASSERT instead.

As a fly-by, I also changed a couple of tests against nullptr or 0 to
be more explicit.

After this patch, all uses of _LIBCPP_ASSERT should be with constant-time
conditions, and all uses of _LIBCPP_DEBUG_ASSERT should be with conditions
that we only want to check when the debug mode is enabled.

Diff Detail

Event Timeline

ldionne created this revision.Mar 24 2022, 6:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2022, 6:18 AM
ldionne requested review of this revision.Mar 24 2022, 6:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2022, 6:18 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
philnik accepted this revision as: philnik.Mar 24 2022, 8:46 AM
philnik added a subscriber: philnik.
philnik added inline comments.
libcxx/include/list
2044

Since you are touching these lines anyways, could you replace the _VSTD uses?

ldionne accepted this revision as: Restricted Project.Mar 24 2022, 10:09 AM
ldionne marked an inline comment as done.

I'll update _VSTD upon committing to avoid hitting the CI again!

This revision is now accepted and ready to land.Mar 24 2022, 10:09 AM