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/lib/Support/X86TargetParser.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/lib/Support/X86TargetParser.cpp')
-rw-r--r-- | llvm/lib/Support/X86TargetParser.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/Support/X86TargetParser.cpp b/llvm/lib/Support/X86TargetParser.cpp index bb62102..1f72f58 100644 --- a/llvm/lib/Support/X86TargetParser.cpp +++ b/llvm/lib/Support/X86TargetParser.cpp @@ -54,7 +54,7 @@ public: } constexpr FeatureBitset &operator&=(const FeatureBitset &RHS) { - for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I) { + for (unsigned I = 0, E = std::size(Bits); I != E; ++I) { // GCC <6.2 crashes if this is written in a single statement. uint32_t NewBits = Bits[I] & RHS.Bits[I]; Bits[I] = NewBits; @@ -63,7 +63,7 @@ public: } constexpr FeatureBitset &operator|=(const FeatureBitset &RHS) { - for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I) { + for (unsigned I = 0, E = std::size(Bits); I != E; ++I) { // GCC <6.2 crashes if this is written in a single statement. uint32_t NewBits = Bits[I] | RHS.Bits[I]; Bits[I] = NewBits; @@ -74,7 +74,7 @@ public: // gcc 5.3 miscompiles this if we try to write this using operator&=. constexpr FeatureBitset operator&(const FeatureBitset &RHS) const { FeatureBitset Result; - for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I) + for (unsigned I = 0, E = std::size(Bits); I != E; ++I) Result.Bits[I] = Bits[I] & RHS.Bits[I]; return Result; } @@ -82,20 +82,20 @@ public: // gcc 5.3 miscompiles this if we try to write this using operator&=. constexpr FeatureBitset operator|(const FeatureBitset &RHS) const { FeatureBitset Result; - for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I) + for (unsigned I = 0, E = std::size(Bits); I != E; ++I) Result.Bits[I] = Bits[I] | RHS.Bits[I]; return Result; } constexpr FeatureBitset operator~() const { FeatureBitset Result; - for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I) + for (unsigned I = 0, E = std::size(Bits); I != E; ++I) Result.Bits[I] = ~Bits[I]; return Result; } constexpr bool operator!=(const FeatureBitset &RHS) const { - for (unsigned I = 0, E = array_lengthof(Bits); I != E; ++I) + for (unsigned I = 0, E = std::size(Bits); I != E; ++I) if (Bits[I] != RHS.Bits[I]) return true; return false; @@ -692,7 +692,7 @@ unsigned llvm::X86::getFeaturePriority(ProcessorFeatures Feat) { #include "llvm/Support/X86TargetParser.def" std::numeric_limits<unsigned>::max() // Need to consume last comma. }; - std::array<unsigned, array_lengthof(Priorities) - 1> HelperList; + std::array<unsigned, std::size(Priorities) - 1> HelperList; std::iota(HelperList.begin(), HelperList.end(), 0); assert(std::is_permutation(HelperList.begin(), HelperList.end(), std::begin(Priorities), |