]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdbsupport: assume that compiler supports std::{is_trivially_constructible,is_trivial...
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 21 Feb 2024 16:46:52 +0000 (11:46 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Wed, 21 Feb 2024 18:30:19 +0000 (13:30 -0500)
This code was there to support g++ 4, which didn't support
std::is_trivially_constructible and std::is_trivially_copyable.  Since
we now require g++ >= 9, I think it's fair to assume that GDB will
always be compiled with a compiler that supports those.

Change-Id: Ie7c1649139a2f48bf662cac92d7f3e38fb1f1ba1

gdb/trad-frame.c
gdb/unittests/array-view-selftests.c
gdb/unittests/enum-flags-selftests.c
gdb/unittests/packed-selftests.c
gdbsupport/check-defines.el
gdbsupport/packed.h
gdbsupport/poison.h
gdbsupport/traits.h

index 8b63927b133c610798062fdd980c1b5d55a44fde..c35e08ab28050e11ed2d1da02f744092e10e4637 100644 (file)
@@ -61,9 +61,7 @@ trad_frame_reset_saved_regs (struct gdbarch *gdbarch,
 trad_frame_saved_reg *
 trad_frame_alloc_saved_regs (struct gdbarch *gdbarch)
 {
-#ifdef HAVE_IS_TRIVIALLY_CONSTRUCTIBLE
   static_assert (std::is_trivially_constructible<trad_frame_saved_reg>::value);
-#endif
 
   int numregs = gdbarch_num_cooked_regs (gdbarch);
   trad_frame_saved_reg *this_saved_regs
index 9d2448fefc1035956e0f110bb872b3224a4255a8..299318ace434488028bb51b7c54370c7c767d438 100644 (file)
@@ -30,15 +30,11 @@ namespace array_view_tests {
 #define CHECK_TRAIT(TRAIT)                     \
   static_assert (std::TRAIT<gdb::array_view<gdb_byte>>::value, "")
 
-#if HAVE_IS_TRIVIALLY_COPYABLE
-
 CHECK_TRAIT (is_trivially_copyable);
 CHECK_TRAIT (is_trivially_move_assignable);
 CHECK_TRAIT (is_trivially_move_constructible);
 CHECK_TRAIT (is_trivially_destructible);
 
-#endif
-
 #undef CHECK_TRAIT
 
 /* Wrapper around std::is_convertible to make the code using it a bit
index 607b8ac66a6463f60c298fd133aea5943337e4e6..54e168173de6f5505e8b63b38c95a210a55aa0a7 100644 (file)
@@ -63,14 +63,10 @@ DEF_ENUM_FLAGS_TYPE (RE, EF);
 DEF_ENUM_FLAGS_TYPE (RE2, EF2);
 DEF_ENUM_FLAGS_TYPE (URE, UEF);
 
-#if HAVE_IS_TRIVIALLY_COPYABLE
-
 /* So that std::vectors of types that have enum_flags fields can
    reallocate efficiently memcpy.  */
 static_assert (std::is_trivially_copyable<EF>::value);
 
-#endif
-
 /* A couple globals used as lvalues in the CHECK_VALID expressions
    below.  Their names (and types) match the uppercase type names
    exposed by CHECK_VALID just to make the expressions easier to
index 3f20861ad4a244bbd9b00d683d85052b09bcce6c..852a7d364ce9f79ec64568398f7fcd9ea4ddc465 100644 (file)
@@ -46,16 +46,12 @@ static_assert (alignof (packed<test_enum, 4>) == 1);
 #define CHECK_TRAIT(TRAIT)                     \
   static_assert (std::TRAIT<packed<test_enum, 1>>::value, "")
 
-#if HAVE_IS_TRIVIALLY_COPYABLE
-
 CHECK_TRAIT (is_trivially_copyable);
 CHECK_TRAIT (is_trivially_copy_constructible);
 CHECK_TRAIT (is_trivially_move_constructible);
 CHECK_TRAIT (is_trivially_copy_assignable);
 CHECK_TRAIT (is_trivially_move_assignable);
 
-#endif
-
 #undef CHECK_TRAIT
 
 /* Entry point.  */
index 7603effc29de2ecf949752d862fcc2a3ed903c2c..b7cf61ba8599ba37b413dfd05d030457c625797e 100644 (file)
@@ -35,8 +35,6 @@
 (put (intern "HAVE_USEFUL_SBRK") :check-ok t)
 (put (intern "HAVE_SOCKETS") :check-ok t)
 (put (intern "HAVE_F_GETFD") :check-ok t)
-(put (intern "HAVE_IS_TRIVIALLY_COPYABLE") :check-ok t)
-(put (intern "HAVE_IS_TRIVIALLY_CONSTRUCTIBLE") :check-ok t)
 (put (intern "HAVE_DOS_BASED_FILE_SYSTEM") :check-ok t)
 
 (defun check-read-config.in (file)
index 8035535386b0fa7d26a8016c87557835a6aaa848..5c817d4c9ccee7a809d22937cfa8be64f57e4929 100644 (file)
@@ -80,9 +80,7 @@ public:
     static_assert (alignof (packed) == 1);
 
     /* Make sure packed can be wrapped with std::atomic.  */
-#if HAVE_IS_TRIVIALLY_COPYABLE
     static_assert (std::is_trivially_copyable<packed>::value);
-#endif
     static_assert (std::is_copy_constructible<packed>::value);
     static_assert (std::is_move_constructible<packed>::value);
     static_assert (std::is_copy_assignable<packed>::value);
index 0d0159eb7f8145f27bb277c9f9b795da460bb72c..7b4f8e8a178d074d8f849d61db7322239dc9a533 100644 (file)
@@ -56,8 +56,6 @@ template <typename T,
          typename = gdb::Requires<gdb::Not<IsMemsettable<T>>>>
 void *memset (T *s, int c, size_t n) = delete;
 
-#if HAVE_IS_TRIVIALLY_COPYABLE
-
 /* Similarly, poison memcpy and memmove of non trivially-copyable
    types, which is undefined.  */
 
@@ -83,17 +81,11 @@ template <typename D, typename S,
          typename = gdb::Requires<gdb::Not<BothAreRelocatable<D, S>>>>
 void *memmove (D *dest, const S *src, size_t n) = delete;
 
-#endif /* HAVE_IS_TRIVIALLY_COPYABLE */
-
 /* Poison XNEW and friends to catch usages of malloc-style allocations on
    objects that require new/delete.  */
 
 template<typename T>
-#if HAVE_IS_TRIVIALLY_CONSTRUCTIBLE
 using IsMallocable = std::is_trivially_constructible<T>;
-#else
-using IsMallocable = std::true_type;
-#endif
 
 template<typename T>
 using IsFreeable = gdb::Or<std::is_trivially_destructible<T>, std::is_void<T>>;
index eb97b96599048e3a75c3df2c9ef867cb11de03f4..92fe59f34af726de5c389c8d2de87b0873f81f86 100644 (file)
 
 #include <type_traits>
 
-/* GCC does not understand __has_feature.  */
-#if !defined(__has_feature)
-# define __has_feature(x) 0
-#endif
-
-/* HAVE_IS_TRIVIALLY_COPYABLE is defined as 1 iff
-   std::is_trivially_copyable is available.  GCC only implemented it
-   in GCC 5.  */
-#if (__has_feature(is_trivially_copyable) \
-     || (defined __GNUC__ && __GNUC__ >= 5))
-# define HAVE_IS_TRIVIALLY_COPYABLE 1
-#endif
-
-/* HAVE_IS_TRIVIALLY_CONSTRUCTIBLE is defined as 1 iff
-   std::is_trivially_constructible is available.  GCC only implemented it
-   in GCC 5.  */
-#if (__has_feature(is_trivially_constructible) \
-     || (defined __GNUC__ && __GNUC__ >= 5))
-# define HAVE_IS_TRIVIALLY_CONSTRUCTIBLE 1
-#endif
-
 namespace gdb {
 
 /* Implementation of the detection idiom: