[PATCH] D133598: [lld] Use std::size instead of llvm::array_lengthof
Joe Loser via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 9 11:44:19 PDT 2022
jloser created this revision.
jloser added reviewers: MaskRay, kazu, dblaikie.
Herald added a subscriber: StephenFan.
Herald added a project: All.
jloser requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D133598
Files:
lld/COFF/Chunks.cpp
Index: lld/COFF/Chunks.cpp
===================================================================
--- lld/COFF/Chunks.cpp
+++ lld/COFF/Chunks.cpp
@@ -20,6 +20,7 @@
#include "llvm/Support/Endian.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
+#include <iterator>
using namespace llvm;
using namespace llvm::object;
@@ -947,7 +948,7 @@
void MergeChunk::addSection(COFFLinkerContext &ctx, SectionChunk *c) {
assert(isPowerOf2_32(c->getAlignment()));
uint8_t p2Align = llvm::Log2_32(c->getAlignment());
- assert(p2Align < array_lengthof(ctx.mergeChunkInstances));
+ assert(p2Align < std::size(ctx.mergeChunkInstances));
auto *&mc = ctx.mergeChunkInstances[p2Align];
if (!mc)
mc = make<MergeChunk>(c->getAlignment());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133598.459150.patch
Type: text/x-patch
Size: 752 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220909/4c00c53f/attachment.bin>
More information about the llvm-commits
mailing list