[PATCH] D151557: [ADT] Fix DenseMapInfo<variant>::isEqual to delegate to DenseMapInfo, not ==
Elliot Goodrich via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 3 13:55:12 PDT 2023
IncludeGuardian requested changes to this revision.
IncludeGuardian added inline comments.
This revision now requires changes to proceed.
================
Comment at: llvm/include/llvm/ADT/DenseMapInfo.h:354-356
+ return std::visit(detail::EqVisitor{detail::variantGetDynamic(
+ RHS, std::make_index_sequence<sizeof...(Ts)>{})},
+ LHS);
----------------
I think we may be able to use `std::visit` twice and rely on the type of the parameter in the second visit matching the original type of the value we cast to `const void *`.
```
const void *ErasedLHSValue = std::visit([](const auto& LHSValue){
return static_cast<const void *>(&LHSValue);
}, l);
return std::visit([=](const auto& RHSValue){
using T = std::remove_reference_t<decltype(RHSValue)>;
return DenseMapInfo<T>::isEqual(*static_cast<T *>(ErasedLHSValue), RHSValue);
}, r);
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151557/new/
https://reviews.llvm.org/D151557
More information about the llvm-commits
mailing list