[libcxx-commits] [PATCH] D91708: [libcxx] Add some missing _VSTD:: to <vector>, with a regression test.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 18 06:45:31 PST 2020


Quuxplusone created this revision.
Quuxplusone added a reviewer: ldionne.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
Quuxplusone requested review of this revision.

This is cleanup after d9a4f936d05 <https://reviews.llvm.org/rGd9a4f936d05c1e8740f5f73da1b149c36d25d02c>.
Relevant blog post: https://quuxplusone.github.io/blog/2019/09/26/uglification-doesnt-stop-adl/


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91708

Files:
  libcxx/include/vector
  libcxx/test/libcxx/containers/sequences/vector/robust_against_adl.pass.cpp


Index: libcxx/test/libcxx/containers/sequences/vector/robust_against_adl.pass.cpp
===================================================================
--- /dev/null
+++ libcxx/test/libcxx/containers/sequences/vector/robust_against_adl.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+#include <vector>
+
+#include "test_macros.h"
+
+template<class T, class AdlTrap>
+struct MyAlloc {
+    using value_type = T;
+    T *allocate(int n) { return std::allocator<T>().allocate(n); }
+    void deallocate(T *p, int n) { return std::allocator<T>().deallocate(p, n); }
+};
+
+struct Incomplete;
+template<class T> struct Holder { T t; };
+template<class T> using A = MyAlloc<T, Holder<Incomplete>>;
+
+int main(int, char**)
+{
+    std::vector<int, A<int>> v;
+    v.push_back(1);
+    v.insert(v.end(), 3);
+    v.insert(v.begin()+1, 2);
+    v.pop_back();
+    v.erase(v.begin());
+    v.erase(v.begin(), v.end());
+    return 0;
+}
Index: libcxx/include/vector
===================================================================
--- libcxx/include/vector
+++ libcxx/include/vector
@@ -951,7 +951,7 @@
 {
 
     __annotate_delete();
-    __construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, this->__end_, __v.__begin_);
+    _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, this->__end_, __v.__begin_);
     _VSTD::swap(this->__begin_, __v.__begin_);
     _VSTD::swap(this->__end_, __v.__end_);
     _VSTD::swap(this->__end_cap(), __v.__end_cap());
@@ -966,8 +966,8 @@
 {
     __annotate_delete();
     pointer __r = __v.__begin_;
-    __construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, __p, __v.__begin_);
-    __construct_forward_with_exception_guarantees(this->__alloc(), __p, this->__end_, __v.__end_);
+    _VSTD::__construct_backward_with_exception_guarantees(this->__alloc(), this->__begin_, __p, __v.__begin_);
+    _VSTD::__construct_forward_with_exception_guarantees(this->__alloc(), __p, this->__end_, __v.__end_);
     _VSTD::swap(this->__begin_, __v.__begin_);
     _VSTD::swap(this->__end_, __v.__end_);
     _VSTD::swap(this->__end_cap(), __v.__end_cap());
@@ -1074,7 +1074,7 @@
 vector<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardIterator __last, size_type __n)
 {
     _ConstructTransaction __tx(*this, __n);
-    __construct_range_forward(this->__alloc(), __first, __last, __tx.__pos_);
+    _VSTD::__construct_range_forward(this->__alloc(), __first, __last, __tx.__pos_);
 }
 
 //  Default constructs __n objects starting at __end_


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91708.306093.patch
Type: text/x-patch
Size: 2937 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201118/4379f91e/attachment.bin>


More information about the libcxx-commits mailing list