about summary refs log tree commit diff
path: root/src/test/ui/thinlto
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2019-06-23 14:26:36 +0200
committerRalf Jung <post@ralfj.de>2019-06-23 15:55:04 +0200
commitc50b9d197f54016714ad45808450e018c2c253b3 (patch)
tree65a6ef56bb3da4b9218d3779aa0a949acc7871da /src/test/ui/thinlto
parent305930cffeac1da0fd73a08d9f5680e4a49bfb9f (diff)
downloadrust-c50b9d197f54016714ad45808450e018c2c253b3.tar.gz
rust-c50b9d197f54016714ad45808450e018c2c253b3.zip
Centralize bounds, alignment and NULL checking for memory accesses in one function: memory.check_ptr_access
That function also takes care of converting a Scalar to a Pointer, should that be needed.  Not all accesses need that though: if the access has size 0, None is returned.
Everyone accessing memory based on a Scalar should use this method to get the Pointer they need.

All operations on the Allocation work on Pointer inputs and expect all the checks to have happened (and will ICE if the bounds are violated).
The operations on Memory work on Scalar inputs and do the checks themselves.

The only other public method to check pointers is memory.ptr_may_be_null, which is needed in a few places.
With this, we can make all the other methods (tests for a pointer being in-bounds and checking alignment) private helper methods, used to implement the two public methods.
That maks the public API surface much easier to use and harder to mis-use.

While I am at it, this also removes the assumption that the vtable part of a `dyn Trait`-fat-pointer is a `Pointer` (as opposed to a pointer cast to an integer, stored as raw bits).
Diffstat (limited to 'src/test/ui/thinlto')
0 files changed, 0 insertions, 0 deletions