[libcxx-commits] [libcxx] [libc++] Remove _LIBCPP_USING_IF_EXISTS from fundamental aliases (PR #107220)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed Sep 4 04:06:22 PDT 2024


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/107220


There are a few types without which the library is hopelessly broken. Specifically, these are `size_t`, `ptrdiff_t` and the `intX_t` and `uintX_t` types. This results in significantly better diagnostics if they are missing, since they are flagged at the `using` instead of the inevitable first use.



>From 4c1dc3f00b65ba4d26818908e6dadd2986085847 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Wed, 4 Sep 2024 13:03:58 +0200
Subject: [PATCH] [libc++] Remove _LIBCPP_USING_IF_EXISTS from fundamental
 aliases

---
 libcxx/include/cstddef |  4 ++--
 libcxx/include/cstdint | 18 +++++++++---------
 libcxx/include/cstdio  |  2 +-
 libcxx/include/cstdlib |  2 +-
 libcxx/include/cstring |  2 +-
 libcxx/include/ctime   |  2 +-
 libcxx/include/cuchar  |  2 +-
 libcxx/include/cwchar  |  2 +-
 8 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/libcxx/include/cstddef b/libcxx/include/cstddef
index 592f6261a6de3f..223eab878050e9 100644
--- a/libcxx/include/cstddef
+++ b/libcxx/include/cstddef
@@ -56,8 +56,8 @@ Types:
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::nullptr_t;
-using ::ptrdiff_t _LIBCPP_USING_IF_EXISTS;
-using ::size_t _LIBCPP_USING_IF_EXISTS;
+using ::ptrdiff_t;
+using ::size_t;
 
 #if !defined(_LIBCPP_CXX03_LANG)
 using ::max_align_t _LIBCPP_USING_IF_EXISTS;
diff --git a/libcxx/include/cstdint b/libcxx/include/cstdint
index 8c4782859426dd..88f6f901f9fd09 100644
--- a/libcxx/include/cstdint
+++ b/libcxx/include/cstdint
@@ -158,15 +158,15 @@ Types:
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-using ::int8_t _LIBCPP_USING_IF_EXISTS;
-using ::int16_t _LIBCPP_USING_IF_EXISTS;
-using ::int32_t _LIBCPP_USING_IF_EXISTS;
-using ::int64_t _LIBCPP_USING_IF_EXISTS;
-
-using ::uint8_t _LIBCPP_USING_IF_EXISTS;
-using ::uint16_t _LIBCPP_USING_IF_EXISTS;
-using ::uint32_t _LIBCPP_USING_IF_EXISTS;
-using ::uint64_t _LIBCPP_USING_IF_EXISTS;
+using ::int8_t;
+using ::int16_t;
+using ::int32_t;
+using ::int64_t;
+
+using ::uint8_t;
+using ::uint16_t;
+using ::uint32_t;
+using ::uint64_t;
 
 using ::int_least8_t _LIBCPP_USING_IF_EXISTS;
 using ::int_least16_t _LIBCPP_USING_IF_EXISTS;
diff --git a/libcxx/include/cstdio b/libcxx/include/cstdio
index 7f94371081f8b1..633773e63e5de1 100644
--- a/libcxx/include/cstdio
+++ b/libcxx/include/cstdio
@@ -115,7 +115,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::FILE _LIBCPP_USING_IF_EXISTS;
 using ::fpos_t _LIBCPP_USING_IF_EXISTS;
-using ::size_t _LIBCPP_USING_IF_EXISTS;
+using ::size_t;
 
 using ::fclose _LIBCPP_USING_IF_EXISTS;
 using ::fflush _LIBCPP_USING_IF_EXISTS;
diff --git a/libcxx/include/cstdlib b/libcxx/include/cstdlib
index c817fd8f4accda..e57a54e38a97f8 100644
--- a/libcxx/include/cstdlib
+++ b/libcxx/include/cstdlib
@@ -99,7 +99,7 @@ void *aligned_alloc(size_t alignment, size_t size);                       // C11
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-using ::size_t _LIBCPP_USING_IF_EXISTS;
+using ::size_t;
 using ::div_t _LIBCPP_USING_IF_EXISTS;
 using ::ldiv_t _LIBCPP_USING_IF_EXISTS;
 using ::lldiv_t _LIBCPP_USING_IF_EXISTS;
diff --git a/libcxx/include/cstring b/libcxx/include/cstring
index c2c92b02e73cc1..268ec1e8fabd8a 100644
--- a/libcxx/include/cstring
+++ b/libcxx/include/cstring
@@ -75,7 +75,7 @@ size_t strlen(const char* s);
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-using ::size_t _LIBCPP_USING_IF_EXISTS;
+using ::size_t;
 using ::memcpy _LIBCPP_USING_IF_EXISTS;
 using ::memmove _LIBCPP_USING_IF_EXISTS;
 using ::strcpy _LIBCPP_USING_IF_EXISTS;
diff --git a/libcxx/include/ctime b/libcxx/include/ctime
index f47b49a43e23ef..b1124ad0eb489d 100644
--- a/libcxx/include/ctime
+++ b/libcxx/include/ctime
@@ -62,7 +62,7 @@ int timespec_get( struct timespec *ts, int base); // C++17
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::clock_t _LIBCPP_USING_IF_EXISTS;
-using ::size_t _LIBCPP_USING_IF_EXISTS;
+using ::size_t;
 using ::time_t _LIBCPP_USING_IF_EXISTS;
 using ::tm _LIBCPP_USING_IF_EXISTS;
 #if _LIBCPP_STD_VER >= 17
diff --git a/libcxx/include/cuchar b/libcxx/include/cuchar
index f0015be275367d..9ffc5548c1c7f4 100644
--- a/libcxx/include/cuchar
+++ b/libcxx/include/cuchar
@@ -57,7 +57,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 #if !defined(_LIBCPP_CXX03_LANG)
 
 using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
-using ::size_t _LIBCPP_USING_IF_EXISTS;
+using ::size_t;
 
 #  if !defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8)
 using ::mbrtoc8 _LIBCPP_USING_IF_EXISTS;
diff --git a/libcxx/include/cwchar b/libcxx/include/cwchar
index 08cfac58c846ac..9bbb19d5f00f35 100644
--- a/libcxx/include/cwchar
+++ b/libcxx/include/cwchar
@@ -127,7 +127,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
-using ::size_t _LIBCPP_USING_IF_EXISTS;
+using ::size_t;
 using ::tm _LIBCPP_USING_IF_EXISTS;
 using ::wint_t _LIBCPP_USING_IF_EXISTS;
 using ::FILE _LIBCPP_USING_IF_EXISTS;



More information about the libcxx-commits mailing list