[libcxx-commits] [libcxx] dc95245 - [libc++][format] Removes format sources.

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 16 11:31:51 PDT 2023


Author: Mark de Wever
Date: 2023-05-16T20:31:44+02:00
New Revision: dc95245e69a1c1098a744a2c3af83ca48d9ba495

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

LOG: [libc++][format] Removes format sources.

The source file is used to anchor the destructor of format_error. When
format is moved from experimental to stable this code would move to the
dylib. One issue with code in the dylib is that it can't be used in
constexpr context. There is a proposal to make format work during
constant evaluation

  P2758 Emitting messages at compile time

This paper has initially been received favourable by EWG. Therefore move
the code to the header. This also avoids possible availability issues on
Mac back deployment targets.

Note it is expected that format will no longer be experimental with the
next LLVM release.

Reviewed By: ldionne, #libc

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

Added: 
    

Modified: 
    libcxx/CMakeLists.txt
    libcxx/include/__format/format_error.h
    libcxx/src/CMakeLists.txt

Removed: 
    libcxx/src/format.cpp


################################################################################
diff  --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index a003d1e98048c..6e9182390247f 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -763,14 +763,6 @@ function(cxx_add_windows_flags target)
                                  # Use the ISO conforming behaviour for conversion
                                  # in printf, scanf.
                                  _CRT_STDIO_ISO_WIDE_SPECIFIERS)
-    # Clang-cl shared builds don't support the experimental library.
-    # To avoid linker errors the format_error destructor is inlined for the
-    # dylib. Users can never use format in this mode.
-    # TODO FMT Remove when format becomes mainline.
-    if (LIBCXX_ENABLE_SHARED)
-      target_compile_definitions(${target} PRIVATE
-                                 _LIBCPP_INLINE_FORMAT_ERROR_DTOR)
-    endif()
   endif()
 endfunction()
 

diff  --git a/libcxx/include/__format/format_error.h b/libcxx/include/__format/format_error.h
index 5f9b7daf805ea..7fb4dd0d7a47d 100644
--- a/libcxx/include/__format/format_error.h
+++ b/libcxx/include/__format/format_error.h
@@ -22,21 +22,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 #if _LIBCPP_STD_VER >= 20
 
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables")
 class _LIBCPP_EXCEPTION_ABI format_error : public runtime_error {
 public:
   _LIBCPP_HIDE_FROM_ABI explicit format_error(const string& __s)
       : runtime_error(__s) {}
   _LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s)
       : runtime_error(__s) {}
-  // TODO FMT Remove when format is no longer experimental.
-  // Avoids linker errors when building the Clang-cl Windows DLL which doesn't
-  // support the experimental library.
-#  ifndef _LIBCPP_INLINE_FORMAT_ERROR_DTOR
-  ~format_error() noexcept override;
-#  else
-  ~format_error() noexcept  override {}
-#  endif
+  _LIBCPP_HIDE_FROM_ABI_VIRTUAL
+  ~format_error() noexcept override = default;
 };
+_LIBCPP_DIAGNOSTIC_POP
 
 _LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void
 __throw_format_error(const char* __s) {

diff  --git a/libcxx/src/CMakeLists.txt b/libcxx/src/CMakeLists.txt
index 2d04f7704e09d..21cc9a50096c9 100644
--- a/libcxx/src/CMakeLists.txt
+++ b/libcxx/src/CMakeLists.txt
@@ -311,7 +311,6 @@ add_custom_target(cxx DEPENDS ${LIBCXX_BUILD_TARGETS})
 
 set(LIBCXX_EXPERIMENTAL_SOURCES
   experimental/memory_resource.cpp
-  format.cpp
   )
 
 add_library(cxx_experimental STATIC ${LIBCXX_EXPERIMENTAL_SOURCES})

diff  --git a/libcxx/src/format.cpp b/libcxx/src/format.cpp
deleted file mode 100644
index 401cccf17210a..0000000000000
--- a/libcxx/src/format.cpp
+++ /dev/null
@@ -1,17 +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
-//
-//===----------------------------------------------------------------------===//
-
-#include <format>
-
-_LIBCPP_BEGIN_NAMESPACE_STD
-
-#ifndef _LIBCPP_INLINE_FORMAT_ERROR_DTOR
-format_error::~format_error() noexcept = default;
-#endif
-
-_LIBCPP_END_NAMESPACE_STD


        


More information about the libcxx-commits mailing list