[PATCH] back() and pop_back() in InternalVector
Alexander Potapenko
glider at google.com
Tue Mar 5 02:59:34 PST 2013
LGTM
On Tue, Mar 5, 2013 at 2:37 PM, Sergey Matveev <earthdok at google.com> wrote:
> Hi glider, samsonov,
>
> add back() and pop_back() to InternalVector in sanitizer_common
>
> http://llvm-reviews.chandlerc.com/D493
>
> Files:
> lib/sanitizer_common/sanitizer_common.h
> lib/sanitizer_common/tests/sanitizer_common_test.cc
>
> Index: lib/sanitizer_common/sanitizer_common.h
> ===================================================================
> --- lib/sanitizer_common/sanitizer_common.h
> +++ lib/sanitizer_common/sanitizer_common.h
> @@ -287,6 +287,14 @@
> }
> data_[size_++] = element;
> }
> + T &back() {
> + CHECK_GT(size_, 0);
> + return data_[size_ - 1];
> + }
> + void pop_back() {
> + CHECK_GT(size_, 0);
> + size_--;
> + }
> uptr size() {
> return size_;
> }
> Index: lib/sanitizer_common/tests/sanitizer_common_test.cc
> ===================================================================
> --- lib/sanitizer_common/tests/sanitizer_common_test.cc
> +++ lib/sanitizer_common/tests/sanitizer_common_test.cc
> @@ -105,6 +105,11 @@
> for (uptr i = 0; i < 100; i++) {
> EXPECT_EQ(vector[i], i);
> }
> + for (int i = 99; i >= 0; i--) {
> + EXPECT_EQ(vector.back(), i);
> + vector.pop_back();
> + EXPECT_EQ(vector.size(), i);
> + }
> }
>
> } // namespace __sanitizer
--
Alexander Potapenko
Software Engineer
Google Moscow
More information about the llvm-commits
mailing list