diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h --- a/llvm/include/llvm/ADT/STLExtras.h +++ b/llvm/include/llvm/ADT/STLExtras.h @@ -2311,14 +2311,22 @@ return Storage; } - /// Returns the value at index `I`. This includes the index. - template - friend decltype(auto) get(const enumerator_result &Result) { + /// Returns the value at index `I`. This case covers index. + template > + friend std::size_t get(const enumerator_result &Result) { + return Result.Idx; + } + + /// Returns the value at index `I`. This case covers references to the + /// iteratees. + template > + friend std::tuple_element_t + get(const enumerator_result &Result) { + /// Note: This is a separate function from the other `get`, instead of an + /// `if constexpr` case, to work around an MSVC 19.31.31XXX compiler + /// (Visual Studio 17.1) return type deduction bug. static_assert(I < NumValues, "Index out of bounds"); - if constexpr (I == 0) - return Result.Idx; - else - return std::get(Result.Storage); + return std::get(Result.Storage); } template