[llvm] 0838bd6 - [DenseMap] Fix MSVC buildbot failure in lookup_or (#142268)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 3 03:00:10 PDT 2025


Author: Ramkumar Ramachandra
Date: 2025-06-03T11:00:07+01:00
New Revision: 0838bd60b4c2fedc31b9cba218847781cd4dca50

URL: https://github.com/llvm/llvm-project/commit/0838bd60b4c2fedc31b9cba218847781cd4dca50
DIFF: https://github.com/llvm/llvm-project/commit/0838bd60b4c2fedc31b9cba218847781cd4dca50.diff

LOG: [DenseMap] Fix MSVC buildbot failure in lookup_or (#142268)

4bf67cd ([DenseMap] Fix constness issues with lookup_or) introduced a
buildbot failure:

  https://lab.llvm.org/buildbot/#/builders/63/builds/6559

The patch deviates from the spec and MSVC complains, where it doesn't
bind an lvalue to an rvalue reference. Fix it by qualifying the argument
of lookup_or with remove_cv_t.

Proof: https://godbolt.org/z/sjTvGMbce

Added: 
    

Modified: 
    llvm/include/llvm/ADT/DenseMap.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index de41a212c65ab..3825f8d523728 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -220,7 +220,8 @@ class DenseMapBase : public DebugEpochBase {
   // Return the entry with the specified key, or \p Default. This variant is
   // useful, because `lookup` cannot be used with non-default-constructible
   // values.
-  ValueT lookup_or(const_arg_type_t<KeyT> Val, ValueT &&Default) const {
+  template <typename U = std::remove_cv_t<ValueT>>
+  ValueT lookup_or(const_arg_type_t<KeyT> Val, U &&Default) const {
     if (const BucketT *Bucket = doFind(Val))
       return Bucket->getSecond();
     return Default;


        


More information about the llvm-commits mailing list