[libc][NFC] Use STL case for array

Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion.

Differential Revision: https://reviews.llvm.org/D130773

GitOrigin-RevId: 7add0e5fdc5c7cb6f59f60cd436bf161cf9f9eb7
diff --git a/src/__support/CPP/ArrayRef.h b/src/__support/CPP/ArrayRef.h
index 1219963..157e315 100644
--- a/src/__support/CPP/ArrayRef.h
+++ b/src/__support/CPP/ArrayRef.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC_SUPPORT_CPP_ARRAYREF_H
 #define LLVM_LIBC_SRC_SUPPORT_CPP_ARRAYREF_H
 
-#include "Array.h"
+#include "array.h"
 #include "type_traits.h" // RemoveCVType
 
 #include <stddef.h> // For size_t.
@@ -120,8 +120,8 @@
   ArrayRef(const void *Data, size_t Length)
       : Impl(reinterpret_cast<const T *>(Data), Length / sizeof(T)) {}
 
-  // From Array.
-  template <size_t N> ArrayRef(const Array<T, N> &Arr) : Impl(Arr.Data, N) {}
+  // From array.
+  template <size_t N> ArrayRef(const array<T, N> &Arr) : Impl(Arr.Data, N) {}
 };
 
 template <typename T>
@@ -139,8 +139,8 @@
   MutableArrayRef(void *Data, size_t Length)
       : Impl(reinterpret_cast<T *>(Data), Length / sizeof(T)) {}
 
-  // From Array.
-  template <size_t N> MutableArrayRef(Array<T, N> &Arr) : Impl(Arr.Data, N) {}
+  // From array.
+  template <size_t N> MutableArrayRef(array<T, N> &Arr) : Impl(Arr.Data, N) {}
 
   operator ArrayRef<T>() const {
     return ArrayRef<T>(this->data(), this->size());
diff --git a/src/__support/CPP/CMakeLists.txt b/src/__support/CPP/CMakeLists.txt
index 12cf729..d9126b1 100644
--- a/src/__support/CPP/CMakeLists.txt
+++ b/src/__support/CPP/CMakeLists.txt
@@ -1,7 +1,7 @@
 add_header_library(
   array
   HDRS
-    Array.h
+    array.h
 )
 
 add_header_library(
diff --git a/src/__support/CPP/UInt.h b/src/__support/CPP/UInt.h
index 045950b..dd15635 100644
--- a/src/__support/CPP/UInt.h
+++ b/src/__support/CPP/UInt.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_UTILS_CPP_UINT_H
 #define LLVM_LIBC_UTILS_CPP_UINT_H
 
-#include "Array.h"
+#include "array.h"
 
 #include <stddef.h> // For size_t
 #include <stdint.h>
@@ -44,7 +44,7 @@
       val[i] = 0;
     }
   }
