Fix the remaining clang-tidy warnings.

This introduces a new `address_t` type and two new casts: `pointer_cast`
and `address_cast` for casting between an `address_t` and a pointer.
These should make it easier to audit the codebase for casts between
pointers and integers.  In particular, the remaining `reinterpret_cast`s
and `pointer_cast`s should be the only places where we could perform
invalid pointer arithmetic.

Also adds a `pointer_offset` helper that adds an offset (in bytes) to a
pointer, preserving its original type.  This is a sufficiently common
pattern that it seemed worthwhile to centralise it.
This commit is contained in:
David Chisnall
2019-04-29 13:37:05 +01:00
parent 4bafca9be7
commit 28fac4d700
12 changed files with 128 additions and 77 deletions

View File

@@ -19,7 +19,7 @@ namespace snmalloc
sizeof(AllocPool) == sizeof(Parent),
"You cannot add fields to this class.");
// This cast is safe due to the static assert.
return (AllocPool*)Parent::make(mp);
return static_cast<AllocPool*>(Parent::make(mp));
}
static AllocPool* make() noexcept