diff options
Diffstat (limited to 'absl')
-rw-r--r-- | absl/numeric/internal/bits.h | 12 | ||||
-rw-r--r-- | absl/strings/numbers.h | 8 | ||||
-rw-r--r-- | absl/strings/numbers_test.cc | 4 | ||||
-rw-r--r-- | absl/strings/string_view_test.cc | 4 |
4 files changed, 16 insertions, 12 deletions
diff --git a/absl/numeric/internal/bits.h b/absl/numeric/internal/bits.h index 50828156..af45700f 100644 --- a/absl/numeric/internal/bits.h +++ b/absl/numeric/internal/bits.h @@ -23,12 +23,6 @@ // windows intrinsic functions. #if defined(_MSC_VER) && !defined(__clang__) #include <intrin.h> -#if defined(_M_X64) -#pragma intrinsic(_BitScanReverse64) -#pragma intrinsic(_BitScanForward64) -#endif -#pragma intrinsic(_BitScanReverse) -#pragma intrinsic(_BitScanForward) #endif #include "absl/base/attributes.h" @@ -185,7 +179,8 @@ CountLeadingZeroes64(uint64_t x) { // Handle 0 as a special case because __builtin_clzll(0) is undefined. return x == 0 ? 64 : __builtin_clzll(x); -#elif defined(_MSC_VER) && !defined(__clang__) && defined(_M_X64) +#elif defined(_MSC_VER) && !defined(__clang__) && \ + (defined(_M_X64) || defined(_M_ARM64)) // MSVC does not have __buitin_clzll. Use _BitScanReverse64. unsigned long result = 0; // NOLINT(runtime/int) if (_BitScanReverse64(&result, x)) { @@ -271,7 +266,8 @@ CountTrailingZeroesNonzero64(uint64_t x) { static_assert(sizeof(unsigned long long) == sizeof(x), // NOLINT(runtime/int) "__builtin_ctzll does not take 64-bit arg"); return __builtin_ctzll(x); -#elif defined(_MSC_VER) && !defined(__clang__) && defined(_M_X64) +#elif defined(_MSC_VER) && !defined(__clang__) && \ + (defined(_M_X64) || defined(_M_ARM64)) unsigned long result = 0; // NOLINT(runtime/int) _BitScanForward64(&result, x); return result; diff --git a/absl/strings/numbers.h b/absl/strings/numbers.h index ffc738fa..7966e250 100644 --- a/absl/strings/numbers.h +++ b/absl/strings/numbers.h @@ -1,3 +1,4 @@ +// // Copyright 2017 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -244,6 +245,13 @@ inline size_t FastHexToBufferZeroPad16(uint64_t val, char* out) { } // namespace numbers_internal +// SimpleAtoi() +// +// Converts a string to an integer, using `safe_strto?()` functions for actual +// parsing, returning `true` if successful. The `safe_strto?()` functions apply +// strict checking; the string must be a base-10 integer, optionally followed or +// preceded by ASCII whitespace, with a value in the range of the corresponding +// integer type. template <typename int_type> ABSL_MUST_USE_RESULT bool SimpleAtoi(absl::string_view str, int_type* out) { return numbers_internal::safe_strtoi_base(str, out, 10); diff --git a/absl/strings/numbers_test.cc b/absl/strings/numbers_test.cc index 27616bf8..4ab67fb6 100644 --- a/absl/strings/numbers_test.cc +++ b/absl/strings/numbers_test.cc @@ -46,7 +46,6 @@ namespace { -using absl::SimpleAtoi; using absl::numbers_internal::kSixDigitsToBufferSize; using absl::numbers_internal::safe_strto32_base; using absl::numbers_internal::safe_strto64_base; @@ -56,6 +55,7 @@ using absl::numbers_internal::SixDigitsToBuffer; using absl::strings_internal::Itoa; using absl::strings_internal::strtouint32_test_cases; using absl::strings_internal::strtouint64_test_cases; +using absl::SimpleAtoi; using testing::Eq; using testing::MatchesRegex; @@ -380,7 +380,7 @@ TEST(NumbersTest, Atoi) { VerifySimpleAtoiGood<uint32_t>(42, 42); VerifySimpleAtoiGood<unsigned int>(42, 42); VerifySimpleAtoiGood<int64_t>(-42, -42); - VerifySimpleAtoiGood<long>(-42, -42); // NOLINT: runtime-int + VerifySimpleAtoiGood<long>(-42, -42); // NOLINT(runtime/int) VerifySimpleAtoiGood<uint64_t>(42, 42); VerifySimpleAtoiGood<size_t>(42, 42); VerifySimpleAtoiGood<std::string::size_type>(42, 42); diff --git a/absl/strings/string_view_test.cc b/absl/strings/string_view_test.cc index dcebb150..643af8f8 100644 --- a/absl/strings/string_view_test.cc +++ b/absl/strings/string_view_test.cc @@ -915,9 +915,9 @@ TEST(StringViewTest, At) { EXPECT_EQ(abc.at(1), 'b'); EXPECT_EQ(abc.at(2), 'c'); #ifdef ABSL_HAVE_EXCEPTIONS - EXPECT_THROW(abc.at(3), std::out_of_range); + EXPECT_THROW((void)abc.at(3), std::out_of_range); #else - ABSL_EXPECT_DEATH_IF_SUPPORTED(abc.at(3), "absl::string_view::at"); + ABSL_EXPECT_DEATH_IF_SUPPORTED((void)abc.at(3), "absl::string_view::at"); #endif } |