diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-01-13 19:02:22 -0800 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-01-13 19:04:20 -0800 |
commit | 56d1ffb927d03958a7a31442596df749264a7792 (patch) | |
tree | c714e15c06c15db6e0ef3620a71a970984dc48e2 /llvm/unittests/ADT/SmallVectorTest.cpp | |
parent | b196dc6607233d6235846b4a1bde70a6e0cc8512 (diff) | |
download | llvm-56d1ffb927d03958a7a31442596df749264a7792.zip llvm-56d1ffb927d03958a7a31442596df749264a7792.tar.gz llvm-56d1ffb927d03958a7a31442596df749264a7792.tar.bz2 |
Revert "ADT: Fix reference invalidation in SmallVector::push_back and single-element insert"
This reverts commit 9abac60309006db00eca0af406c2e16bef26807c since there
are some bot errors on Windows:
http://lab.llvm.org:8011/#/builders/127/builds/4489
```
FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/IntervalMap.cpp.obj
C:\PROGRA~2\MIB055~1\2017\PROFES~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\cl.exe /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib\Support -IC:\b\slave\sanitizer-windows\llvm-project\llvm\lib\Support -Iinclude -IC:\b\slave\sanitizer-windows\llvm-project\llvm\include /DWIN32 /D_WINDOWS /Zc:inline /Zc:__cplusplus /Zi /Zc:strictStrings /Oi /Zc:rvalueCast /bigobj /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd4324 -w14062 -we4238 /Gw /MD /O2 /Ob2 -UNDEBUG -std:c++14 /EHs-c- /GR- /showIncludes /Folib\Support\CMakeFiles\LLVMSupport.dir\IntervalMap.cpp.obj /Fdlib\Support\CMakeFiles\LLVMSupport.dir\LLVMSupport.pdb /FS -c C:\b\slave\sanitizer-windows\llvm-project\llvm\lib\Support\IntervalMap.cpp
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(746): error C2672: 'llvm::SmallVectorImpl<T>::insert_one_maybe_copy': no matching overloaded function found
with
[
T=llvm::IntervalMapImpl::Path::Entry
]
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(745): note: while compiling class template member function 'llvm::IntervalMapImpl::Path::Entry *llvm::SmallVectorImpl<T>::insert(llvm::IntervalMapImpl::Path::Entry *,T &&)'
with
[
T=llvm::IntervalMapImpl::Path::Entry
]
C:\b\slave\sanitizer-windows\llvm-project\llvm\lib\Support\IntervalMap.cpp(22): note: see reference to function template instantiation 'llvm::IntervalMapImpl::Path::Entry *llvm::SmallVectorImpl<T>::insert(llvm::IntervalMapImpl::Path::Entry *,T &&)' being compiled
with
[
T=llvm::IntervalMapImpl::Path::Entry
]
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(1136): note: see reference to class template instantiation 'llvm::SmallVectorImpl<T>' being compiled
with
[
T=llvm::IntervalMapImpl::Path::Entry
]
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/IntervalMap.h(790): note: see reference to class template instantiation 'llvm::SmallVector<llvm::IntervalMapImpl::Path::Entry,4>' being compiled
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(746): error C2783: 'llvm::IntervalMapImpl::Path::Entry *llvm::SmallVectorImpl<T>::insert_one_maybe_copy(llvm::IntervalMapImpl::Path::Entry *,ArgType &&)': could not deduce template argument for '__formal'
with
[
T=llvm::IntervalMapImpl::Path::Entry
]
C:\b\slave\sanitizer-windows\llvm-project\llvm\include\llvm/ADT/SmallVector.h(727): note: see declaration of 'llvm::SmallVectorImpl<T>::insert_one_maybe_copy'
with
[
T=llvm::IntervalMapImpl::Path::Entry
]
```
Diffstat (limited to 'llvm/unittests/ADT/SmallVectorTest.cpp')
-rw-r--r-- | llvm/unittests/ADT/SmallVectorTest.cpp | 107 |
1 files changed, 16 insertions, 91 deletions
diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp index c880a6b..d97ab57 100644 --- a/llvm/unittests/ADT/SmallVectorTest.cpp +++ b/llvm/unittests/ADT/SmallVectorTest.cpp @@ -53,7 +53,6 @@ public: Constructable(Constructable && src) : constructed(true) { value = src.value; - src.value = 0; ++numConstructorCalls; ++numMoveConstructorCalls; } @@ -75,7 +74,6 @@ public: Constructable & operator=(Constructable && src) { EXPECT_TRUE(constructed); value = src.value; - src.value = 0; ++numAssignmentCalls; ++numMoveAssignmentCalls; return *this; @@ -1058,16 +1056,11 @@ protected: return N; } - template <class T> static bool isValueType() { - return std::is_same<T, typename VectorT::value_type>::value; - } - void SetUp() override { SmallVectorTestBase::SetUp(); // Fill up the small size so that insertions move the elements. - for (int I = 0, E = NumBuiltinElts(V); I != E; ++I) - V.emplace_back(I + 1); + V.append({0, 0, 0}); } }; @@ -1081,54 +1074,19 @@ TYPED_TEST_CASE(SmallVectorReferenceInvalidationTest, SmallVectorReferenceInvalidationTestTypes); TYPED_TEST(SmallVectorReferenceInvalidationTest, PushBack) { - // Note: setup adds [1, 2, ...] to V until it's at capacity in small mode. auto &V = this->V; - int N = this->NumBuiltinElts(V); - - // Push back a reference to last element when growing from small storage. - V.push_back(V.back()); - EXPECT_EQ(N, V.back()); - - // Check that the old value is still there (not moved away). - EXPECT_EQ(N, V[V.size() - 2]); - - // Fill storage again. - V.back() = V.size(); - while (V.size() < V.capacity()) - V.push_back(V.size() + 1); - - // Push back a reference to last element when growing from large storage. - V.push_back(V.back()); - EXPECT_EQ(int(V.size()) - 1, V.back()); + (void)V; +#if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST + EXPECT_DEATH(V.push_back(V.back()), this->AssertionMessage); +#endif } TYPED_TEST(SmallVectorReferenceInvalidationTest, PushBackMoved) { - // Note: setup adds [1, 2, ...] to V until it's at capacity in small mode. auto &V = this->V; - int N = this->NumBuiltinElts(V); - - // Push back a reference to last element when growing from small storage. - V.push_back(std::move(V.back())); - EXPECT_EQ(N, V.back()); - if (this->template isValueType<Constructable>()) { - // Check that the value was moved (not copied). - EXPECT_EQ(0, V[V.size() - 2]); - } - - // Fill storage again. - V.back() = V.size(); - while (V.size() < V.capacity()) - V.push_back(V.size() + 1); - - // Push back a reference to last element when growing from large storage. - V.push_back(std::move(V.back())); - - // Check the values. - EXPECT_EQ(int(V.size()) - 1, V.back()); - if (this->template isValueType<Constructable>()) { - // Check the value got moved out. - EXPECT_EQ(0, V[V.size() - 2]); - } + (void)V; +#if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST + EXPECT_DEATH(V.push_back(std::move(V.back())), this->AssertionMessage); +#endif } TYPED_TEST(SmallVectorReferenceInvalidationTest, Resize) { @@ -1192,53 +1150,20 @@ TYPED_TEST(SmallVectorReferenceInvalidationTest, AssignRange) { } TYPED_TEST(SmallVectorReferenceInvalidationTest, Insert) { - // Note: setup adds [1, 2, ...] to V until it's at capacity in small mode. auto &V = this->V; (void)V; - - // Insert a reference to the back (not at end() or else insert delegates to - // push_back()), growing out of small mode. Confirm the value was copied out - // (moving out Constructable sets it to 0). - V.insert(V.begin(), V.back()); - EXPECT_EQ(int(V.size() - 1), V.front()); - EXPECT_EQ(int(V.size() - 1), V.back()); - - // Fill up the vector again. - while (V.size() < V.capacity()) - V.push_back(V.size() + 1); - - // Grow again from large storage to large storage. - V.insert(V.begin(), V.back()); - EXPECT_EQ(int(V.size() - 1), V.front()); - EXPECT_EQ(int(V.size() - 1), V.back()); +#if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST + EXPECT_DEATH(V.insert(V.begin(), V.back()), this->AssertionMessage); +#endif } TYPED_TEST(SmallVectorReferenceInvalidationTest, InsertMoved) { - // Note: setup adds [1, 2, ...] to V until it's at capacity in small mode. auto &V = this->V; (void)V; - - // Insert a reference to the back (not at end() or else insert delegates to - // push_back()), growing out of small mode. Confirm the value was copied out - // (moving out Constructable sets it to 0). - V.insert(V.begin(), std::move(V.back())); - EXPECT_EQ(int(V.size() - 1), V.front()); - if (this->template isValueType<Constructable>()) { - // Check the value got moved out. - EXPECT_EQ(0, V.back()); - } - - // Fill up the vector again. - while (V.size() < V.capacity()) - V.push_back(V.size() + 1); - - // Grow again from large storage to large storage. - V.insert(V.begin(), std::move(V.back())); - EXPECT_EQ(int(V.size() - 1), V.front()); - if (this->template isValueType<Constructable>()) { - // Check the value got moved out. - EXPECT_EQ(0, V.back()); - } +#if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST + EXPECT_DEATH(V.insert(V.begin(), std::move(V.back())), + this->AssertionMessage); +#endif } TYPED_TEST(SmallVectorReferenceInvalidationTest, InsertN) { |