[llvm] [libc] [libc][NFC] Remove named_pair (PR #73952)

via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 30 07:20:25 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Guillaume Chatelet (gchatelet)

<details>
<summary>Changes</summary>



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


5 Files Affected:

- (modified) libc/src/__support/CMakeLists.txt (-8) 
- (modified) libc/src/__support/math_extras.h (+8-3) 
- (removed) libc/src/__support/named_pair.h (-18) 
- (modified) libc/src/__support/number_pair.h (+4-2) 
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (-7) 


``````````diff
diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt
index a76b22960f5a504..d41a9339b17a9df 100644
--- a/libc/src/__support/CMakeLists.txt
+++ b/libc/src/__support/CMakeLists.txt
@@ -10,12 +10,6 @@ add_header_library(
     libc.src.__support.CPP.new
 )
 
-add_header_library(
-  named_pair
-  HDRS
-    named_pair.h
-)
-
 add_header_library(
   common
   HDRS
@@ -40,7 +34,6 @@ add_header_library(
   HDRS
     math_extras.h
   DEPENDS
-    .named_pair
     libc.src.__support.CPP.type_traits
     libc.src.__support.macros.attributes
     libc.src.__support.macros.config
@@ -185,7 +178,6 @@ add_header_library(
   HDRS
     number_pair.h
   DEPENDS
-    .named_pair
     libc.src.__support.CPP.type_traits
 )
 
diff --git a/libc/src/__support/math_extras.h b/libc/src/__support/math_extras.h
index cc22aa49d02601b..860cdda8586d1ea 100644
--- a/libc/src/__support/math_extras.h
+++ b/libc/src/__support/math_extras.h
@@ -10,7 +10,6 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_EXTRAS_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_EXTRAS_H
 
-#include "named_pair.h"
 #include "src/__support/CPP/type_traits.h"
 #include "src/__support/macros/attributes.h" // LIBC_INLINE
 #include "src/__support/macros/config.h"     // LIBC_HAS_BUILTIN
@@ -18,7 +17,10 @@
 namespace LIBC_NAMESPACE {
 
 // Add with carry
-DEFINE_NAMED_PAIR_TEMPLATE(SumCarry, sum, carry);
+template <typename T> struct SumCarry {
+  T sum;
+  T carry;
+};
 
 // This version is always valid for constexpr.
 template <typename T>
@@ -91,7 +93,10 @@ add_with_carry<unsigned long long>(unsigned long long a, unsigned long long b,
 #endif // LIBC_HAS_BUILTIN(__builtin_addc)
 
 // Subtract with borrow
-DEFINE_NAMED_PAIR_TEMPLATE(DiffBorrow, diff, borrow);
+template <typename T> struct DiffBorrow {
+  T diff;
+  T borrow;
+};
 
 // This version is always valid for constexpr.
 template <typename T>
diff --git a/libc/src/__support/named_pair.h b/libc/src/__support/named_pair.h
deleted file mode 100644
index bd7dccf9810c7f7..000000000000000
--- a/libc/src/__support/named_pair.h
+++ /dev/null
@@ -1,18 +0,0 @@
-//===-- Utilities for pairs of numbers. -------------------------*- 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 LLVM_LIBC_SRC___SUPPORT_NAMED_PAIR_H
-#define LLVM_LIBC_SRC___SUPPORT_NAMED_PAIR_H
-
-#define DEFINE_NAMED_PAIR_TEMPLATE(Name, FirstField, SecondField)              \
-  template <typename T1, typename T2 = T1> struct Name {                       \
-    T1 FirstField;                                                             \
-    T2 SecondField;                                                            \
-  }
-
-#endif // LLVM_LIBC_SRC___SUPPORT_NAMED_PAIR_H
diff --git a/libc/src/__support/number_pair.h b/libc/src/__support/number_pair.h
index 5e553d817994b4b..12e730836af2c67 100644
--- a/libc/src/__support/number_pair.h
+++ b/libc/src/__support/number_pair.h
@@ -10,13 +10,15 @@
 #define LLVM_LIBC_SRC___SUPPORT_NUMBER_PAIR_H
 
 #include "CPP/type_traits.h"
-#include "named_pair.h"
 
 #include <stddef.h>
 
 namespace LIBC_NAMESPACE {
 
-DEFINE_NAMED_PAIR_TEMPLATE(NumberPair, lo, hi);
+template <typename T> struct NumberPair {
+  T lo;
+  T hi;
+};
 
 template <typename T>
 cpp::enable_if_t<cpp::is_integral_v<T> && cpp::is_unsigned_v<T>, NumberPair<T>>
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index a0a6a4366ea7537..2f9f5a4f90efc00 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -431,7 +431,6 @@ libc_support_library(
     hdrs = ["src/__support/number_pair.h"],
     deps = [
         ":__support_cpp_type_traits",
-        ":__support_named_pair",
     ],
 )
 
@@ -587,11 +586,6 @@ libc_support_library(
     ],
 )
 
-libc_support_library(
-    name = "__support_named_pair",
-    hdrs = ["src/__support/named_pair.h"],
-)
-
 libc_support_library(
     name = "__support_bit",
     hdrs = ["src/__support/bit.h"],
@@ -608,7 +602,6 @@ libc_support_library(
         ":__support_cpp_type_traits",
         ":__support_macros_attributes",
         ":__support_macros_config",
-        ":__support_named_pair",
     ],
 )
 

``````````

</details>


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


More information about the llvm-commits mailing list