From b7a37e2860ced1e17ba5e47a63f473863a16c89a Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Thu, 7 Dec 2023 10:04:46 -0800 Subject: [PATCH] Remove dead code. PiperOrigin-RevId: 588828678 --- src/google/protobuf/map.h | 12 ---------- src/google/protobuf/port_def.inc | 38 ------------------------------ src/google/protobuf/port_undef.inc | 3 --- 3 files changed, 53 deletions(-) diff --git a/src/google/protobuf/map.h b/src/google/protobuf/map.h index 30536af831..4ea42241dd 100644 --- a/src/google/protobuf/map.h +++ b/src/google/protobuf/map.h @@ -454,18 +454,6 @@ size_t SpaceUsedInValues(const Map* map) { return size; } -// Multiply two numbers where overflow is expected. -template -N MultiplyWithOverflow(N a, N b) { -#if defined(PROTOBUF_HAS_BUILTIN_MUL_OVERFLOW) - N res; - (void)__builtin_mul_overflow(a, b, &res); - return res; -#else - return a * b; -#endif -} - inline size_t SpaceUsedInValues(const void*) { return 0; } class UntypedMapBase; diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 235644a706..9fdb3ff5c8 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -67,12 +67,6 @@ // - MSVC: https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes-history // https://docs.microsoft.com/en-us/visualstudio/releasenotes/vs2017-relnotes-history -// Portable fallback for Clang's __has_warning macro: -#ifndef __has_warning -#define __has_warning(x) 0 -#define PROTOBUF_has_warning_DEFINED_ -#endif - // Portable PROTOBUF_BUILTIN_BSWAPxx definitions // Code must check for availability, e.g.: `defined(PROTOBUF_BUILTIN_BSWAP32)` #ifdef PROTOBUF_BUILTIN_BSWAP16 @@ -94,11 +88,6 @@ #define PROTOBUF_BUILTIN_BSWAP64(x) __builtin_bswap64(x) #endif -// Portable check for __builtin_mul_overflow. -#if ABSL_HAVE_BUILTIN(__builtin_mul_overflow) -#define PROTOBUF_HAS_BUILTIN_MUL_OVERFLOW 1 -#endif - // Portable check for gcc-style atomic built-ins #if ABSL_HAVE_BUILTIN(__atomic_load_n) #define PROTOBUF_BUILTIN_ATOMIC 1 @@ -512,11 +501,6 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3), #define PROTOBUF_ALIGNAS(byte_alignment) alignas(byte_alignment) #endif -#ifdef PROTOBUF_FINAL -#error PROTOBUF_FINAL was previously defined -#endif -#define PROTOBUF_FINAL final - #ifdef PROTOBUF_THREAD_LOCAL #error PROTOBUF_THREAD_LOCAL was previously defined #endif @@ -579,21 +563,6 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3), #define PROTOBUF_ATTRIBUTE_NO_DESTROY #endif -// Force clang to always emit complete debug info for a type. -// Clang uses constructor homing to determine when to emit debug info for a -// type. If the constructor of a type is never used, which can happen in some -// cases where member variables are constructed in place for optimization -// purposes (see b/208803175 for an example), the type will have incomplete -// debug info unless this attribute is used. -#ifdef PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG -#error PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG was previously defined -#endif -#if ABSL_HAVE_CPP_ATTRIBUTE(clang::standalone_debug) -#define PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG [[clang::standalone_debug]] -#else -#define PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG -#endif - // Protobuf extensions and reflection require registration of the protos linked // in the binary. Not until everything is registered does the runtime have a // complete view on all protos. When code is using reflection or extensions @@ -1070,10 +1039,3 @@ namespace internal { #endif // !NDEBUG #endif // has_builtin(__builtin_assume) -// We don't want code outside port_def doing complex testing, so -// remove our portable condition test macros to nudge folks away from -// using it themselves. -#ifdef PROTOBUF_has_warning_DEFINED_ -# undef __has_warning -# undef PROTOBUF_has_warning_DEFINED_ -#endif diff --git a/src/google/protobuf/port_undef.inc b/src/google/protobuf/port_undef.inc index 70fca1c81d..b64343632a 100644 --- a/src/google/protobuf/port_undef.inc +++ b/src/google/protobuf/port_undef.inc @@ -19,7 +19,6 @@ #undef PROTOBUF_BUILTIN_BSWAP16 #undef PROTOBUF_BUILTIN_BSWAP32 #undef PROTOBUF_BUILTIN_BSWAP64 -#undef PROTOBUF_HAS_BUILTIN_MUL_OVERFLOW #undef PROTOBUF_BUILTIN_ATOMIC #undef PROTOBUF_GNUC_MIN #undef PROTOBUF_CLANG_MIN @@ -58,7 +57,6 @@ #undef PROTOBUF_EXPORT_TEMPLATE_DECLARE #undef PROTOBUF_EXPORT_TEMPLATE_DEFINE #undef PROTOBUF_ALIGNAS -#undef PROTOBUF_FINAL #undef PROTOBUF_THREAD_LOCAL #undef PROTOBUF_CONSTINIT #undef PROTOBUF_CONSTEXPR @@ -66,7 +64,6 @@ #undef PROTOBUF_ATTRIBUTE_WEAK #undef PROTOBUF_HAVE_ATTRIBUTE_WEAK #undef PROTOBUF_ATTRIBUTE_NO_DESTROY -#undef PROTOBUF_ATTRIBUTE_STANDALONE_DEBUG #undef PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 #undef PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 #undef PROTOBUF_PRAGMA_INIT_SEG