diff options
author | Michael Kruse <llvm@meinersbur.de> | 2018-12-05 00:31:54 +0000 |
---|---|---|
committer | Michael Kruse <llvm@meinersbur.de> | 2018-12-05 00:31:54 +0000 |
commit | f57bfd3d9f2a9d659cfbab9bb196f8f183f669bf (patch) | |
tree | 8685a9fb07e1b2394fb8a6b11f703e08f325cfa5 /llvm/lib/CodeGen/InlineSpiller.cpp | |
parent | ff9aaa25e85948f1aebe30c058d9def55ece91ee (diff) | |
download | bcm5719-llvm-f57bfd3d9f2a9d659cfbab9bb196f8f183f669bf.tar.gz bcm5719-llvm-f57bfd3d9f2a9d659cfbab9bb196f8f183f669bf.zip |
[ADT] Add zip_longest iterators.
Like the already existing zip_shortest/zip_first iterators, zip_longest
iterates over multiple iterators at once, but has as many iterations as
the longest sequence.
This means some iterators may reach the end before others do.
zip_longest uses llvm::Optional's None value to mark a
past-the-end value.
zip_longest is not reverse-iteratable because the tuples iterated over
would be different for different length sequences (IMHO for the same
reason neither zip_shortest nor zip_first should be reverse-iteratable;
one can still reverse the ranges individually if that's the expected
behavior).
In contrast to zip_shortest/zip_first, zip_longest tuples contain
rvalues instead of references. This is because llvm::Optional cannot
contain reference types and the value-initialized default does not have
a memory location a reference could point to.
The motivation for these iterators is to use C++ foreach to compare two
lists of ordered attributes in D48100 (SemaOverload.cpp and
ASTReaderDecl.cpp).
Idea by @hfinkel.
This re-commits r348301 which was reverted by r348303.
The compilation error by gcc 5.4 was resolved using make_tuple in the in
the initializer_list.
The compileration error by msvc14 was resolved by splitting
ZipLongestValueType (which already was a workaround for msvc15) into
ZipLongestItemType and ZipLongestTupleType.
Differential Revision: https://reviews.llvm.org/D48348
llvm-svn: 348323
Diffstat (limited to 'llvm/lib/CodeGen/InlineSpiller.cpp')
0 files changed, 0 insertions, 0 deletions