[llvm] r280685 - Fix DensetSet::insert_as() for MSVC2015 (NFC)

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 5 20:03:15 PDT 2016


Author: mehdi_amini
Date: Mon Sep  5 22:03:15 2016
New Revision: 280685

URL: http://llvm.org/viewvc/llvm-project?rev=280685&view=rev
Log:
Fix DensetSet::insert_as() for MSVC2015  (NFC)

The latest MSVC update apparently resolve the call from the
const ref variant to itself, leading to an infinite
recursion. It is not clear to me why the r-value overload is
not selected. `ValueT` is a pointer type, and the functional-style
cast in the call `insert_as(ValueT(V), LookupKey);` should result
in a r-value ref. A bug in MSVC?

Differential Revision: https://reviews.llvm.org/D23956

Modified:
    llvm/trunk/include/llvm/ADT/DenseSet.h

Modified: llvm/trunk/include/llvm/ADT/DenseSet.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseSet.h?rev=280685&r1=280684&r2=280685&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/DenseSet.h (original)
+++ llvm/trunk/include/llvm/ADT/DenseSet.h Mon Sep  5 22:03:15 2016
@@ -168,12 +168,11 @@ public:
   template <typename LookupKeyT>
   std::pair<iterator, bool> insert_as(const ValueT &V,
                                       const LookupKeyT &LookupKey) {
-    return insert_as(ValueT(V), LookupKey);
+    return TheMap.insert_as({V, detail::DenseSetEmpty()}, LookupKey);
   }
   template <typename LookupKeyT>
   std::pair<iterator, bool> insert_as(ValueT &&V, const LookupKeyT &LookupKey) {
-    detail::DenseSetEmpty Empty;
-    return TheMap.insert_as(std::make_pair(std::move(V), Empty), LookupKey);
+    return TheMap.insert_as({std::move(V), detail::DenseSetEmpty()}, LookupKey);
   }
 
   // Range insertion of values.




More information about the llvm-commits mailing list