[libcxx-commits] [libcxx] [libc++][hardening] Clean up some legacy debug mode tests: (PR #71016)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Nov 1 21:24:13 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libcxx

Author: Konstantin Varlamov (var-const)

<details>
<summary>Changes</summary>

- reenable a few tests that still pass under the new debug mode;
- delete a placeholder test;
- delete a test that is no longer relevant.


---
Full diff: https://github.com/llvm/llvm-project/pull/71016.diff


6 Files Affected:

- (modified) libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp (+2-2) 
- (modified) libcxx/test/libcxx/algorithms/debug_less.pass.cpp (+2-2) 
- (modified) libcxx/test/libcxx/algorithms/debug_three_way_comp.inconsistent.pass.cpp (+2-1) 
- (removed) libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp (-60) 
- (removed) libcxx/test/libcxx/debug/extern-templates.sh.cpp (-52) 
- (modified) libcxx/test/libcxx/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/debug.deallocate.pass.cpp (+2-2) 


``````````diff
diff --git a/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp b/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp
index f58250a2c855fba..701edd1335afa84 100644
--- a/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/debug_less.inconsistent.pass.cpp
@@ -12,8 +12,8 @@
 
 // Make sure __debug_less asserts when the comparator is not consistent.
 
-// REQUIRES: has-unix-headers
-// UNSUPPORTED: !libcpp-has-legacy-debug-mode, c++03
+// REQUIRES: has-unix-headers, libcpp-hardening-mode=debug
+// UNSUPPORTED: c++03
 
 #include <algorithm>
 #include <iterator>
diff --git a/libcxx/test/libcxx/algorithms/debug_less.pass.cpp b/libcxx/test/libcxx/algorithms/debug_less.pass.cpp
index d05cbfac4b8f6a2..4889f94d170a16d 100644
--- a/libcxx/test/libcxx/algorithms/debug_less.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/debug_less.pass.cpp
@@ -12,8 +12,8 @@
 
 // __debug_less checks that a comparator actually provides a strict-weak ordering.
 
-// REQUIRES: has-unix-headers
-// UNSUPPORTED: !libcpp-has-legacy-debug-mode, c++03
+// REQUIRES: has-unix-headers, libcpp-hardening-mode=debug
+// UNSUPPORTED: c++03
 
 #include <algorithm>
 #include <cassert>
diff --git a/libcxx/test/libcxx/algorithms/debug_three_way_comp.inconsistent.pass.cpp b/libcxx/test/libcxx/algorithms/debug_three_way_comp.inconsistent.pass.cpp
index 8a9943693d8a30a..b9bb1c9136f65ce 100644
--- a/libcxx/test/libcxx/algorithms/debug_three_way_comp.inconsistent.pass.cpp
+++ b/libcxx/test/libcxx/algorithms/debug_three_way_comp.inconsistent.pass.cpp
@@ -12,7 +12,8 @@
 
 // Make sure __debug_three_way_comp asserts when the comparator is not consistent.
 
-// UNSUPPORTED: !libcpp-has-legacy-debug-mode, c++03, c++11, c++14, c++17
+// REQUIRES: libcpp-hardening-mode=debug
+// UNSUPPORTED: c++03, c++11, c++14, c++17
 
 #include <algorithm>
 #include <iterator>
diff --git a/libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp b/libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp
deleted file mode 100644
index 449e0244b272495..000000000000000
--- a/libcxx/test/libcxx/debug/containers/associative_containers.pass.cpp
+++ /dev/null
@@ -1,60 +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
-//
-//===----------------------------------------------------------------------===//
-
-// REQUIRES: has-unix-headers
-// UNSUPPORTED: !libcpp-has-legacy-debug-mode, c++03, c++11, c++14
-
-// test container debugging
-
-#include <map>
-#include <set>
-#include <utility>
-#include <cassert>
-#include "check_assertion.h"
-#include "container_debug_tests.h"
-#include "test_macros.h"
-
-using namespace IteratorDebugChecks;
-
-template <class Container, ContainerType CT>
-struct AssociativeContainerChecks : BasicContainerChecks<Container, CT> {
-  using Base = BasicContainerChecks<Container, CT>;
-  using value_type = typename Container::value_type;
-  using iterator = typename Container::iterator;
-  using const_iterator = typename Container::const_iterator;
-  using traits = std::iterator_traits<iterator>;
-  using category = typename traits::iterator_category;
-
-  using Base::makeContainer;
-public:
-  static void run() {
-    Base::run();
-  }
-
-private:
-  // FIXME Add tests here
-};
-
-int main(int, char**)
-{
-  using SetAlloc = test_allocator<int>;
-  using MapAlloc = test_allocator<std::pair<const int, int>>;
-  // FIXME: Add debug mode to these containers
-  if ((false)) {
-    AssociativeContainerChecks<
-        std::set<int, std::less<int>, SetAlloc>, CT_Set>::run();
-    AssociativeContainerChecks<
-        std::multiset<int, std::less<int>, SetAlloc>, CT_MultiSet>::run();
-    AssociativeContainerChecks<
-        std::map<int, int, std::less<int>, MapAlloc>, CT_Map>::run();
-    AssociativeContainerChecks<
-        std::multimap<int, int, std::less<int>, MapAlloc>, CT_MultiMap>::run();
-  }
-
-  return 0;
-}
diff --git a/libcxx/test/libcxx/debug/extern-templates.sh.cpp b/libcxx/test/libcxx/debug/extern-templates.sh.cpp
deleted file mode 100644
index 88c009337055c22..000000000000000
--- a/libcxx/test/libcxx/debug/extern-templates.sh.cpp
+++ /dev/null
@@ -1,52 +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
-//
-//===----------------------------------------------------------------------===//
-
-// This test checks that we retain extern template instantiation declarations
-// for members of <locale> even when the debug mode is enabled, which is
-// necessary for correctness. See https://llvm.org/D94718 for details.
-
-// UNSUPPORTED: !libcpp-has-legacy-debug-mode
-// UNSUPPORTED: no-localization
-// UNSUPPORTED: cant-build-shared-library
-
-// This test relies on linking a shared library and then passing that shared
-// library as input when linking an executable; this is generally not supported
-// on Windows (GNU ld supports it, but MS link.exe and LLD don't) - one has to
-// use an import library instead. (Additionally, the test uses the -fPIC
-// option which clang doesn't accept on Windows.)
-// UNSUPPORTED: windows
-
-// RUN: %{cxx} %{flags} %{compile_flags} %s %{link_flags} -fPIC -DTU1 -fvisibility=hidden -shared -o %t.lib
-// RUN: cd %T && %{cxx} %{flags} %{compile_flags} %s ./%basename_t.tmp.lib %{link_flags} -DTU2 -fvisibility=hidden -o %t.exe
-// RUN: %{exec} %t.exe
-
-#include <cassert>
-#include <cstdio>
-#include <sstream>
-#include <string>
-
-std::string __attribute__((visibility("default"))) numToString(int x);
-
-#if defined(TU1)
-
-std::string numToString(int x) {
-  std::stringstream ss;
-  ss << x;
-  return ss.str();
-}
-
-#elif defined(TU2)
-
-int main(int, char**) {
-  std::string s = numToString(42);
-  assert(s == "42");
-
-  return 0;
-}
-
-#endif
diff --git a/libcxx/test/libcxx/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/debug.deallocate.pass.cpp b/libcxx/test/libcxx/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/debug.deallocate.pass.cpp
index 6e70d171cb3ef15..305b06295bc44ae 100644
--- a/libcxx/test/libcxx/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/debug.deallocate.pass.cpp
+++ b/libcxx/test/libcxx/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/debug.deallocate.pass.cpp
@@ -6,8 +6,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: !libcpp-has-legacy-debug-mode, c++03, c++11, c++14
-// REQUIRES: has-unix-headers
+// UNSUPPORTED: c++03, c++11, c++14
+// REQUIRES: has-unix-headers, libcpp-hardening-mode=debug
 
 // <memory_resource>
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/71016


More information about the libcxx-commits mailing list