[libcxx-commits] [libcxx] f901254 - [libc++] Remove libc++'s own <limits.h> (#65472)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 10 11:06:48 PDT 2023


Author: Louis Dionne
Date: 2023-10-10T11:06:43-07:00
New Revision: f901254341592afeb0eb1bf1307b19b332e6279f

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

LOG: [libc++] Remove libc++'s own <limits.h> (#65472)

We do not define anything beyond the C Library's limits.h, so it
shouldn't be needed. This removes the need for a GCC-specific
workaround, see [1].

[1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107795

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

Added: 
    

Modified: 
    libcxx/include/CMakeLists.txt
    libcxx/include/__std_clang_module
    libcxx/include/climits
    libcxx/include/module.modulemap.in
    libcxx/test/std/depr/depr.c.headers/limits_h.compile.pass.cpp
    libcxx/utils/data/ignore_format.txt

Removed: 
    libcxx/include/limits.h


################################################################################
diff  --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 340353f8ebb41c4..4d98b8eed1afd65 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -954,7 +954,6 @@ set(files
   latch
   libcxx.imp
   limits
-  limits.h
   list
   locale
   locale.h

diff  --git a/libcxx/include/__std_clang_module b/libcxx/include/__std_clang_module
index 4d02336d30b0649..2644ea98b4907f7 100644
--- a/libcxx/include/__std_clang_module
+++ b/libcxx/include/__std_clang_module
@@ -135,7 +135,6 @@
 #if !defined(_LIBCPP_HAS_NO_THREADS)
 #  include <latch>
 #endif
-#include <limits.h>
 #include <limits>
 #include <list>
 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)

diff  --git a/libcxx/include/climits b/libcxx/include/climits
index d773af50d299132..2e8993e4d6a5195 100644
--- a/libcxx/include/climits
+++ b/libcxx/include/climits
@@ -42,14 +42,6 @@ Macros:
 
 #include <limits.h>
 
-#ifndef _LIBCPP_LIMITS_H
-#   error <climits> tried including <limits.h> but didn't find libc++'s <limits.h> header. \
-          This usually means that your header search paths are not configured properly. \
-          The header search paths should contain the C++ Standard Library headers before \
-          any C Standard Library, and you are probably using compiler flags that make that \
-          not be the case.
-#endif
-
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif

diff  --git a/libcxx/include/limits.h b/libcxx/include/limits.h
deleted file mode 100644
index 537a4b1439f9c82..000000000000000
--- a/libcxx/include/limits.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// -*- C++ -*-
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_LIMITS_H
-#define _LIBCPP_LIMITS_H
-
-/*
-    limits.h synopsis
-
-Macros:
-
-    CHAR_BIT
-    SCHAR_MIN
-    SCHAR_MAX
-    UCHAR_MAX
-    CHAR_MIN
-    CHAR_MAX
-    MB_LEN_MAX
-    SHRT_MIN
-    SHRT_MAX
-    USHRT_MAX
-    INT_MIN
-    INT_MAX
-    UINT_MAX
-    LONG_MIN
-    LONG_MAX
-    ULONG_MAX
-    LLONG_MIN   // C99
-    LLONG_MAX   // C99
-    ULLONG_MAX  // C99
-
-*/
-
-#include <__config>
-
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#  pragma GCC system_header
-#endif
-
-#ifdef _LIBCPP_COMPILER_GCC
-
-// GCC header limits.h recursively includes itself through another header called
-// syslimits.h for some reason. This setup breaks down if we directly
-// #include_next GCC's limits.h (reasons not entirely clear to me).
-// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107795 for more details.
-// Therefore, we manually re-create the necessary include sequence below:
-
-// Get the system limits.h defines (force recurse into the next level)
-#define _GCC_LIMITS_H_
-#define _GCC_NEXT_LIMITS_H
-#include_next <limits.h>
-
-// Get the ISO C defines
-#undef _GCC_LIMITS_H_
-#include_next <limits.h>
-
-#else
-
-#  if __has_include_next(<limits.h>)
-#    include_next <limits.h>
-#  endif
-
-#endif // _LIBCPP_COMPILER_GCC
-
-#endif // _LIBCPP_LIMITS_H

diff  --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 26657b78b8440c6..09184af2732c83f 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -448,10 +448,6 @@ module std_inttypes_h [system] {
   export *
 }
 // <iso646.h> provided by compiler.
-module std_limits_h [system] {
-  header "limits.h"
-  export *
-}
 module std_locale_h [system] {
   header "locale.h"
   export *

diff  --git a/libcxx/test/std/depr/depr.c.headers/limits_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/limits_h.compile.pass.cpp
index 4738cc4028cf95c..14fb8b69fac74ce 100644
--- a/libcxx/test/std/depr/depr.c.headers/limits_h.compile.pass.cpp
+++ b/libcxx/test/std/depr/depr.c.headers/limits_h.compile.pass.cpp
@@ -6,7 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 
- // test limits.h
+// test <limits.h>
+//
+// Even though <limits.h> is not provided by libc++, we still test that
+// using it with libc++ on the search path will work.
 
 #include <limits.h>
 

diff  --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt
index 1d0a6b0b7ef5f8f..01038c75f4e1336 100644
--- a/libcxx/utils/data/ignore_format.txt
+++ b/libcxx/utils/data/ignore_format.txt
@@ -291,7 +291,6 @@ libcxx/include/__iterator/unreachable_sentinel.h
 libcxx/include/__iterator/wrap_iter.h
 libcxx/include/latch
 libcxx/include/limits
-libcxx/include/limits.h
 libcxx/include/list
 libcxx/include/__locale
 libcxx/include/locale


        


More information about the libcxx-commits mailing list