This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Add a few _LIBCPP_ASSERTs in __tree
ClosedPublic

Authored by ldionne on Apr 26 2022, 2:05 PM.

Details

Reviewers
philnik
Group Reviewers
Restricted Project
Commits
rG990ea3925b7a: [libc++] Add a few _LIBCPP_ASSERTs in __tree
Summary

Several helper functions specify preconditions as comments, but we never
check them. I ran across a bug report (without a reproducer) in this code,
and I thought that having these assertions in place would make it easier
to troubleshoot.

Diff Detail

Event Timeline

ldionne created this revision.Apr 26 2022, 2:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2022, 2:05 PM
ldionne requested review of this revision.Apr 26 2022, 2:05 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2022, 2:05 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript

I think I would remove the comments, since the preconditions are now documented in code.

libcxx/include/__tree
355

Could you also add that precondition?

ldionne updated this revision to Diff 427074.May 4 2022, 11:14 AM
ldionne marked an inline comment as done.

Address comments.

libcxx/include/__tree
355

I'll do that, but I'll add it as a _LIBCPP_DEBUG_ASSERT, since checking that invariant requires recursively visiting the whole tree AFAICT. _LIBCPP_ASSERT assertions should be cheap and should not impact complexity.

philnik accepted this revision as: philnik.May 4 2022, 11:20 AM

LGTM assuming CI passes.

libcxx/include/__tree
355

Sounds good.

ldionne accepted this revision as: Restricted Project.May 5 2022, 8:28 AM
This revision is now accepted and ready to land.May 5 2022, 8:28 AM
This revision was automatically updated to reflect the committed changes.