diff --git a/llvm/include/llvm/Support/HashBuilder.h b/llvm/include/llvm/Support/HashBuilder.h index c13e7d2c33a9c..04a7b2e7dc8ab 100644 --- a/llvm/include/llvm/Support/HashBuilder.h +++ b/llvm/include/llvm/Support/HashBuilder.h @@ -261,13 +261,12 @@ class HashBuilderImpl : public HashBuilderBase { template HashBuilderImpl &add(const std::pair &Value) { - add(Value.first); - add(Value.second); - return *this; + return add(Value.first, Value.second); } template HashBuilderImpl &add(const std::tuple &Arg) { - return addTupleHelper(Arg, typename std::index_sequence_for()); + std::apply([this](const auto &...Args) { this->add(Args...); }, Arg); + return *this; } /// A convenenience variadic helper. @@ -280,12 +279,10 @@ class HashBuilderImpl : public HashBuilderBase { /// add(Arg1) /// add(Arg2) /// ``` - template - std::enable_if_t<(sizeof...(Ts) >= 1), HashBuilderImpl &> - add(const T &FirstArg, const Ts &...Args) { - add(FirstArg); - add(Args...); - return *this; + template + std::enable_if_t<(sizeof...(Ts) > 1), HashBuilderImpl &> + add(const Ts &...Args) { + return (add(Args), ...); } template @@ -325,13 +322,6 @@ class HashBuilderImpl : public HashBuilderBase { } private: - template - HashBuilderImpl &addTupleHelper(const std::tuple &Arg, - std::index_sequence) { - add(std::get(Arg)...); - return *this; - } - // FIXME: Once available, specialize this function for `contiguous_iterator`s, // and use it for `ArrayRef` and `StringRef`. template