diff options
author | Joe Loser <joeloser@fastmail.com> | 2022-09-06 18:06:58 -0600 |
---|---|---|
committer | Joe Loser <joeloser@fastmail.com> | 2022-09-08 09:01:53 -0600 |
commit | 5e96cea1db0623a833d5376c9ea2ce4528771f97 (patch) | |
tree | 7949b48788ad2e39d81d601464cdd2bb6f5c9e20 /llvm/unittests/ADT/StringRefTest.cpp | |
parent | 7aec9ddcfd20dc241a37f862b20dddbb8a4efb2f (diff) | |
download | llvm-5e96cea1db0623a833d5376c9ea2ce4528771f97.zip llvm-5e96cea1db0623a833d5376c9ea2ce4528771f97.tar.gz llvm-5e96cea1db0623a833d5376c9ea2ce4528771f97.tar.bz2 |
[llvm] Use std::size instead of llvm::array_lengthof
LLVM contains a helpful function for getting the size of a C-style
array: `llvm::array_lengthof`. This is useful prior to C++17, but not as
helpful for C++17 or later: `std::size` already has support for C-style
arrays.
Change call sites to use `std::size` instead.
Differential Revision: https://reviews.llvm.org/D133429
Diffstat (limited to 'llvm/unittests/ADT/StringRefTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/StringRefTest.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/unittests/ADT/StringRefTest.cpp b/llvm/unittests/ADT/StringRefTest.cpp index 25cd3cd..719f7c6 100644 --- a/llvm/unittests/ADT/StringRefTest.cpp +++ b/llvm/unittests/ADT/StringRefTest.cpp @@ -664,7 +664,7 @@ TEST(StringRefTest, getAsInteger) { uint32_t U32; uint64_t U64; - for (size_t i = 0; i < array_lengthof(Unsigned); ++i) { + for (size_t i = 0; i < std::size(Unsigned); ++i) { bool U8Success = StringRef(Unsigned[i].Str).getAsInteger(0, U8); if (static_cast<uint8_t>(Unsigned[i].Expected) == Unsigned[i].Expected) { ASSERT_FALSE(U8Success); @@ -696,7 +696,7 @@ TEST(StringRefTest, getAsInteger) { int32_t S32; int64_t S64; - for (size_t i = 0; i < array_lengthof(Signed); ++i) { + for (size_t i = 0; i < std::size(Signed); ++i) { bool S8Success = StringRef(Signed[i].Str).getAsInteger(0, S8); if (static_cast<int8_t>(Signed[i].Expected) == Signed[i].Expected) { ASSERT_FALSE(S8Success); @@ -742,7 +742,7 @@ static const char* BadStrings[] = { TEST(StringRefTest, getAsUnsignedIntegerBadStrings) { unsigned long long U64; - for (size_t i = 0; i < array_lengthof(BadStrings); ++i) { + for (size_t i = 0; i < std::size(BadStrings); ++i) { bool IsBadNumber = StringRef(BadStrings[i]).getAsInteger(0, U64); ASSERT_TRUE(IsBadNumber); } @@ -825,7 +825,7 @@ TEST(StringRefTest, consumeIntegerUnsigned) { uint32_t U32; uint64_t U64; - for (size_t i = 0; i < array_lengthof(ConsumeUnsigned); ++i) { + for (size_t i = 0; i < std::size(ConsumeUnsigned); ++i) { StringRef Str = ConsumeUnsigned[i].Str; bool U8Success = Str.consumeInteger(0, U8); if (static_cast<uint8_t>(ConsumeUnsigned[i].Expected) == @@ -873,7 +873,7 @@ TEST(StringRefTest, consumeIntegerSigned) { int32_t S32; int64_t S64; - for (size_t i = 0; i < array_lengthof(ConsumeSigned); ++i) { + for (size_t i = 0; i < std::size(ConsumeSigned); ++i) { StringRef Str = ConsumeSigned[i].Str; bool S8Success = Str.consumeInteger(0, S8); if (static_cast<int8_t>(ConsumeSigned[i].Expected) == @@ -950,7 +950,7 @@ static const char join_result3[] = "a::b::c"; TEST(StringRefTest, joinStrings) { std::vector<StringRef> v1; std::vector<std::string> v2; - for (size_t i = 0; i < array_lengthof(join_input); ++i) { + for (size_t i = 0; i < std::size(join_input); ++i) { v1.push_back(join_input[i]); v2.push_back(join_input[i]); } |