aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/CommandLineTest.cpp
diff options
context:
space:
mode:
authorJoe Loser <joeloser@fastmail.com>2022-09-06 18:06:58 -0600
committerJoe Loser <joeloser@fastmail.com>2022-09-08 09:01:53 -0600
commit5e96cea1db0623a833d5376c9ea2ce4528771f97 (patch)
tree7949b48788ad2e39d81d601464cdd2bb6f5c9e20 /llvm/unittests/Support/CommandLineTest.cpp
parent7aec9ddcfd20dc241a37f862b20dddbb8a4efb2f (diff)
downloadllvm-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/Support/CommandLineTest.cpp')
-rw-r--r--llvm/unittests/Support/CommandLineTest.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index 32dc440..41d483a5 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -375,7 +375,7 @@ TEST(CommandLineTest, AliasesWithArguments) {
{ "-tool", "-alias", "x" }
};
- for (size_t i = 0, e = array_lengthof(Inputs); i < e; ++i) {
+ for (size_t i = 0, e = std::size(Inputs); i < e; ++i) {
StackOption<std::string> Actual("actual");
StackOption<bool> Extra("extra");
StackOption<std::string> Input(cl::Positional);
@@ -404,8 +404,8 @@ void testAliasRequired(int argc, const char *const *argv) {
TEST(CommandLineTest, AliasRequired) {
const char *opts1[] = { "-tool", "-option=x" };
const char *opts2[] = { "-tool", "-o", "x" };
- testAliasRequired(array_lengthof(opts1), opts1);
- testAliasRequired(array_lengthof(opts2), opts2);
+ testAliasRequired(std::size(opts1), opts1);
+ testAliasRequired(std::size(opts2), opts2);
}
TEST(CommandLineTest, HideUnrelatedOptions) {
@@ -455,8 +455,8 @@ TEST(CommandLineTest, HideUnrelatedOptionsMulti) {
TEST(CommandLineTest, SetMultiValues) {
StackOption<int> Option("option");
const char *args[] = {"prog", "-option=1", "-option=2"};
- EXPECT_TRUE(cl::ParseCommandLineOptions(array_lengthof(args), args,
- StringRef(), &llvm::nulls()));
+ EXPECT_TRUE(cl::ParseCommandLineOptions(std::size(args), args, StringRef(),
+ &llvm::nulls()));
EXPECT_EQ(Option, 2);
}
@@ -1032,8 +1032,8 @@ TEST(CommandLineTest, ResponseFileEOLs) {
/*CurrentDir=*/StringRef(TestRoot), FS));
const char *Expected[] = {"clang", "-Xclang", "-Wno-whatever", nullptr,
"input.cpp"};
- ASSERT_EQ(array_lengthof(Expected), Argv.size());
- for (size_t I = 0, E = array_lengthof(Expected); I < E; ++I) {
+ ASSERT_EQ(std::size(Expected), Argv.size());
+ for (size_t I = 0, E = std::size(Expected); I < E; ++I) {
if (Expected[I] == nullptr) {
ASSERT_EQ(Argv[I], nullptr);
} else {