-
Notifications
You must be signed in to change notification settings - Fork 12.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc++] Refactor tests for hijacked address operator in vector #117457
Open
ldionne
wants to merge
1
commit into
llvm:main
Choose a base branch
from
ldionne:review/refactor-tests-operators
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+47
−281
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
llvmbot
added
the
libc++
libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
label
Nov 24, 2024
@llvm/pr-subscribers-libcxx Author: Louis Dionne (ldionne) ChangesFull diff: https://github.com/llvm/llvm-project/pull/117457.diff 12 Files Affected:
diff --git a/libcxx/test/std/containers/sequences/vector/addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/addressof.compile.pass.cpp
new file mode 100644
index 00000000000000..120b7b289af93e
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/addressof.compile.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03 && !stdlib=libc++
+
+// <vector>
+
+// Validate various member functions of std::vector with an ADL-hijacking operator&
+
+#include <vector>
+#include <utility>
+
+#include "operator_hijacker.h"
+#include "test_iterators.h"
+
+using Vector = std::vector<operator_hijacker>;
+
+void test(
+ Vector v, Vector::const_iterator it, cpp17_input_iterator<operator_hijacker*> other_it, operator_hijacker val) {
+ // emplace / insert
+ v.emplace(it);
+ v.insert(it, it, it);
+ v.insert(it, other_it, other_it);
+ v.insert(it, operator_hijacker());
+ v.insert(it, 1, val);
+ v.insert(it, val);
+
+ // erase
+ v.erase(it);
+ v.erase(it, it);
+
+ // assignment
+ v = static_cast<Vector&>(v);
+ v = std::move(v);
+
+ // construction
+ { Vector v2(std::move(v)); }
+ { Vector v2(std::move(v), std::allocator<operator_hijacker>()); }
+
+ // swap
+ v.swap(v);
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.addressof.compile.pass.cpp
deleted file mode 100644
index ceecdfda3fa304..00000000000000
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.addressof.compile.pass.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// vector& operator=(const vector& c);
-
-// Validate whether the container can be copy-assigned with an ADL-hijacking operator&
-
-#include <vector>
-
-#include "test_macros.h"
-#include "operator_hijacker.h"
-
-void test() {
- std::vector<operator_hijacker> vo;
- std::vector<operator_hijacker> v;
- v = vo;
-}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.addressof.compile.pass.cpp
deleted file mode 100644
index 2008c8d048f4b4..00000000000000
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.addressof.compile.pass.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// vector& operator=(vector&& c);
-
-// Validate whether the container can be copy-assigned with an ADL-hijacking operator&
-
-#include <vector>
-#include <utility>
-
-#include "test_macros.h"
-#include "operator_hijacker.h"
-
-void test() {
- std::vector<operator_hijacker> vo;
- std::vector<operator_hijacker> v;
- v = std::move(vo);
-}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/move.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/move.addressof.compile.pass.cpp
deleted file mode 100644
index 521b8705d49202..00000000000000
--- a/libcxx/test/std/containers/sequences/vector/vector.cons/move.addressof.compile.pass.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++03 && !stdlib=libc++
-
-// <vector>
-
-// vector(vector&& c);
-
-// Validate whether the container can be copy-assigned with an ADL-hijacking operator&
-
-#include <vector>
-#include <utility>
-
-#include "test_macros.h"
-#include "operator_hijacker.h"
-
-void test() {
- {
- std::vector<operator_hijacker> vo;
- std::vector<operator_hijacker> v(std::move(vo));
- }
- {
- std::vector<operator_hijacker> vo;
- std::vector<operator_hijacker> v(std::move(vo), std::allocator<operator_hijacker>());
- }
-}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.addressof.compile.pass.cpp
deleted file mode 100644
index 43e553e71e7414..00000000000000
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.addressof.compile.pass.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++03 && !stdlib=libc++
-
-// <vector>
-
-// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
-
-// Validate whether the container can be copy-assigned with an ADL-hijacking operator&
-
-#include <vector>
-
-#include "test_macros.h"
-#include "operator_hijacker.h"
-
-void test() {
- std::vector<operator_hijacker> v;
- v.emplace(v.end());
-}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.addressof.compile.pass.cpp
deleted file mode 100644
index 0fce3498fec7e8..00000000000000
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.addressof.compile.pass.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// iterator erase(const_iterator position);
-
-// Validate whether the container can be copy-assigned with an ADL-hijacking operator&
-
-#include <vector>
-
-#include "test_macros.h"
-#include "operator_hijacker.h"
-
-void test() {
- std::vector<operator_hijacker> v;
- v.erase(v.end());
-}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.addressof.compile.pass.cpp
deleted file mode 100644
index bc90fa783e98f5..00000000000000
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.addressof.compile.pass.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// iterator erase(const_iterator position);
-
-// Validate whether the container can be copy-assigned with an ADL-hijacking operator&
-
-#include <vector>
-
-#include "test_macros.h"
-#include "operator_hijacker.h"
-
-void test() {
- std::vector<operator_hijacker> v;
- v.erase(v.begin(), v.end());
-}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.addressof.compile.pass.cpp
deleted file mode 100644
index f8311090b37e3c..00000000000000
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.addressof.compile.pass.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class Iter>
-// iterator insert(const_iterator position, Iter first, Iter last);
-
-// Validate whether the container can be copy-assigned with an ADL-hijacking operator&
-
-#include <vector>
-
-#include "test_macros.h"
-#include "operator_hijacker.h"
-#include "test_iterators.h"
-
-void test(cpp17_input_iterator<operator_hijacker*> i) {
- {
- std::vector<operator_hijacker> v;
- v.insert(v.end(), i, i);
- }
- {
- std::vector<operator_hijacker> v;
- v.insert(v.end(), v.begin(), v.end());
- }
-}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.addressof.compile.pass.cpp
deleted file mode 100644
index 11f24604eeac4d..00000000000000
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.addressof.compile.pass.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-// UNSUPPORTED: c++03 && !stdlib=libc++
-
-// <vector>
-
-// iterator insert(const_iterator position, value_type&& x);
-
-// Validate whether the container can be copy-assigned with an ADL-hijacking operator&
-
-#include <vector>
-
-#include "test_macros.h"
-#include "operator_hijacker.h"
-
-void test() {
- std::vector<operator_hijacker> v;
- v.insert(v.end(), operator_hijacker());
-}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.addressof.compile.pass.cpp
deleted file mode 100644
index c02b92a4998e85..00000000000000
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.addressof.compile.pass.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// iterator insert(const_iterator position, size_type n, const value_type& x);
-
-// Validate whether the container can be copy-assigned with an ADL-hijacking operator&
-
-#include <vector>
-
-#include "test_macros.h"
-#include "operator_hijacker.h"
-
-void test() {
- std::vector<operator_hijacker> v;
- operator_hijacker val;
- v.insert(v.end(), 1, val);
-}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.addressof.compile.pass.cpp
deleted file mode 100644
index fbf1a4f50b974f..00000000000000
--- a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.addressof.compile.pass.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// iterator insert(const_iterator position, const value_type& x);
-
-// Validate whether the container can be copy-assigned with an ADL-hijacking operator&
-
-#include <vector>
-
-#include "test_macros.h"
-#include "operator_hijacker.h"
-
-void test() {
- std::vector<operator_hijacker> v;
- operator_hijacker val;
- v.insert(v.end(), val);
-}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.special/swap.addressof.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.special/swap.addressof.compile.pass.cpp
deleted file mode 100644
index 4e908d9ff6eaca..00000000000000
--- a/libcxx/test/std/containers/sequences/vector/vector.special/swap.addressof.compile.pass.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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>
-
-// template <class T, class Alloc>
-// void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
-
-// Validate whether the container can be copy-assigned with an ADL-hijacking operator&
-
-#include <vector>
-
-#include "test_macros.h"
-#include "operator_hijacker.h"
-
-void test() {
- std::vector<operator_hijacker> vo;
- std::vector<operator_hijacker> v;
- v.swap(vo);
-}
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.