Author: Louis Dionne
Date: 2022-02-15T15:50:01-05:00
New Revision: 2fc17e919f0cc6d6ca7ce189f0dc0c7bd82344c2

URL: 
https://github.com/llvm/llvm-project/commit/2fc17e919f0cc6d6ca7ce189f0dc0c7bd82344c2
DIFF: 
https://github.com/llvm/llvm-project/commit/2fc17e919f0cc6d6ca7ce189f0dc0c7bd82344c2.diff

LOG: [libc++] Temporarily silence failing debug mode test

Also, fix the actual code so that the test would pass if we fixed the
issue that the method is instantiated in the dylib, and hence the debug
assertion will never fire except if the debug mode is enabled when the
dylib is being compiled.

(cherry picked from commit 5c53afe5aac0d295a9345cd439c6caf3ac5eb8ba)

Added: 
    

Modified: 
    libcxx/include/string
    
libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/include/string b/libcxx/include/string
index 01cff902e07db..fd6a7424c815f 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -2897,6 +2897,10 @@ template <class _CharT, class _Traits, class _Allocator>
 typename basic_string<_CharT, _Traits, _Allocator>::iterator
 basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, 
value_type __c)
 {
+    _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
+                         "string::insert(iterator, character) called with an 
iterator not"
+                         " referring to this string");
+
     size_type __ip = static_cast<size_type>(__pos - begin());
     size_type __sz = size();
     size_type __cap = capacity();

diff  --git 
a/libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp
 
b/libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp
index c6a81ebfa65ae..ac05b69cf5561 100644
--- 
a/libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp
+++ 
b/libcxx/test/libcxx/strings/basic.string/string.modifiers/insert_iter_char_db1.pass.cpp
@@ -14,6 +14,12 @@
 
 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
 
+// TODO: Since string::insert(iter, char) is intantiated in the dylib, this 
test doesn't
+//       actually work if the dylib hasn't been built with debug assertions 
enabled.
+//       Until we overhaul the debug mode, mark this test as unsupported to 
avoid
+//       spurious CI failures.
+// REQUIRES: never-run
+
 #include <string>
 
 #include "test_macros.h"
@@ -24,7 +30,8 @@ int main(int, char**)
     typedef std::string S;
     S s;
     S s2;
-    TEST_LIBCPP_ASSERT_FAILURE(s.insert(s2.begin(), '1'), "Attempted to 
subtract incompatible iterators");
+    TEST_LIBCPP_ASSERT_FAILURE(s.insert(s2.begin(), '1'),
+        "string::insert(iterator, character) called with an iterator not 
referring to this string");
 
     return 0;
 }


        
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to