[libcxx-commits] [libcxx] bbc6893 - Implement N3644 "Null Forward Pointers" in _LIBCPP_DEBUG mode.
Arthur O'Dwyer via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Apr 23 15:23:13 PDT 2021
Author: Arthur O'Dwyer
Date: 2021-04-23T18:20:39-04:00
New Revision: bbc6893b11cd85147543e84351176da7c3869cc4
URL: https://github.com/llvm/llvm-project/commit/bbc6893b11cd85147543e84351176da7c3869cc4
DIFF: https://github.com/llvm/llvm-project/commit/bbc6893b11cd85147543e84351176da7c3869cc4.diff
LOG: Implement N3644 "Null Forward Pointers" in _LIBCPP_DEBUG mode.
This functionality is tested in std/containers/sequences/vector/iterators.pass.cpp
(and similarly for all containers, but vector is the only one to be tested that
uses debug iterators).
Differential Revision: https://reviews.llvm.org/D100881
Added:
Modified:
libcxx/src/debug.cpp
libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/src/debug.cpp b/libcxx/src/debug.cpp
index 20055fcf7590..dd5963fcce16 100644
--- a/libcxx/src/debug.cpp
+++ b/libcxx/src/debug.cpp
@@ -438,7 +438,7 @@ __libcpp_db::__less_than_comparable(const void* __i, const void* __j) const
__i_node* j = __find_iterator(__j);
__c_node* ci = i != nullptr ? i->__c_ : nullptr;
__c_node* cj = j != nullptr ? j->__c_ : nullptr;
- return ci != nullptr && ci == cj;
+ return ci == cj;
}
void
diff --git a/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp
index fe467116e9a6..4ca75d288dc0 100644
--- a/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp
+++ b/libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp
@@ -22,69 +22,46 @@
#include "test_macros.h"
-int main(int, char**)
+template<class C>
+void test()
{
{ // N3644 testing
- typedef std::string C;
- C::iterator ii1{}, ii2{};
- C::iterator ii4 = ii1;
- C::const_iterator cii{};
+ typename C::iterator ii1{}, ii2{};
+ typename C::iterator ii4 = ii1;
+ typename C::const_iterator cii{};
assert ( ii1 == ii2 );
assert ( ii1 == ii4 );
- assert ( ii1 == cii );
- assert ( !(ii1 != ii2 ));
- assert ( !(ii1 != cii ));
- }
- { // N3644 testing
- typedef std::wstring C;
- C::iterator ii1{}, ii2{};
- C::iterator ii4 = ii1;
- C::const_iterator cii{};
- assert ( ii1 == ii2 );
- assert ( ii1 == ii4 );
- assert ( ii1 == cii );
- assert ( !(ii1 != ii2 ));
- assert ( !(ii1 != cii ));
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ assert (!(ii1 < cii ));
+ assert (!(cii < ii1 ));
+ assert ( (ii1 <= cii ));
+ assert ( (cii <= ii1 ));
+ assert (!(ii1 > cii ));
+ assert (!(cii > ii1 ));
+ assert ( (ii1 >= cii ));
+ assert ( (cii >= ii1 ));
+ assert (cii - ii1 == 0);
+ assert (ii1 - cii == 0);
}
+}
+
+int main(int, char**)
+{
+ test<std::string>();
+ test<std::wstring>();
#if defined(__cpp_lib_char8_t) && __cpp_lib_char8_t >= 201811L
- {
- typedef std::u8string C;
- C::iterator ii1{}, ii2{};
- C::iterator ii4 = ii1;
- C::const_iterator cii{};
- assert ( ii1 == ii2 );
- assert ( ii1 == ii4 );
- assert ( ii1 == cii );
- assert ( !(ii1 != ii2 ));
- assert ( !(ii1 != cii ));
- }
+ test<std::u8string>();
#endif
- { // N3644 testing
- typedef std::u16string C;
- C::iterator ii1{}, ii2{};
- C::iterator ii4 = ii1;
- C::const_iterator cii{};
- assert ( ii1 == ii2 );
- assert ( ii1 == ii4 );
- assert ( ii1 == cii );
- assert ( !(ii1 != ii2 ));
- assert ( !(ii1 != cii ));
- }
-
- { // N3644 testing
- typedef std::u32string C;
- C::iterator ii1{}, ii2{};
- C::iterator ii4 = ii1;
- C::const_iterator cii{};
- assert ( ii1 == ii2 );
- assert ( ii1 == ii4 );
- assert ( ii1 == cii );
- assert ( !(ii1 != ii2 ));
- assert ( !(ii1 != cii ));
- }
+ test<std::u16string>();
+ test<std::u32string>();
- return 0;
+ return 0;
}
More information about the libcxx-commits
mailing list