[PATCH] D146340: [ADT] Work around `enumerate` compilation error with modules enabled
Jakub Kuderski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 17 16:56:03 PDT 2023
kuhar created this revision.
kuhar added reviewers: aprantl, dblaikie, kazu, zero9178.
Herald added a subscriber: hanchung.
Herald added a project: All.
kuhar requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This manifests on Apple clang 14 with `-DLLVM_ENABLE_MODULES=1` and
`-DLLVM_ENABLE_ASSERTIONS=1` and seems like a host compiler bug.
Sample compilation failure:
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/52513/consoleFull#-458239162a1ca8a51-895e-46c6-af87-ce24fa4cd561.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D146340
Files:
llvm/include/llvm/ADT/STLExtras.h
Index: llvm/include/llvm/ADT/STLExtras.h
===================================================================
--- llvm/include/llvm/ADT/STLExtras.h
+++ llvm/include/llvm/ADT/STLExtras.h
@@ -2385,10 +2385,15 @@
///
template <typename FirstRange, typename... RestRanges>
auto enumerate(FirstRange &&First, RestRanges &&...Rest) {
- assert((sizeof...(Rest) == 0 ||
- all_equal({std::distance(adl_begin(First), adl_end(First)),
- std::distance(adl_begin(Rest), adl_end(Rest))...})) &&
- "Ranges have different length");
+ if constexpr (sizeof...(Rest) != 0) {
+ // Note: Create an array instead of an initializer list to work around an
+ // Apple clang 14 compiler bug.
+ size_t sizes[] = {
+ static_cast<size_t>(std::distance(adl_begin(First), adl_end(First))),
+ static_cast<size_t>(std::distance(adl_begin(Rest), adl_end(Rest)))...};
+ (void)sizes;
+ assert(all_equal(sizes) && "Ranges have different length");
+ }
using enumerator = detail::zippy<detail::zip_enumerator, detail::index_stream,
FirstRange, RestRanges...>;
return enumerator(detail::index_stream{}, std::forward<FirstRange>(First),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146340.506229.patch
Type: text/x-patch
Size: 1209 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230317/f78c8f7a/attachment.bin>
More information about the llvm-commits
mailing list