[llvm] r182684 - MathExtras: Return the result of find(First|Last)Set in the input type.

Benjamin Kramer benny.kra at googlemail.com
Fri May 24 15:25:20 PDT 2013


Author: d0k
Date: Fri May 24 17:25:20 2013
New Revision: 182684

URL: http://llvm.org/viewvc/llvm-project?rev=182684&view=rev
Log:
MathExtras: Return the result of find(First|Last)Set in the input type.

Otherwise ZB_Max returns a wrong result when sizeof(T) > sizeof(size_t).

Modified:
    llvm/trunk/include/llvm/Support/MathExtras.h

Modified: llvm/trunk/include/llvm/Support/MathExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=182684&r1=182683&r2=182684&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MathExtras.h (original)
+++ llvm/trunk/include/llvm/Support/MathExtras.h Fri May 24 17:25:20 2013
@@ -177,7 +177,7 @@ inline std::size_t countLeadingZeros<uin
 ///   valid arguments.
 template <typename T>
 typename enable_if_c<std::numeric_limits<T>::is_integer &&
-                     !std::numeric_limits<T>::is_signed, std::size_t>::type
+                     !std::numeric_limits<T>::is_signed, T>::type
 findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) {
   if (ZB == ZB_Max && Val == 0)
     return std::numeric_limits<T>::max();
@@ -188,7 +188,7 @@ findFirstSet(T Val, ZeroBehavior ZB = ZB
 // Disable signed.
 template <typename T>
 typename enable_if_c<std::numeric_limits<T>::is_integer &&
-                     std::numeric_limits<T>::is_signed, std::size_t>::type
+                     std::numeric_limits<T>::is_signed, T>::type
 findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) LLVM_DELETED_FUNCTION;
 
 /// \brief Get the index of the last set bit starting from the least
@@ -200,7 +200,7 @@ findFirstSet(T Val, ZeroBehavior ZB = ZB
 ///   valid arguments.
 template <typename T>
 typename enable_if_c<std::numeric_limits<T>::is_integer &&
-                     !std::numeric_limits<T>::is_signed, std::size_t>::type
+                     !std::numeric_limits<T>::is_signed, T>::type
 findLastSet(T Val, ZeroBehavior ZB = ZB_Max) {
   if (ZB == ZB_Max && Val == 0)
     return std::numeric_limits<T>::max();
@@ -214,7 +214,7 @@ findLastSet(T Val, ZeroBehavior ZB = ZB_
 // Disable signed.
 template <typename T>
 typename enable_if_c<std::numeric_limits<T>::is_integer &&
-                     std::numeric_limits<T>::is_signed, std::size_t>::type
+                     std::numeric_limits<T>::is_signed, T>::type
 findLastSet(T Val, ZeroBehavior ZB = ZB_Max) LLVM_DELETED_FUNCTION;
 
 /// \brief Macro compressed bit reversal table for 256 bits.





More information about the llvm-commits mailing list