[llvm] [DenseMap] Fix constness issues with lookup_or (PR #139247)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Wed May 28 11:06:29 PDT 2025
kazutakahirata wrote:
> Sorry about the thinko in the test case: should be fixed now. The included test case now fails with:
>
> ```
> /Users/artagnon/src/llvm/llvm/include/llvm/ADT/DenseMap.h:227:12: error: cannot initialize return object of type 'unsigned int *' with an lvalue of type 'const_arg_type_t<unsigned int *>' (aka 'const unsigned int *')
> 227 | return Default;
> | ^~~~~~~
> /Users/artagnon/src/llvm/llvm/unittests/ADT/DenseMapTest.cpp:677:21: note: in instantiation of member function 'llvm::DenseMapBase<llvm::DenseMap<int, unsigned int *>, int, unsigned int *, llvm::DenseMapInfo<int>, llvm::detail::DenseMapPair<int, unsigned int *>>::lookup_or' requested here
> 677 | unsigned *Ret = M.lookup_or(0, &Default);
> | ^
> ```
>
> without the DenseMap change. The issue isn't move semantics, but rather a constness.
I've verified the same failure.
So, the issue is about unnecessarily putting `const` on the value type. Thanks for the update and explanation!
https://github.com/llvm/llvm-project/pull/139247
More information about the llvm-commits
mailing list