Skip to content

Commit

Permalink
Drop std:: qualification from integer types like uint64_t.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 643418422
Change-Id: Ib16cfef8ddedc8366df49ca75ab02eb60af08f26
  • Loading branch information
Chris Mihelich authored and Copybara-Service committed Jun 14, 2024
1 parent 9755364 commit f04e489
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
12 changes: 6 additions & 6 deletions absl/debugging/internal/demangle_rust.cc
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ class RustSymbolParser {

private:
// Enumerates resumption points for ABSL_DEMANGLER_RECURSE calls.
enum ReturnAddress : std::uint8_t {
enum ReturnAddress : uint8_t {
kInstantiatingCrate,
kVendorSpecificSuffix,
kIdentifierInUppercaseNamespace,
Expand Down Expand Up @@ -585,9 +585,9 @@ class RustSymbolParser {
// false if not everything fit into the output buffer.
ABSL_MUST_USE_RESULT bool Emit(const char* token) {
if (silence_depth_ > 0) return true;
const std::size_t token_length = std::strlen(token);
const std::size_t bytes_to_copy = token_length + 1; // token and final NUL
if (static_cast<std::size_t>(out_end_ - out_) < bytes_to_copy) return false;
const size_t token_length = std::strlen(token);
const size_t bytes_to_copy = token_length + 1; // token and final NUL
if (static_cast<size_t>(out_end_ - out_) < bytes_to_copy) return false;
std::memcpy(out_, token, bytes_to_copy);
out_ += token_length;
return true;
Expand All @@ -604,7 +604,7 @@ class RustSymbolParser {
// because 999 > 256. The bound will remain correct even if future
// maintenance changes the type of the disambiguator variable.
char digits[3 * sizeof(disambiguator)] = {};
std::size_t leading_digit_index = sizeof(digits) - 1;
size_t leading_digit_index = sizeof(digits) - 1;
for (; disambiguator > 0; disambiguator /= 10) {
digits[--leading_digit_index] =
static_cast<char>('0' + disambiguator % 10);
Expand Down Expand Up @@ -909,7 +909,7 @@ class RustSymbolParser {
} // namespace

bool DemangleRustSymbolEncoding(const char* mangled, char* out,
std::size_t out_size) {
size_t out_size) {
return RustSymbolParser(mangled, out, out + out_size).Parse();
}

Expand Down
2 changes: 1 addition & 1 deletion absl/debugging/internal/demangle_rust.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace debugging_internal {
// The demangling logic is under development; search for "not yet implemented"
// in the .cc file to see where the gaps are.
bool DemangleRustSymbolEncoding(const char* mangled, char* out,
std::size_t out_size);
size_t out_size);

} // namespace debugging_internal
ABSL_NAMESPACE_END
Expand Down
10 changes: 5 additions & 5 deletions absl/debugging/internal/demangle_rust_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace {
// chars>, buffer_size) returns true and seems not to have overrun its output
// buffer, returns the string written by DemangleRustSymbolEncoding; otherwise
// returns an error message.
std::string ResultOfDemangling(const char* mangled, std::size_t buffer_size) {
std::string ResultOfDemangling(const char* mangled, size_t buffer_size) {
// Fill the buffer with something other than NUL so we test whether Demangle
// appends trailing NUL as expected.
std::string buffer(buffer_size + 1, '~');
Expand Down Expand Up @@ -58,9 +58,9 @@ std::string ResultOfDemangling(const char* mangled, std::size_t buffer_size) {
#define EXPECT_DEMANGLING(mangled, plaintext) \
do { \
[] { \
constexpr std::size_t plenty_of_space = sizeof(plaintext) + 128; \
constexpr std::size_t just_enough_space = sizeof(plaintext); \
constexpr std::size_t one_byte_too_few = sizeof(plaintext) - 1; \
constexpr size_t plenty_of_space = sizeof(plaintext) + 128; \
constexpr size_t just_enough_space = sizeof(plaintext); \
constexpr size_t one_byte_too_few = sizeof(plaintext) - 1; \
const char* expected_plaintext = plaintext; \
const char* expected_error = "Failed parse"; \
ASSERT_EQ(ResultOfDemangling(mangled, plenty_of_space), \
Expand All @@ -76,7 +76,7 @@ std::string ResultOfDemangling(const char* mangled, std::size_t buffer_size) {
// truncation of a real Rust symbol name).
#define EXPECT_DEMANGLING_FAILS(mangled) \
do { \
constexpr std::size_t plenty_of_space = 1024; \
constexpr size_t plenty_of_space = 1024; \
const char* expected_error = "Failed parse"; \
EXPECT_EQ(ResultOfDemangling(mangled, plenty_of_space), expected_error); \
} while (0)
Expand Down
2 changes: 1 addition & 1 deletion absl/debugging/internal/demangle_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@ TEST(Demangle, BinaryFoldExpressions) {
TEST(Demangle, SizeofPacks) {
char tmp[80];

// template <std::size_t i> struct S {};
// template <size_t i> struct S {};
//
// template <class... T> auto f(T... p) -> S<sizeof...(T)> { return {}; }
// template auto f<int, long>(int, long) -> S<2>;
Expand Down
42 changes: 21 additions & 21 deletions absl/debugging/internal/utf8_for_code_point_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,63 +25,63 @@ namespace debugging_internal {
namespace {

TEST(Utf8ForCodePointTest, RecognizesTheSmallestCodePoint) {
Utf8ForCodePoint utf8(std::uint64_t{0});
Utf8ForCodePoint utf8(uint64_t{0});
ASSERT_EQ(utf8.length, 1);
EXPECT_EQ(utf8.bytes[0], '\0');
}

TEST(Utf8ForCodePointTest, RecognizesAsciiSmallA) {
Utf8ForCodePoint utf8(std::uint64_t{'a'});
Utf8ForCodePoint utf8(uint64_t{'a'});
ASSERT_EQ(utf8.length, 1);
EXPECT_EQ(utf8.bytes[0], 'a');
}

TEST(Utf8ForCodePointTest, RecognizesTheLargestOneByteCodePoint) {
Utf8ForCodePoint utf8(std::uint64_t{0x7f});
Utf8ForCodePoint utf8(uint64_t{0x7f});
ASSERT_EQ(utf8.length, 1);
EXPECT_EQ(utf8.bytes[0], '\x7f');
}

TEST(Utf8ForCodePointTest, RecognizesTheSmallestTwoByteCodePoint) {
Utf8ForCodePoint utf8(std::uint64_t{0x80});
Utf8ForCodePoint utf8(uint64_t{0x80});
ASSERT_EQ(utf8.length, 2);
EXPECT_EQ(utf8.bytes[0], static_cast<char>(0xc2));
EXPECT_EQ(utf8.bytes[1], static_cast<char>(0x80));
}

TEST(Utf8ForCodePointTest, RecognizesSmallNWithTilde) {
Utf8ForCodePoint utf8(std::uint64_t{0xf1});
Utf8ForCodePoint utf8(uint64_t{0xf1});
ASSERT_EQ(utf8.length, 2);
const char* want = "ñ";
EXPECT_EQ(utf8.bytes[0], want[0]);
EXPECT_EQ(utf8.bytes[1], want[1]);
}

TEST(Utf8ForCodePointTest, RecognizesCapitalPi) {
Utf8ForCodePoint utf8(std::uint64_t{0x3a0});
Utf8ForCodePoint utf8(uint64_t{0x3a0});
ASSERT_EQ(utf8.length, 2);
const char* want = "Π";
EXPECT_EQ(utf8.bytes[0], want[0]);
EXPECT_EQ(utf8.bytes[1], want[1]);
}

TEST(Utf8ForCodePointTest, RecognizesTheLargestTwoByteCodePoint) {
Utf8ForCodePoint utf8(std::uint64_t{0x7ff});
Utf8ForCodePoint utf8(uint64_t{0x7ff});
ASSERT_EQ(utf8.length, 2);
EXPECT_EQ(utf8.bytes[0], static_cast<char>(0xdf));
EXPECT_EQ(utf8.bytes[1], static_cast<char>(0xbf));
}

TEST(Utf8ForCodePointTest, RecognizesTheSmallestThreeByteCodePoint) {
Utf8ForCodePoint utf8(std::uint64_t{0x800});
Utf8ForCodePoint utf8(uint64_t{0x800});
ASSERT_EQ(utf8.length, 3);
EXPECT_EQ(utf8.bytes[0], static_cast<char>(0xe0));
EXPECT_EQ(utf8.bytes[1], static_cast<char>(0xa0));
EXPECT_EQ(utf8.bytes[2], static_cast<char>(0x80));
}

TEST(Utf8ForCodePointTest, RecognizesTheChineseCharacterZhong1AsInZhong1Wen2) {
Utf8ForCodePoint utf8(std::uint64_t{0x4e2d});
Utf8ForCodePoint utf8(uint64_t{0x4e2d});
ASSERT_EQ(utf8.length, 3);
const char* want = "";
EXPECT_EQ(utf8.bytes[0], want[0]);
Expand All @@ -90,41 +90,41 @@ TEST(Utf8ForCodePointTest, RecognizesTheChineseCharacterZhong1AsInZhong1Wen2) {
}

TEST(Utf8ForCodePointTest, RecognizesOneBeforeTheSmallestSurrogate) {
Utf8ForCodePoint utf8(std::uint64_t{0xd7ff});
Utf8ForCodePoint utf8(uint64_t{0xd7ff});
ASSERT_EQ(utf8.length, 3);
EXPECT_EQ(utf8.bytes[0], static_cast<char>(0xed));
EXPECT_EQ(utf8.bytes[1], static_cast<char>(0x9f));
EXPECT_EQ(utf8.bytes[2], static_cast<char>(0xbf));
}

TEST(Utf8ForCodePointTest, RejectsTheSmallestSurrogate) {
Utf8ForCodePoint utf8(std::uint64_t{0xd800});
Utf8ForCodePoint utf8(uint64_t{0xd800});
EXPECT_EQ(utf8.length, 0);
}

TEST(Utf8ForCodePointTest, RejectsTheLargestSurrogate) {
Utf8ForCodePoint utf8(std::uint64_t{0xdfff});
Utf8ForCodePoint utf8(uint64_t{0xdfff});
EXPECT_EQ(utf8.length, 0);
}

TEST(Utf8ForCodePointTest, RecognizesOnePastTheLargestSurrogate) {
Utf8ForCodePoint utf8(std::uint64_t{0xe000});
Utf8ForCodePoint utf8(uint64_t{0xe000});
ASSERT_EQ(utf8.length, 3);
EXPECT_EQ(utf8.bytes[0], static_cast<char>(0xee));
EXPECT_EQ(utf8.bytes[1], static_cast<char>(0x80));
EXPECT_EQ(utf8.bytes[2], static_cast<char>(0x80));
}

TEST(Utf8ForCodePointTest, RecognizesTheLargestThreeByteCodePoint) {
Utf8ForCodePoint utf8(std::uint64_t{0xffff});
Utf8ForCodePoint utf8(uint64_t{0xffff});
ASSERT_EQ(utf8.length, 3);
EXPECT_EQ(utf8.bytes[0], static_cast<char>(0xef));
EXPECT_EQ(utf8.bytes[1], static_cast<char>(0xbf));
EXPECT_EQ(utf8.bytes[2], static_cast<char>(0xbf));
}

TEST(Utf8ForCodePointTest, RecognizesTheSmallestFourByteCodePoint) {
Utf8ForCodePoint utf8(std::uint64_t{0x10000});
Utf8ForCodePoint utf8(uint64_t{0x10000});
ASSERT_EQ(utf8.length, 4);
EXPECT_EQ(utf8.bytes[0], static_cast<char>(0xf0));
EXPECT_EQ(utf8.bytes[1], static_cast<char>(0x90));
Expand All @@ -133,7 +133,7 @@ TEST(Utf8ForCodePointTest, RecognizesTheSmallestFourByteCodePoint) {
}

TEST(Utf8ForCodePointTest, RecognizesTheJackOfHearts) {
Utf8ForCodePoint utf8(std::uint64_t{0x1f0bb});
Utf8ForCodePoint utf8(uint64_t{0x1f0bb});
ASSERT_EQ(utf8.length, 4);
const char* want = "🂻";
EXPECT_EQ(utf8.bytes[0], want[0]);
Expand All @@ -143,7 +143,7 @@ TEST(Utf8ForCodePointTest, RecognizesTheJackOfHearts) {
}

TEST(Utf8ForCodePointTest, RecognizesTheLargestFourByteCodePoint) {
Utf8ForCodePoint utf8(std::uint64_t{0x10ffff});
Utf8ForCodePoint utf8(uint64_t{0x10ffff});
ASSERT_EQ(utf8.length, 4);
EXPECT_EQ(utf8.bytes[0], static_cast<char>(0xf4));
EXPECT_EQ(utf8.bytes[1], static_cast<char>(0x8f));
Expand All @@ -152,21 +152,21 @@ TEST(Utf8ForCodePointTest, RecognizesTheLargestFourByteCodePoint) {
}

TEST(Utf8ForCodePointTest, RejectsTheSmallestOverlargeCodePoint) {
Utf8ForCodePoint utf8(std::uint64_t{0x110000});
Utf8ForCodePoint utf8(uint64_t{0x110000});
EXPECT_EQ(utf8.length, 0);
}

TEST(Utf8ForCodePointTest, RejectsAThroughlyOverlargeCodePoint) {
Utf8ForCodePoint utf8(std::uint64_t{0xffffffff00000000});
Utf8ForCodePoint utf8(uint64_t{0xffffffff00000000});
EXPECT_EQ(utf8.length, 0);
}

TEST(Utf8ForCodePointTest, OkReturnsTrueForAValidCodePoint) {
EXPECT_TRUE(Utf8ForCodePoint(std::uint64_t{0}).ok());
EXPECT_TRUE(Utf8ForCodePoint(uint64_t{0}).ok());
}

TEST(Utf8ForCodePointTest, OkReturnsFalseForAnInvalidCodePoint) {
EXPECT_FALSE(Utf8ForCodePoint(std::uint64_t{0xffffffff00000000}).ok());
EXPECT_FALSE(Utf8ForCodePoint(uint64_t{0xffffffff00000000}).ok());
}

} // namespace
Expand Down

0 comments on commit f04e489

Please sign in to comment.