[cfe-commits] [libcxx] r171167 - /libcxx/trunk/src/hash.cpp

David Blaikie dblaikie at gmail.com
Thu Dec 27 11:33:04 PST 2012


On Thu, Dec 27, 2012 at 10:59 AM, Howard Hinnant <hhinnant at apple.com> wrote:
> Author: hhinnant
> Date: Thu Dec 27 12:59:05 2012
> New Revision: 171167
>
> URL: http://llvm.org/viewvc/llvm-project?rev=171167&view=rev
> Log:
> Saleem Abdulrasool:  Silence warning and reduce unnecessary code in hash.cpp.
>
> Modified:
>     libcxx/trunk/src/hash.cpp
>
> Modified: libcxx/trunk/src/hash.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/hash.cpp?rev=171167&r1=171166&r2=171167&view=diff
> ==============================================================================
> --- libcxx/trunk/src/hash.cpp (original)
> +++ libcxx/trunk/src/hash.cpp Thu Dec 27 12:59:05 2012
> @@ -10,6 +10,10 @@
>  #include "__hash_table"
>  #include "algorithm"
>  #include "stdexcept"
> +#include "type_traits"
> +
> +#pragma clang diagnostic push

Did you mean to pop this at some point? (otherwise I'm not sure why
you'd push it, though I may not be entirely understanding how these
push/pop things work - maybe there's some other reason to use them)

> +#pragma clang diagnostic ignored "-Wtautological-constant-out-of-range-compare"
>
>  _LIBCPP_BEGIN_NAMESPACE_STD
>
> @@ -144,21 +148,23 @@
>  // are fewer potential primes to search, and fewer potential primes to divide
>  // against.
>
> +template <size_t _Sz = sizeof(size_t)>
>  inline _LIBCPP_INLINE_VISIBILITY
> -void
> -__check_for_overflow(size_t N, integral_constant<size_t, 32>)
> +typename enable_if<_Sz == 4, void>::type
> +__check_for_overflow(size_t N)
>  {
> -#ifndef _LIBCPP_NO_EXCEPTIONS
> +#ifndef _LIBCPP_NO_EXCEPTIONS
>      if (N > 0xFFFFFFFB)
>          throw overflow_error("__next_prime overflow");
>  #endif
>  }
>
> +template <size_t _Sz = sizeof(size_t)>
>  inline _LIBCPP_INLINE_VISIBILITY
> -void
> -__check_for_overflow(size_t N, integral_constant<size_t, 64>)
> +typename enable_if<_Sz == 8, void>::type
> +__check_for_overflow(size_t N)
>  {
> -#ifndef _LIBCPP_NO_EXCEPTIONS
> +#ifndef _LIBCPP_NO_EXCEPTIONS
>      if (N > 0xFFFFFFFFFFFFFFC5ull)
>          throw overflow_error("__next_prime overflow");
>  #endif
> @@ -174,8 +180,7 @@
>          return *std::lower_bound(small_primes, small_primes + N, n);
>      // Else n > largest small_primes
>      // Check for overflow
> -    __check_for_overflow(n, integral_constant<size_t,
> -                                                   sizeof(n) * __CHAR_BIT__>());
> +    __check_for_overflow(n);
>      // Start searching list of potential primes: L * k0 + indices[in]
>      const size_t M = sizeof(indices) / sizeof(indices[0]);
>      // Select first potential prime >= n
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list