[llvm] db008af - [llvm] Repair the modules build with C++17

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 22 12:52:23 PDT 2022


Ping

On Mon, Aug 15, 2022 at 3:20 PM David Blaikie <dblaikie at gmail.com> wrote:
>
> Ping
>
> On Tue, Aug 9, 2022 at 8:27 AM David Blaikie <dblaikie at gmail.com> wrote:
>>
>> These "I don't know why they work but they do" Workarounds continue to happen for modules & they're pretty unsatisfying.
>>
>> Any chance you could look into this a bit more to understand why they're broken/why this is the right fix? (partly because I expect we have quite a few range-based-for loops with initializer lists, and figuring out when some need explicit types and some don't seems like it'd be hard and confusing going forward)
>>
>> On Mon, Aug 8, 2022 at 3:04 PM Jonas Devlieghere via llvm-commits <llvm-commits at lists.llvm.org> wrote:
>>>
>>>
>>> Author: Jonas Devlieghere
>>> Date: 2022-08-08T15:04:46-07:00
>>> New Revision: db008af501534d4590542253ae3acf783986f5f7
>>>
>>> URL: https://github.com/llvm/llvm-project/commit/db008af501534d4590542253ae3acf783986f5f7
>>> DIFF: https://github.com/llvm/llvm-project/commit/db008af501534d4590542253ae3acf783986f5f7.diff
>>>
>>> LOG: [llvm] Repair the modules build with C++17
>>>
>>> I'm honestly not sure if this is a legitimate issue or not, but after
>>> switching from C++14 to C++17, the modules build started confusing
>>> arrays and initializer lists. Work around the issue by being explicit.
>>>
>>> Added:
>>>
>>>
>>> Modified:
>>>     llvm/include/llvm/ADT/STLExtras.h
>>>     llvm/include/llvm/Support/FormatProviders.h
>>>
>>> Removed:
>>>
>>>
>>>
>>> ################################################################################
>>> diff  --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
>>> index 8e18b6a95aac0..c56ca97856c2b 100644
>>> --- a/llvm/include/llvm/ADT/STLExtras.h
>>> +++ b/llvm/include/llvm/ADT/STLExtras.h
>>> @@ -725,8 +725,8 @@ class zip_shortest : public zip_common<zip_shortest<Iters...>, Iters...> {
>>>    template <size_t... Ns>
>>>    bool test(const zip_shortest<Iters...> &other,
>>>              std::index_sequence<Ns...>) const {
>>> -    return all_of(std::initializer_list<bool>{std::get<Ns>(this->iterators) !=
>>> -                                              std::get<Ns>(other.iterators)...},
>>> +    return all_of(std::array{std::get<Ns>(this->iterators) !=
>>> +                             std::get<Ns>(other.iterators)...},
>>>                    identity<bool>{});
>>>    }
>>>
>>>
>>> diff  --git a/llvm/include/llvm/Support/FormatProviders.h b/llvm/include/llvm/Support/FormatProviders.h
>>> index 8101ed7968adb..7cfce29b134fc 100644
>>> --- a/llvm/include/llvm/Support/FormatProviders.h
>>> +++ b/llvm/include/llvm/Support/FormatProviders.h
>>> @@ -21,8 +21,8 @@
>>>  #include "llvm/Support/FormatVariadicDetails.h"
>>>  #include "llvm/Support/NativeFormatting.h"
>>>
>>> +#include <array>
>>>  #include <type_traits>
>>> -#include <vector>
>>>
>>>  namespace llvm {
>>>  namespace detail {
>>> @@ -369,7 +369,7 @@ template <typename IterT> class format_provider<llvm::iterator_range<IterT>> {
>>>        return Default;
>>>      }
>>>
>>> -    for (const char *D : {"[]", "<>", "()"}) {
>>> +    for (const char *D : std::array{"[]", "<>", "()"}) {
>>>        if (Style.front() != D[0])
>>>          continue;
>>>        size_t End = Style.find_first_of(D[1]);
>>>
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list