-  constexpr explicit UInt(const cpp::Array<uint64_t, WordCount> &words) {
+  constexpr explicit UInt(const cpp::array<uint64_t, WordCount> &words) {
     for (size_t i = 0; i < WordCount; ++i)
       val[i] = words[i];
   }
@@ -104,7 +104,7 @@
     uint64_t x_lo = low(x);
     uint64_t x_hi = high(x);
 
-    cpp::Array<uint64_t, WordCount + 1> row1;
+    cpp::array<uint64_t, WordCount + 1> row1;
     uint64_t carry = 0;
     for (size_t i = 0; i < WordCount; ++i) {
       uint64_t l = low(val[i]);
@@ -123,7 +123,7 @@
     }
     row1[WordCount] = carry;
 
-    cpp::Array<uint64_t, WordCount + 1> row2;
+    cpp::array<uint64_t, WordCount + 1> row2;
     row2[0] = 0;
     carry = 0;
     for (size_t i = 0; i < WordCount; ++i) {
diff --git a/src/__support/CPP/Array.h b/src/__support/CPP/array.h
similarity index 93%
rename from src/__support/CPP/Array.h
rename to src/__support/CPP/array.h
index e198943..97db026 100644
--- a/src/__support/CPP/Array.h
+++ b/src/__support/CPP/array.h
@@ -14,8 +14,8 @@
 namespace __llvm_libc {
 namespace cpp {
 
-template <class T, size_t N> struct Array {
-  static_assert(N != 0, "Cannot create a __llvm_libc::cpp::Array of size 0.");
+template <class T, size_t N> struct array {
+  static_assert(N != 0, "Cannot create a __llvm_libc::cpp::array of size 0.");
 
   T Data[N];
 
diff --git a/test/src/__support/CPP/arrayref_test.cpp b/test/src/__support/CPP/arrayref_test.cpp
index 7cdff32..edb545a 100644
--- a/test/src/__support/CPP/arrayref_test.cpp
+++ b/test/src/__support/CPP/arrayref_test.cpp
@@ -65,7 +65,7 @@
 TYPED_TEST(LlvmLibcArrayRefTest, ConstructFromLibcArray, Types) {
   using value_type = typename ParamType::value_type;
   using const_pointer = typename ParamType::const_pointer;
-  Array<value_type, 2> values = {1, 2};
+  array<value_type, 2> values = {1, 2};
   ParamType arrayref(values);
   EXPECT_FALSE(arrayref.empty());
   EXPECT_EQ(arrayref.size(), size_t(2));
diff --git a/test/src/math/cosf_test.cpp b/test/src/math/cosf_test.cpp
index c7315e8..48b58b9 100644
--- a/test/src/math/cosf_test.cpp
+++ b/test/src/math/cosf_test.cpp
@@ -6,7 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/CPP/Array.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/math/cosf.h"
 #include "test/src/math/sdcomp26094.h"
diff --git a/test/src/math/sdcomp26094.h b/test/src/math/sdcomp26094.h
index 3162884..284578b 100644
--- a/test/src/math/sdcomp26094.h
+++ b/test/src/math/sdcomp26094.h
@@ -9,14 +9,14 @@
 #ifndef LLVM_LIBC_TEST_SRC_MATH_SDCOMP26094_H
 #define LLVM_LIBC_TEST_SRC_MATH_SDCOMP26094_H
 
-#include "src/__support/CPP/Array.h"
+#include "src/__support/CPP/array.h"
 
 #include <stdint.h>
 
 namespace __llvm_libc {
 namespace testing {
 
-static constexpr __llvm_libc::cpp::Array<uint32_t, 10> SDCOMP26094_VALUES{
+static constexpr __llvm_libc::cpp::array<uint32_t, 10> SDCOMP26094_VALUES{
     0x46427f1b, 0x4647e568, 0x46428bac, 0x4647f1f9, 0x4647fe8a,
     0x45d8d7f1, 0x45d371a4, 0x45ce0b57, 0x45d35882, 0x45cdf235,
 };
diff --git a/test/src/math/sincosf_test.cpp b/test/src/math/sincosf_test.cpp
index dfd86eb..f23d719 100644
--- a/test/src/math/sincosf_test.cpp
+++ b/test/src/math/sincosf_test.cpp
@@ -6,7 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/CPP/Array.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/math/sincosf.h"
 #include "test/src/math/sdcomp26094.h"
diff --git a/test/src/math/sinf_test.cpp b/test/src/math/sinf_test.cpp
index 40dcc4d..7defafa 100644
--- a/test/src/math/sinf_test.cpp
+++ b/test/src/math/sinf_test.cpp
@@ -6,7 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/CPP/Array.h"
 #include "src/__support/FPUtil/FPBits.h"
 #include "src/math/sinf.h"
 #include "test/src/math/sdcomp26094.h"
diff --git a/test/src/stdlib/atexit_test.cpp b/test/src/stdlib/atexit_test.cpp
index 877222f..11ab2fa 100644
--- a/test/src/stdlib/atexit_test.cpp
+++ b/test/src/stdlib/atexit_test.cpp
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/CPP/Array.h"
 #include "src/__support/CPP/Utility.h"
+#include "src/__support/CPP/array.h"
 #include "src/stdlib/atexit.h"
 #include "src/stdlib/exit.h"
 #include "utils/UnitTest/Test.h"
@@ -40,7 +40,7 @@
 }
 
 static int size;
-static __llvm_libc::cpp::Array<int, 256> arr;
+static __llvm_libc::cpp::array<int, 256> arr;
 
 template <int... Ts>
 void register_atexit_handlers(__llvm_libc::cpp::IntegerSequence<int, Ts...>) {
diff --git a/test/src/string/bzero_test.cpp b/test/src/string/bzero_test.cpp
index f8edfa5..beecf48 100644
--- a/test/src/string/bzero_test.cpp
+++ b/test/src/string/bzero_test.cpp
@@ -10,9 +10,9 @@
 #include "src/string/bzero.h"
 #include "utils/UnitTest/Test.h"
 
-using __llvm_libc::cpp::Array;
+using __llvm_libc::cpp::array;
 using __llvm_libc::cpp::ArrayRef;
-using Data = Array<char, 2048>;
+using Data = array<char, 2048>;
 
 static const ArrayRef<char> k_deadcode("DEADC0DE", 8);
 
diff --git a/test/src/string/memcpy_test.cpp b/test/src/string/memcpy_test.cpp
index ed4bbd4..875927b 100644
--- a/test/src/string/memcpy_test.cpp
+++ b/test/src/string/memcpy_test.cpp
@@ -10,9 +10,9 @@
 #include "src/string/memcpy.h"
 #include "utils/UnitTest/Test.h"
 
-using __llvm_libc::cpp::Array;
+using __llvm_libc::cpp::array;
 using __llvm_libc::cpp::ArrayRef;
-using Data = Array<char, 2048>;
+using Data = array<char, 2048>;
 
 static const ArrayRef<char> k_numbers("0123456789", 10);
 static const ArrayRef<char> k_deadcode("DEADC0DE", 8);
diff --git a/test/src/string/memmove_test.cpp b/test/src/string/memmove_test.cpp
index cacd2bf..0b753cd 100644
--- a/test/src/string/memmove_test.cpp
+++ b/test/src/string/memmove_test.cpp
@@ -11,7 +11,7 @@
 #include "utils/UnitTest/MemoryMatcher.h"
 #include "utils/UnitTest/Test.h"
 
-using __llvm_libc::cpp::Array;
+using __llvm_libc::cpp::array;
 using __llvm_libc::cpp::ArrayRef;
 using __llvm_libc::cpp::MutableArrayRef;
 
@@ -92,7 +92,7 @@
 }
 
 TEST(LlvmLibcMemmoveTest, Thorough) {
-  using LargeBuffer = Array<char, 3 * kMaxSize>;
+  using LargeBuffer = array<char, 3 * kMaxSize>;
   LargeBuffer GroundTruth;
   Randomize(GroundTruth);
   for (int Size = 0; Size < kMaxSize; ++Size) {
diff --git a/test/src/string/memory_utils/algorithm_test.cpp b/test/src/string/memory_utils/algorithm_test.cpp
index 3c6303a..d973fbc 100644
--- a/test/src/string/memory_utils/algorithm_test.cpp
+++ b/test/src/string/memory_utils/algorithm_test.cpp
@@ -2,7 +2,7 @@
 #define LLVM_LIBC_USE_BUILTIN_MEMSET_INLINE 0
 
 #include "utils/UnitTest/Test.h"
-#include <src/__support/CPP/Array.h>
+#include <src/__support/CPP/array.h>
 #include <src/string/memory_utils/algorithm.h>
 #include <src/string/memory_utils/backends.h>
 
@@ -10,7 +10,7 @@
 
 namespace __llvm_libc {
 
-struct alignas(64) Buffer : cpp::Array<char, 128> {
+struct alignas(64) Buffer : cpp::array<char, 128> {
   bool contains(const char *ptr) const {
     return ptr >= data() && ptr < (data() + size());
   }
diff --git a/test/src/string/memory_utils/backend_test.cpp b/test/src/string/memory_utils/backend_test.cpp
index f4ffe9c..2ce0d17 100644
--- a/test/src/string/memory_utils/backend_test.cpp
+++ b/test/src/string/memory_utils/backend_test.cpp
@@ -6,9 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/CPP/Array.h"
 #include "src/__support/CPP/ArrayRef.h"
 #include "src/__support/CPP/Bit.h"
+#include "src/__support/CPP/array.h"
 #include "src/__support/architectures.h"
 #include "src/string/memory_utils/backends.h"
 #include "utils/UnitTest/Test.h"
@@ -16,7 +16,7 @@
 
 namespace __llvm_libc {
 
-template <size_t Size> using Buffer = cpp::Array<char, Size>;
+template <size_t Size> using Buffer = cpp::array<char, Size>;
 
 static char GetRandomChar() {
   // Implementation of C++ minstd_rand seeded with 123456789.
@@ -84,7 +84,7 @@
     >;
 
 TYPED_TEST(LlvmLibcMemoryBackend, splat, FunctionTypes) {
-  for (auto value : cpp::Array<uint8_t, 3>{0u, 1u, 255u}) {
+  for (auto value : cpp::array<uint8_t, 3>{0u, 1u, 255u}) {
     alignas(64) const auto stored = ParamType::splat(bit_cast<ubyte>(value));
     for (size_t i = 0; i < ParamType::SIZE; ++i)
       EXPECT_EQ(bit_cast<uint8_t>(stored[i]), value);
diff --git a/test/src/string/memory_utils/elements_test.cpp b/test/src/string/memory_utils/elements_test.cpp
index ce9a67d..ef43475 100644
--- a/test/src/string/memory_utils/elements_test.cpp
+++ b/test/src/string/memory_utils/elements_test.cpp
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/CPP/Array.h"
 #include "src/__support/CPP/ArrayRef.h"
+#include "src/__support/CPP/array.h"
 #include "src/string/memory_utils/elements.h"
 #include "utils/UnitTest/Test.h"
 
@@ -56,7 +56,7 @@
     current = GetRandomChar();
 }
 
-template <typename Element> using Buffer = cpp::Array<char, Element::SIZE>;
+template <typename Element> using Buffer = cpp::array<char, Element::SIZE>;
 
 template <typename Element> Buffer<Element> GetRandomBuffer() {
   Buffer<Element> buffer;
@@ -81,7 +81,7 @@
 
 TYPED_TEST(LlvmLibcMemoryElements, Move, FixedSizeTypes) {
   constexpr size_t SIZE = ParamType::SIZE;
-  using LargeBuffer = cpp::Array<char, SIZE * 2>;
+  using LargeBuffer = cpp::array<char, SIZE * 2>;
   LargeBuffer GroundTruth;
   Randomize(GroundTruth);
   // Forward, we move the SIZE first bytes from offset 0 to SIZE.
@@ -126,7 +126,7 @@
 
 TYPED_TEST(LlvmLibcMemoryElements, Splat, FixedSizeTypes) {
   Buffer<ParamType> Dst;
-  const cpp::Array<char, 3> values = {char(0x00), char(0x7F), char(0xFF)};
+  const cpp::array<char, 3> values = {char(0x00), char(0x7F), char(0xFF)};
   for (char value : values) {
     splat_set<ParamType>(Dst.data(), value);
     for (size_t i = 0; i < ParamType::SIZE; ++i)
diff --git a/test/src/string/memory_utils/memory_access_test.cpp b/test/src/string/memory_utils/memory_access_test.cpp
index e107d6f..fe257bd 100644
--- a/test/src/string/memory_utils/memory_access_test.cpp
+++ b/test/src/string/memory_utils/memory_access_test.cpp
@@ -8,8 +8,8 @@
 
 #define LLVM_LIBC_UNITTEST_OBSERVE 1
 
-#include "src/__support/CPP/Array.h"
 #include "src/__support/CPP/ArrayRef.h"
+#include "src/__support/CPP/array.h"
 #include "src/string/memory_utils/elements.h"
 #include "utils/UnitTest/Test.h"
 
@@ -20,7 +20,7 @@
 
 static constexpr const size_t kMaxBuffer = 32;
 
-struct BufferAccess : cpp::Array<char, kMaxBuffer + 1> {
+struct BufferAccess : cpp::array<char, kMaxBuffer + 1> {
   BufferAccess() { Reset(); }
   void Reset() {
     for (auto &value : *this)
@@ -45,7 +45,7 @@
     reads.Reset();
     writes.Reset();
   }
-  cpp::Array<char, kMaxBuffer> data;
+  cpp::array<char, kMaxBuffer> data;
   BufferAccess __attribute__((aligned(64))) reads;
   BufferAccess __attribute__((aligned(64))) writes;
 };
diff --git a/test/src/string/memory_utils/utils_test.cpp b/test/src/string/memory_utils/utils_test.cpp
index 6b9ece4..f76d3a7 100644
--- a/test/src/string/memory_utils/utils_test.cpp
+++ b/test/src/string/memory_utils/utils_test.cpp
@@ -6,14 +6,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/CPP/Array.h"
+#include "src/__support/CPP/array.h"
 #include "src/string/memory_utils/utils.h"
 #include "utils/UnitTest/Test.h"
 
 namespace __llvm_libc {
 
 TEST(LlvmLibcUtilsTest, IsPowerOfTwoOrZero) {
-  static const cpp::Array<bool, 65> kExpectedValues{
+  static const cpp::array<bool, 65> kExpectedValues{
       1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, // 0-15
       1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31
       1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 32-47
@@ -25,7 +25,7 @@
 }
 
 TEST(LlvmLibcUtilsTest, IsPowerOfTwo) {
-  static const cpp::Array<bool, 65> kExpectedValues{
+  static const cpp::array<bool, 65> kExpectedValues{
       0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, // 0-15
       1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16-31
       1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 32-47
@@ -37,7 +37,7 @@
 }
 
 TEST(LlvmLibcUtilsTest, Log2) {
-  static const cpp::Array<size_t, 65> kExpectedValues{
+  static const cpp::array<size_t, 65> kExpectedValues{
       0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, // 0-15
       4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, // 16-31
       5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, // 32-47
@@ -49,7 +49,7 @@
 }
 
 TEST(LlvmLibcUtilsTest, LEPowerOf2) {
-  static const cpp::Array<size_t, 65> kExpectedValues{
+  static const cpp::array<size_t, 65> kExpectedValues{
       0,  1,  2,  2,  4,  4,  4,  4,  8,  8,  8,  8,  8,  8,  8,  8,  // 0-15
       16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, // 16-31
       32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, // 32-47
@@ -61,7 +61,7 @@
 }
 
 TEST(LlvmLibcUtilsTest, GEPowerOf2) {
-  static const cpp::Array<size_t, 66> kExpectedValues{
+  static const cpp::array<size_t, 66> kExpectedValues{
       0,  1,  2,  4,  4,  8,  8,  8,  8,  16, 16, 16, 16, 16, 16, 16, // 0-15
       16, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, // 16-31
       32, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // 32-47
diff --git a/test/src/string/memset_test.cpp b/test/src/string/memset_test.cpp
index 2d07e7b..b09a56a 100644
--- a/test/src/string/memset_test.cpp
+++ b/test/src/string/memset_test.cpp
@@ -10,9 +10,9 @@
 #include "src/string/memset.h"
 #include "utils/UnitTest/Test.h"
 
-using __llvm_libc::cpp::Array;
+using __llvm_libc::cpp::array;
 using __llvm_libc::cpp::ArrayRef;
-using Data = Array<char, 2048>;
+using Data = array<char, 2048>;
 
 static const ArrayRef<char> k_deadcode("DEADC0DE", 8);