summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers/sequences/vector
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-03-10 00:25:20 +0000
committerEric Fiselier <eric@efcs.ca>2015-03-10 00:25:20 +0000
commit21d7ffa233807fd1c0ce3fb0b9fb864e07872473 (patch)
treec3f7cf83bb5a4f547d23026f8ca05133d49a4828 /libcxx/test/std/containers/sequences/vector
parent2708e52029451d9337106cbcad2e12225af1219b (diff)
downloadbcm5719-llvm-21d7ffa233807fd1c0ce3fb0b9fb864e07872473.tar.gz
bcm5719-llvm-21d7ffa233807fd1c0ce3fb0b9fb864e07872473.zip
[libcxx] Fix __RAII_IncreaseAnnotator for increases >= 1
Summary: Fix suggested by @mclow.lists on D8109. Store the size of the un-poisoned vector upon construction instead of calculating it later. Reviewers: titus, mclow.lists, kcc, EricWF Reviewed By: EricWF Subscribers: mclow.lists, cfe-commits Differential Revision: http://reviews.llvm.org/D8172 llvm-svn: 231729
Diffstat (limited to 'libcxx/test/std/containers/sequences/vector')
-rw-r--r--libcxx/test/std/containers/sequences/vector/asan_throw.pass.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/sequences/vector/asan_throw.pass.cpp b/libcxx/test/std/containers/sequences/vector/asan_throw.pass.cpp
index a1dce4a3b44..c100da1aade 100644
--- a/libcxx/test/std/containers/sequences/vector/asan_throw.pass.cpp
+++ b/libcxx/test/std/containers/sequences/vector/asan_throw.pass.cpp
@@ -37,6 +37,22 @@ private:
char a;
};
+class ThrowOnCopy {
+public:
+ ThrowOnCopy() : should_throw(false) {}
+ explicit ThrowOnCopy(bool should_throw) : should_throw(should_throw) {}
+
+ ThrowOnCopy(ThrowOnCopy const & other)
+ : should_throw(other.should_throw)
+ {
+ if (should_throw) {
+ throw 0;
+ }
+ }
+
+ bool should_throw;
+};
+
void test_push_back() {
std::vector<X> v;
v.reserve(2);
@@ -157,6 +173,23 @@ void test_insert_n() {
assert(0);
}
+
+void test_insert_n2() {
+ std::vector<ThrowOnCopy> v(10);
+ v.reserve(100);
+ assert(v.size() == 10);
+ v[6].should_throw = true;
+ try {
+ v.insert(v.cbegin(), 5, ThrowOnCopy());
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 11);
+ assert(is_contiguous_container_asan_correct(v));
+ return;
+ }
+ assert(0);
+}
+
void test_resize() {
std::vector<X> v;
v.reserve(3);
@@ -193,6 +226,7 @@ int main() {
test_emplace();
test_insert_range2();
test_insert_n();
+ test_insert_n2();
test_resize();
test_resize_param();
}
OpenPOWER on IntegriCloud