[libcxx-commits] [libcxx] 13ea134 - [libc++] Make it an error to define _LIBCPP_DEBUG

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Nov 15 06:48:20 PST 2022


Author: Louis Dionne
Date: 2022-11-15T09:48:13-05:00
New Revision: 13ea1343231fa4ae12fe9fba4c789728465783d7

URL: https://github.com/llvm/llvm-project/commit/13ea1343231fa4ae12fe9fba4c789728465783d7
DIFF: https://github.com/llvm/llvm-project/commit/13ea1343231fa4ae12fe9fba4c789728465783d7.diff

LOG: [libc++] Make it an error to define _LIBCPP_DEBUG

We have been transitioning off of that macro since LLVM 15.

Differential Revision: https://reviews.llvm.org/D137975

Added: 
    

Modified: 
    libcxx/docs/ReleaseNotes.rst
    libcxx/include/__assert
    libcxx/include/__debug

Removed: 
    libcxx/test/libcxx/assertions/debug_mode_compatibility.pass.cpp
    libcxx/test/libcxx/debug/debug.catch-legacy-macro.verify.cpp


################################################################################
diff  --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst
index abcebeb01ebe..584eed4c7ab7 100644
--- a/libcxx/docs/ReleaseNotes.rst
+++ b/libcxx/docs/ReleaseNotes.rst
@@ -97,6 +97,9 @@ Deprecations and Removals
   Please migrate to ``<memory_resource>`` instead. Per libc++'s TS deprecation policy,
   ``<experimental/memory_resource>`` will be removed in LLVM 18.
 
+- The ``_LIBCPP_DEBUG`` macro is not honored anymore, and it is an error to try to use it. Please migrate to
+  ``_LIBCPP_ENABLE_DEBUG_MODE`` instead.
+
 Upcoming Deprecations and Removals
 ----------------------------------
 

diff  --git a/libcxx/include/__assert b/libcxx/include/__assert
index 87556085eabb..afe7304d0308 100644
--- a/libcxx/include/__assert
+++ b/libcxx/include/__assert
@@ -17,13 +17,9 @@
 #  pragma GCC system_header
 #endif
 
-// This is for backwards compatibility with code that might have been enabling
-// assertions through the Debug mode previously.
-// TODO: In LLVM 16, make it an error to define _LIBCPP_DEBUG
+// TODO: Remove in LLVM 17.
 #if defined(_LIBCPP_DEBUG)
-# ifndef _LIBCPP_ENABLE_ASSERTIONS
-#   define _LIBCPP_ENABLE_ASSERTIONS 1
-# endif
+#   error "Defining _LIBCPP_DEBUG is not supported anymore. Please use _LIBCPP_ENABLE_DEBUG_MODE instead."
 #endif
 
 // Automatically enable assertions when the debug mode is enabled.

diff  --git a/libcxx/include/__debug b/libcxx/include/__debug
index 742384b1515c..088b9557d866 100644
--- a/libcxx/include/__debug
+++ b/libcxx/include/__debug
@@ -19,11 +19,6 @@
 #  pragma GCC system_header
 #endif
 
-// Catch invalid uses of the legacy _LIBCPP_DEBUG toggle.
-#if defined(_LIBCPP_DEBUG) && _LIBCPP_DEBUG != 0 && !defined(_LIBCPP_ENABLE_DEBUG_MODE)
-#   error "Enabling the debug mode now requires having configured the library with support for the debug mode"
-#endif
-
 #if defined(_LIBCPP_ENABLE_DEBUG_MODE) && !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY)
 # define _LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY
 #endif

diff  --git a/libcxx/test/libcxx/assertions/debug_mode_compatibility.pass.cpp b/libcxx/test/libcxx/assertions/debug_mode_compatibility.pass.cpp
deleted file mode 100644
index fe7f0389de91..000000000000
--- a/libcxx/test/libcxx/assertions/debug_mode_compatibility.pass.cpp
+++ /dev/null
@@ -1,28 +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 ensures that assertions are still enabled when _LIBCPP_DEBUG=0 is
-// defined, for backwards compatibility with code that might have been using
-// it to enable assertions previously.
-
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
-
-// We flag uses of the assertion handler in older dylibs at compile-time to avoid runtime
-// failures when back-deploying.
-// XFAIL: use_system_cxx_lib && target={{.+}}-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}}
-
-#include <cstdlib>
-
-void std::__libcpp_verbose_abort(char const*, ...) {
-  std::exit(EXIT_SUCCESS);
-}
-
-int main(int, char**) {
-  _LIBCPP_ASSERT(false, "message");
-  return EXIT_FAILURE;
-}

diff  --git a/libcxx/test/libcxx/debug/debug.catch-legacy-macro.verify.cpp b/libcxx/test/libcxx/debug/debug.catch-legacy-macro.verify.cpp
deleted file mode 100644
index ac265c99ced6..000000000000
--- a/libcxx/test/libcxx/debug/debug.catch-legacy-macro.verify.cpp
+++ /dev/null
@@ -1,21 +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 ensures that we issue an error if we try to enable the debug mode with
-// a library that was not built with support for the debug mode.
-
-// REQUIRES: !libcpp-has-debug-mode
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
-
-// This test fails when modules are enabled because we fail to build module 'std' instead of
-// issuing the preprocessor error.
-// UNSUPPORTED: modules-build
-
-#include <__debug>
-
-// expected-error@*:* {{Enabling the debug mode now requires having configured the library with support for the debug mode}}


        


More information about the libcxx-commits mailing list