This is an archive of the discontinued LLVM Phabricator instance.

[ADT] Clarify `zip` behavior with iteratees of different lengths
ClosedPublic

Authored by kuhar on Nov 28 2022, 1:14 PM.

Details

Summary

Update the documentation comment and add a new test case.

Add an assertion in zip_first checking the iteratee length precondition.

Diff Detail

Event Timeline

kuhar created this revision.Nov 28 2022, 1:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2022, 1:14 PM
Herald added a subscriber: hanchung. · View Herald Transcript
kuhar requested review of this revision.Nov 28 2022, 1:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2022, 1:14 PM
dblaikie added inline comments.Nov 28 2022, 4:04 PM
llvm/include/llvm/ADT/STLExtras.h
882–886

Worth mentioning what values are used to fill in if the second iteratee isn't long enough?

kuhar added inline comments.Nov 28 2022, 4:25 PM
llvm/include/llvm/ADT/STLExtras.h
882–886

Unless I'm mistaken, that's just UB. The first sentence explains that zip_first assumes that the first iteratee is the shortest.

Do you see some better wording here?

kuhar added inline comments.Nov 28 2022, 4:31 PM
llvm/include/llvm/ADT/STLExtras.h
882–886

Actually, maybe that would deserve it's own assertion as well.

kuhar updated this revision to Diff 478439.Nov 28 2022, 7:26 PM

Add an assertion in zip_first and a test case.

kuhar retitled this revision from [ADT] Clarify `zip` behavior with iteratees of different lengths. NFC. to [ADT] Clarify `zip` behavior with iteratees of different lengths.Nov 28 2022, 7:27 PM
kuhar edited the summary of this revision. (Show Details)
kuhar marked an inline comment as done.
kuhar updated this revision to Diff 478440.Nov 28 2022, 7:30 PM

Simplify assertion

kuhar added a reviewer: kazu.Nov 28 2022, 7:49 PM
dblaikie accepted this revision.Nov 29 2022, 12:02 AM
dblaikie added inline comments.
llvm/include/llvm/ADT/STLExtras.h
882–886

Ah, I see, fair enough.

Sure, could add an assertion here if you like - either in this review or separate commit.

This revision is now accepted and ready to land.Nov 29 2022, 12:02 AM
This revision was landed with ongoing or failed builds.Nov 29 2022, 4:55 PM
This revision was automatically updated to reflect the committed changes.