[PATCH] back() and pop_back() in InternalVector
Sergey Matveev
earthdok at google.com
Tue Mar 5 02:37:29 PST 2013
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D493.1.patch
Type: text/x-patch
Size: 945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130305/24611821/attachment.bin>
More information about the llvm-commits
mailing list