This is an archive of the discontinued LLVM Phabricator instance.

Update {Small}BitVector size_type definition
ClosedPublic

Authored by rengolin on Aug 18 2021, 4:19 AM.

Details

Summary

SmallBitVector implements a level of indirection over BitVector by
storing a smaller bit-vector in a pointer-sized element, or in case the
number of elements exceeds the bucket size, it creates a new pointer to
a BitVector and uses that as its storage.

However, the functions returning the vector size were using unsigned,
which is ok for BitVector, but not for SmallBitVector, which is actually
uintptr_t.

This commit reuses the size_type definition to more than just count
and propagates them into range iteration, size calculation, etc.

This is a continuation of D108124.

I haven't changed all occurrences of unsigned or uintptr_t to
size_type, just those that were directly related.

Diff Detail

Event Timeline

rengolin created this revision.Aug 18 2021, 4:19 AM
rengolin requested review of this revision.Aug 18 2021, 4:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2021, 4:19 AM
rengolin updated this revision to Diff 367175.Aug 18 2021, 4:21 AM
rengolin edited the summary of this revision. (Show Details)
rengolin updated this revision to Diff 367194.Aug 18 2021, 6:20 AM

Update with clang-format and clang-tidy hints.

The last clang-tidy warning (capacity_in_bytes) is pertinent but not for this patch.

A code grep on the whole of LLVM shows that it's never used internally, but both DenseMap and SmallVector have the same interface (although, neither use it externally either).

Clang only seems to use llvm::capacity_in_bytes (defined in Support/Capacity.h), so the public API of these containers can change independently.

In theory, we could change all of them to fit the standard, but given that this isn't the review that looks at that, and we were accidentally touching that code, I'll leave it for another commit.

LGTM, thanks for the code cleaning!

This revision is now accepted and ready to land.Aug 18 2021, 2:29 PM
This revision was landed with ongoing or failed builds.Aug 19 2021, 3:13 AM
This revision was automatically updated to reflect the committed changes.