[PATCH] [libcxx] Optimize vectors uninitialized construction of trivial types from an iterator range.

Eric Fiselier eric at efcs.ca
Fri Mar 6 11:40:04 PST 2015


================
Comment at: include/vector:1029
@@ -1034,1 +1028,3 @@
+    __alloc_traits::__construct_range_forward(__a, __first, __last, this->__end_);
+    __annotator.__done();
 }
----------------
mclow.lists wrote:
> This is not exception safe.
> If one of the constructions throws, then the ASAN annotations will be wrong.
> 
This actually is exception safe but I had to think about it for a long time before I understood. 

1. `__RAII_IncreaseAnnotate __annotator(*this, __n);`: Unpoison the next __n elements.
2. `__annotator.__done()`. commits to unpoisoning the elements.
3. `~__annotator`: If `__done()` has been called the destructor does nothing. Otherwise it re-poisons everything from __end_ on.

http://reviews.llvm.org/D8109

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list