diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-05-24 22:25:20 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-05-24 22:25:20 +0000 |
commit | 927d8dcb47a50b4471f5619733fb8196fa1e52ea (patch) | |
tree | dbb17e59d9640d9f5ee287618a8f08d775e5e819 /include | |
parent | c6af2432c802d241c8fffbe0371c023e6c58844e (diff) | |
download | external_llvm-927d8dcb47a50b4471f5619733fb8196fa1e52ea.zip external_llvm-927d8dcb47a50b4471f5619733fb8196fa1e52ea.tar.gz external_llvm-927d8dcb47a50b4471f5619733fb8196fa1e52ea.tar.bz2 |
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).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182684 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Support/MathExtras.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h index d7b5898..272354f 100644 --- a/include/llvm/Support/MathExtras.h +++ b/include/llvm/Support/MathExtras.h @@ -177,7 +177,7 @@ inline std::size_t countLeadingZeros<uint64_t>(uint64_t Val, ZeroBehavior 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 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_Max) { // 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_Max) LLVM_DELETED_FUNCTION; /// 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_Max) { // 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. |