[all-commits] [llvm/llvm-project] fa404a: [libc] Enhance ArrayRef + unittests
Guillaume Chatelet via All-commits
all-commits at lists.llvm.org
Wed Apr 21 06:25:58 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: fa404ae43a6f7ed256a47257aeccc760d16dc0c9
https://github.com/llvm/llvm-project/commit/fa404ae43a6f7ed256a47257aeccc760d16dc0c9
Author: Guillaume Chatelet <gchatelet at google.com>
Date: 2021-04-21 (Wed, 21 Apr 2021)
Changed paths:
M libc/test/utils/CPP/CMakeLists.txt
A libc/test/utils/CPP/arrayref_test.cpp
M libc/utils/CPP/ArrayRef.h
Log Message:
-----------
[libc] Enhance ArrayRef + unittests
This patch mostly adds unittests for `ArrayRef` and `MutableArrayRef`, additionnaly:
- We mimic the behavior of `std::vector` and disallow CV qualified type (`ArrayRef<const X>` is not allowed).
This is to make sure that the type traits are always valid (e.g. `value_type`, `pointer`, ...).
- In the previous implementation `ArrayRef` would define `value_type` as `const T` but this is not correct, it should be `T` for both `MutableArrayRef` and `ArrayRef`.
- We add the `equals` method to ease testing,
- We define the constructor taking an `Array` outside of the base implementation to ensure we match `const Array<T>&` and not `Array<const T>&` in the case of `ArrayRef`.
Differential Revision: https://reviews.llvm.org/D100732
More information about the All-commits
mailing list