This is an archive of the discontinued LLVM Phabricator instance.

[libc][BlockStore] Add back, pop_back and empty methods
ClosedPublic

Authored by abrachet on Mar 14 2022, 6:53 PM.

Diff Detail

Event Timeline

abrachet created this revision.Mar 14 2022, 6:53 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 14 2022, 6:53 PM
sivachandra added inline comments.Mar 14 2022, 9:01 PM
libc/src/__support/CPP/blockstore.h
137

REVERSE_ORDER only controls the iteration. IMO, back and pop_back are independent of that and should work irrespective of the REVERSE_ORDER.

143

I think it might be better have a static assert like this:

static_assert(__has_trivial_contructor(T) && __has_trivial_destructor(T));
156

Please fix.

sivachandra accepted this revision.Mar 14 2022, 9:47 PM
sivachandra added inline comments.
libc/src/__support/CPP/blockstore.h
137

I just realized I pressed submit while I was still thinking about this. Go ahead and submit this patch with one change: Instead of a static_assert in the function body, use a EnableIf for the return type. I have few other thoughts. They would be best expressed as a separate patch, which I will do after you land this.

This revision is now accepted and ready to land.Mar 14 2022, 9:47 PM
abrachet updated this revision to Diff 415323.Mar 14 2022, 10:20 PM

Make pop_back and back work regardless of REVERSE_ORDER

abrachet marked 3 inline comments as done.Mar 14 2022, 10:23 PM
abrachet added inline comments.
libc/src/__support/CPP/blockstore.h
137

Ah, didn't see this comment while working on it. How does this look? I can revert to revision 1 if you'd like. But I guess this is probably better

143

I'll do this in a follow up patch and add an IsTrivially[Con|De]structible to TypeTraits.h to put the implementation dependent builtins in a more generic place.

sivachandra accepted this revision.Mar 14 2022, 10:46 PM
sivachandra added inline comments.
libc/src/__support/CPP/blockstore.h
137

Still fine. I don't quite like the for loop on line 56, but fine for now.

abrachet updated this revision to Diff 415443.Mar 15 2022, 8:09 AM
abrachet marked an inline comment as done.

clang-format

This revision was landed with ongoing or failed builds.Mar 15 2022, 8:13 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 15 2022, 8:14 AM
abrachet marked an inline comment as done.Mar 15 2022, 8:15 AM
abrachet added inline comments.
libc/src/__support/CPP/blockstore.h
137

Agreed, this is why I initially had it only for REVERSE_ORDER. In any case there are no current users of BlockStore<T, N, false>