From 28850292d4397562dde0d108fb848b405c689d76 Mon Sep 17 00:00:00 2001 From: Gil Date: Tue, 6 Feb 2018 09:28:30 -0800 Subject: Update abseil-cpp to a new upstream (#754) Update to bf7fc9986e20f664958fc227547fd8d2fdcf863e --- Firestore/third_party/abseil-cpp/CMakeLists.txt | 48 ++- .../abseil-cpp/absl/base/CMakeLists.txt | 64 +++- .../third_party/abseil-cpp/absl/base/attributes.h | 15 + .../third_party/abseil-cpp/absl/base/config.h | 41 +-- .../abseil-cpp/absl/base/internal/endian.h | 2 + .../abseil-cpp/absl/base/internal/log_severity.h | 52 --- .../abseil-cpp/absl/base/internal/raw_logging.cc | 7 +- .../abseil-cpp/absl/base/internal/raw_logging.h | 2 +- .../absl/base/internal/unaligned_access.h | 2 +- .../abseil-cpp/absl/base/log_severity.h | 61 ++++ .../third_party/abseil-cpp/absl/base/macros.h | 2 +- .../third_party/abseil-cpp/absl/meta/type_traits.h | 66 ++-- .../abseil-cpp/absl/meta/type_traits_test.cc | 369 +++++++++++++++------ .../abseil-cpp/absl/strings/CMakeLists.txt | 5 + .../abseil-cpp/absl/strings/string_view.h | 2 +- .../abseil-cpp/absl/strings/string_view_test.cc | 32 +- 16 files changed, 539 insertions(+), 231 deletions(-) delete mode 100644 Firestore/third_party/abseil-cpp/absl/base/internal/log_severity.h create mode 100644 Firestore/third_party/abseil-cpp/absl/base/log_severity.h (limited to 'Firestore/third_party') diff --git a/Firestore/third_party/abseil-cpp/CMakeLists.txt b/Firestore/third_party/abseil-cpp/CMakeLists.txt index e87f4a8..6d3789e 100644 --- a/Firestore/third_party/abseil-cpp/CMakeLists.txt +++ b/Firestore/third_party/abseil-cpp/CMakeLists.txt @@ -26,7 +26,17 @@ include(AbseilHelpers) # config options -set(ABSL_STD_CXX_FLAG "-std=c++11" CACHE STRING "c++ std flag (default: c++11)") +if (MSVC) + # /wd4005 macro-redefinition + # /wd4068 unknown pragma + # /wd4244 conversion from 'type1' to 'type2' + # /wd4267 conversion from 'size_t' to 'type2' + # /wd4800 force value to bool 'true' or 'false' (performance warning) + add_compile_options(/W3 /WX /wd4005 /wd4068 /wd4244 /wd4267 /wd4800) + add_definitions(/DNOMINMAX /DWIN32_LEAN_AND_MEAN=1 /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS) +else() + set(ABSL_STD_CXX_FLAG "-std=c++11" CACHE STRING "c++ std flag (default: c++11)") +endif() @@ -48,32 +58,34 @@ list(APPEND ABSL_COMMON_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_CXX_FLAGS "${ABSL_STD_CXX_FLAG} ${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_WARNING_VLA} ${CMAKE_CXX_FLAGS} ") +# -fexceptions +set(ABSL_EXCEPTIONS_FLAG "${CMAKE_CXX_EXCEPTIONS}") # find dependencies ## pthread find_package(Threads REQUIRED) +if(NOT ABSL_CCTZ_TARGET) + set(ABSL_CCTZ_TARGET cctz) +endif() + # commented: used only for standalone test #add_subdirectory(cctz) #add_subdirectory(googletest) +check_target(${ABSL_CCTZ_TARGET}) ## check targets -check_target(cctz) -check_target(gtest) -check_target(gtest_main) -check_target(gmock) - -# -fexceptions -set(ABSL_EXCEPTIONS_FLAG "${CMAKE_CXX_EXCEPTIONS}") - -# fix stuff -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FIX_MSVC} ${CMAKE_CXX_FLAGS}") - -list(APPEND ABSL_TEST_COMMON_LIBRARIES - gtest_main - gtest - gmock - ${CMAKE_THREAD_LIBS_INIT} -) +if(BUILD_TESTING) + check_target(gtest) + check_target(gtest_main) + check_target(gmock) + + list(APPEND ABSL_TEST_COMMON_LIBRARIES + gtest_main + gtest + gmock + ${CMAKE_THREAD_LIBS_INIT} + ) +endif() add_subdirectory(absl) diff --git a/Firestore/third_party/abseil-cpp/absl/base/CMakeLists.txt b/Firestore/third_party/abseil-cpp/absl/base/CMakeLists.txt index 3e94d51..4b7b53a 100644 --- a/Firestore/third_party/abseil-cpp/absl/base/CMakeLists.txt +++ b/Firestore/third_party/abseil-cpp/absl/base/CMakeLists.txt @@ -20,6 +20,7 @@ list(APPEND BASE_PUBLIC_HEADERS "casts.h" "config.h" "dynamic_annotations.h" + "log_severity.h" "macros.h" "optimization.h" "policy_checks.h" @@ -33,17 +34,18 @@ list(APPEND BASE_INTERNAL_HEADERS "internal/cycleclock.h" "internal/endian.h" "internal/exception_testing.h" + "internal/exception_safety_testing.h" "internal/identity.h" "internal/invoke.h" - "internal/log_severity.h" + "internal/inline_variable.h" "internal/low_level_alloc.h" "internal/low_level_scheduling.h" - "internal/malloc_extension_c.h" "internal/malloc_extension.h" "internal/malloc_hook_c.h" "internal/malloc_hook.h" "internal/malloc_hook_invoke.h" "internal/per_thread_tls.h" + "internal/pretty_function.h" "internal/raw_logging.h" "internal/scheduling_mode.h" "internal/spinlock.h" @@ -58,7 +60,7 @@ list(APPEND BASE_INTERNAL_HEADERS # absl_base main library -list(APPEND BASE_SRC +list(APPEND BASE_SRC "internal/cycleclock.cc" "internal/raw_logging.cc" "internal/spinlock.cc" @@ -114,6 +116,28 @@ absl_library( throw_delegate ) +if(BUILD_TESTING) + # exception-safety testing library + set(EXCEPTION_SAFETY_TESTING_SRC "internal/exception_safety_testing.cc") + set(EXCEPTION_SAFETY_TESTING_PUBLIC_LIBRARIES + ${ABSL_TEST_COMMON_LIBRARIES} + absl::base + absl::memory + absl::meta + absl::strings + absl::types + ) + +absl_library( + TARGET + absl_base_internal_exception_safety_testing + SOURCES + ${EXCEPTION_SAFETY_TESTING_SRC} + PUBLIC_LIBRARIES + ${EXCEPTION_SAFETY_TESTING_PUBLIC_LIBRARIES} +) +endif() + # dynamic_annotations library set(DYNAMIC_ANNOTATIONS_SRC "dynamic_annotations.cc") @@ -212,6 +236,26 @@ absl_test( ) +# test inline_variable_test +list(APPEND INLINE_VARIABLE_TEST_SRC + "internal/inline_variable_testing.h" + "inline_variable_test.cc" + "inline_variable_test_a.cc" + "inline_variable_test_b.cc" +) + +set(INLINE_VARIABLE_TEST_PUBLIC_LIBRARIES absl::base) + +absl_test( + TARGET + inline_variable_test + SOURCES + ${INLINE_VARIABLE_TEST_SRC} + PUBLIC_LIBRARIES + ${INLINE_VARIABLE_TEST_PUBLIC_LIBRARIES} +) + + # test spinlock_test_common set(SPINLOCK_TEST_COMMON_SRC "spinlock_test_common.cc") set(SPINLOCK_TEST_COMMON_PUBLIC_LIBRARIES absl::base absl::synchronization) @@ -319,6 +363,20 @@ absl_test( ${THREAD_IDENTITY_TEST_PUBLIC_LIBRARIES} ) +#test exceptions_safety_testing_test +set(EXCEPTION_SAFETY_TESTING_TEST_SRC "exception_safety_testing_test.cc") +set(EXCEPTION_SAFETY_TESTING_TEST_PUBLIC_LIBRARIES absl::base absl::memory absl::meta absl::strings absl::optional) + +absl_test( + TARGET + absl_exception_safety_testing_test + SOURCES + ${EXCEPTION_SAFETY_TESTING_TEST_SRC} + PUBLIC_LIBRARIES + ${EXCEPTION_SAFETY_TESTING_TEST_PUBLIC_LIBRARIES} + PRIVATE_COMPILE_FLAGS + ${ABSL_EXCEPTIONS_FLAG} +) # test absl_malloc_extension_system_malloc_test set(MALLOC_EXTENSION_SYSTEM_MALLOC_TEST_SRC "internal/malloc_extension_test.cc") diff --git a/Firestore/third_party/abseil-cpp/absl/base/attributes.h b/Firestore/third_party/abseil-cpp/absl/base/attributes.h index 6f3cfe4..4e1fc8b 100644 --- a/Firestore/third_party/abseil-cpp/absl/base/attributes.h +++ b/Firestore/third_party/abseil-cpp/absl/base/attributes.h @@ -281,6 +281,18 @@ #define ABSL_ATTRIBUTE_NO_SANITIZE_CFI #endif +// ABSL_ATTRIBUTE_RETURNS_NONNULL +// +// Tells the compiler that a particular function never returns a null pointer. +#if ABSL_HAVE_ATTRIBUTE(returns_nonnull) || \ + (defined(__GNUC__) && \ + (__GNUC__ > 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) && \ + !defined(__clang__)) +#define ABSL_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) +#else +#define ABSL_ATTRIBUTE_RETURNS_NONNULL +#endif + // ABSL_HAVE_ATTRIBUTE_SECTION // // Indicates whether labeled sections are supported. Labeled sections are not @@ -305,6 +317,7 @@ __attribute__((section(#name))) __attribute__((noinline)) #endif + // ABSL_ATTRIBUTE_SECTION_VARIABLE // // Tells the compiler/linker to put a given variable into a section and define @@ -344,6 +357,7 @@ (reinterpret_cast(__start_##name)) #define ABSL_ATTRIBUTE_SECTION_STOP(name) \ (reinterpret_cast(__stop_##name)) + #else // !ABSL_HAVE_ATTRIBUTE_SECTION #define ABSL_HAVE_ATTRIBUTE_SECTION 0 @@ -356,6 +370,7 @@ #define ABSL_DECLARE_ATTRIBUTE_SECTION_VARS(name) #define ABSL_ATTRIBUTE_SECTION_START(name) (reinterpret_cast(0)) #define ABSL_ATTRIBUTE_SECTION_STOP(name) (reinterpret_cast(0)) + #endif // ABSL_ATTRIBUTE_SECTION // ABSL_ATTRIBUTE_STACK_ALIGN_FOR_OLD_LIBC diff --git a/Firestore/third_party/abseil-cpp/absl/base/config.h b/Firestore/third_party/abseil-cpp/absl/base/config.h index 8a44c06..6703d0e 100644 --- a/Firestore/third_party/abseil-cpp/absl/base/config.h +++ b/Firestore/third_party/abseil-cpp/absl/base/config.h @@ -138,9 +138,10 @@ // supported. #ifdef ABSL_HAVE_THREAD_LOCAL #error ABSL_HAVE_THREAD_LOCAL cannot be directly set -#elif !defined(__apple_build_version__) || \ - ((__apple_build_version__ >= 8000042) && \ - !(TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0)) +#elif (!defined(__apple_build_version__) || \ + (__apple_build_version__ >= 8000042)) && \ + !(defined(__APPLE__) && TARGET_OS_IPHONE && \ + __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0) // Notes: Xcode's clang did not support `thread_local` until version // 8, and even then not for all iOS < 9.0. #define ABSL_HAVE_THREAD_LOCAL 1 @@ -181,21 +182,21 @@ // __SIZEOF_INT128__ but not all versions actually support __int128. #ifdef ABSL_HAVE_INTRINSIC_INT128 #error ABSL_HAVE_INTRINSIC_INT128 cannot be directly set -#elif (defined(__clang__) && defined(__SIZEOF_INT128__) && \ - !defined(__aarch64__)) || \ - (defined(__CUDACC__) && defined(__SIZEOF_INT128__) && \ - __CUDACC_VER_MAJOR__ >= 9) || \ - (!defined(__clang__) && !defined(__CUDACC__) && defined(__GNUC__) && \ - defined(__SIZEOF_INT128__)) +#elif defined(__SIZEOF_INT128__) +#if (defined(__clang__) && !defined(__aarch64__)) || \ + (defined(__CUDACC__) && __CUDACC_VER_MAJOR__ >= 9) || \ + (!defined(__clang__) && !defined(__CUDACC__) && defined(__GNUC__)) #define ABSL_HAVE_INTRINSIC_INT128 1 +#elif defined(__CUDACC__) // __CUDACC_VER__ is a full version number before CUDA 9, and is defined to a -// std::string explaining that it has been removed starting with CUDA 9. We can't -// compare both variants in a single boolean expression because there is no -// short-circuiting in the preprocessor. -#elif defined(__CUDACC__) && defined(__SIZEOF_INT128__) && \ - __CUDACC_VER__ >= 7000 +// std::string explaining that it has been removed starting with CUDA 9. We use +// nested #ifs because there is no short-circuiting in the preprocessor. +// NOTE: `__CUDACC__` could be undefined while `__CUDACC_VER__` is defined. +#if __CUDACC_VER__ >= 70000 #define ABSL_HAVE_INTRINSIC_INT128 1 -#endif +#endif // __CUDACC_VER__ >= 70000 +#endif // defined(__CUDACC__) +#endif // ABSL_HAVE_INTRINSIC_INT128 // ABSL_HAVE_EXCEPTIONS // @@ -243,7 +244,7 @@ // Windows _WIN32 // NaCL __native_client__ // AsmJS __asmjs__ -// Fuschia __Fuchsia__ +// Fuchsia __Fuchsia__ // // Note that since Android defines both __ANDROID__ and __linux__, one // may probe for either Linux or Android by simply testing for __linux__. @@ -254,8 +255,9 @@ // POSIX.1-2001. #ifdef ABSL_HAVE_MMAP #error ABSL_HAVE_MMAP cannot be directly set -#elif defined(__linux__) || defined(__APPLE__) || defined(__ros__) || \ - defined(__native_client__) || defined(__asmjs__) || defined(__Fuchsia__) +#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ + defined(__ros__) || defined(__native_client__) || defined(__asmjs__) || \ + defined(__Fuchsia__) #define ABSL_HAVE_MMAP 1 #endif @@ -265,7 +267,8 @@ // functions as defined in POSIX.1-2001. #ifdef ABSL_HAVE_PTHREAD_GETSCHEDPARAM #error ABSL_HAVE_PTHREAD_GETSCHEDPARAM cannot be directly set -#elif defined(__linux__) || defined(__APPLE__) || defined(__ros__) +#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ + defined(__ros__) #define ABSL_HAVE_PTHREAD_GETSCHEDPARAM 1 #endif diff --git a/Firestore/third_party/abseil-cpp/absl/base/internal/endian.h b/Firestore/third_party/abseil-cpp/absl/base/internal/endian.h index 602129e..edc10f1 100644 --- a/Firestore/third_party/abseil-cpp/absl/base/internal/endian.h +++ b/Firestore/third_party/abseil-cpp/absl/base/internal/endian.h @@ -22,6 +22,8 @@ #elif defined(__APPLE__) // Mac OS X / Darwin features #include +#elif defined(__FreeBSD__) +#include #elif defined(__GLIBC__) #include // IWYU pragma: export #endif diff --git a/Firestore/third_party/abseil-cpp/absl/base/internal/log_severity.h b/Firestore/third_party/abseil-cpp/absl/base/internal/log_severity.h deleted file mode 100644 index deaf6a5..0000000 --- a/Firestore/third_party/abseil-cpp/absl/base/internal/log_severity.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2017 The Abseil Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -#ifndef ABSL_BASE_INTERNAL_LOG_SEVERITY_H_ -#define ABSL_BASE_INTERNAL_LOG_SEVERITY_H_ - -#include "absl/base/attributes.h" - -namespace absl { - -enum class LogSeverity : int { - kInfo = 0, - kWarning = 1, - kError = 2, - kFatal = 3, -}; - -constexpr const char* LogSeverityName(absl::LogSeverity s) { - return s == absl::LogSeverity::kInfo - ? "INFO" - : s == absl::LogSeverity::kWarning - ? "WARNING" - : s == absl::LogSeverity::kError - ? "ERROR" - : s == absl::LogSeverity::kFatal ? "FATAL" : "UNKNOWN"; -} - -// Note that out-of-range large severities normalize to kError, not kFatal. -constexpr absl::LogSeverity NormalizeLogSeverity(absl::LogSeverity s) { - return s < absl::LogSeverity::kInfo - ? absl::LogSeverity::kInfo - : s > absl::LogSeverity::kFatal ? absl::LogSeverity::kError : s; -} -constexpr absl::LogSeverity NormalizeLogSeverity(int s) { - return NormalizeLogSeverity(static_cast(s)); -} - -} // namespace absl - -#endif // ABSL_BASE_INTERNAL_LOG_SEVERITY_H_ diff --git a/Firestore/third_party/abseil-cpp/absl/base/internal/raw_logging.cc b/Firestore/third_party/abseil-cpp/absl/base/internal/raw_logging.cc index 1b849ab..86e34d4 100644 --- a/Firestore/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +++ b/Firestore/third_party/abseil-cpp/absl/base/internal/raw_logging.cc @@ -22,7 +22,7 @@ #include "absl/base/config.h" #include "absl/base/internal/atomic_hook.h" -#include "absl/base/internal/log_severity.h" +#include "absl/base/log_severity.h" // We know how to perform low-level writes to stderr in POSIX and Windows. For // these platforms, we define the token ABSL_LOW_LEVEL_WRITE_SUPPORTED. @@ -34,7 +34,8 @@ // // This preprocessor token is also defined in raw_io.cc. If you need to copy // this, consider moving both to config.h instead. -#if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) +#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || \ + defined(__Fuchsia__) #include @@ -47,7 +48,7 @@ // ABSL_HAVE_SYSCALL_WRITE is defined when the platform provides the syscall // syscall(SYS_write, /*int*/ fd, /*char* */ buf, /*size_t*/ len); // for low level operations that want to avoid libc. -#if defined(__linux__) && !defined(__ANDROID__) +#if (defined(__linux__) || defined(__FreeBSD__)) && !defined(__ANDROID__) #include #define ABSL_HAVE_SYSCALL_WRITE 1 #define ABSL_LOW_LEVEL_WRITE_SUPPORTED 1 diff --git a/Firestore/third_party/abseil-cpp/absl/base/internal/raw_logging.h b/Firestore/third_party/abseil-cpp/absl/base/internal/raw_logging.h index 568d2af..1b2a44b 100644 --- a/Firestore/third_party/abseil-cpp/absl/base/internal/raw_logging.h +++ b/Firestore/third_party/abseil-cpp/absl/base/internal/raw_logging.h @@ -20,7 +20,7 @@ #define ABSL_BASE_INTERNAL_RAW_LOGGING_H_ #include "absl/base/attributes.h" -#include "absl/base/internal/log_severity.h" +#include "absl/base/log_severity.h" #include "absl/base/macros.h" #include "absl/base/port.h" diff --git a/Firestore/third_party/abseil-cpp/absl/base/internal/unaligned_access.h b/Firestore/third_party/abseil-cpp/absl/base/internal/unaligned_access.h index ea30829..c572436 100644 --- a/Firestore/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +++ b/Firestore/third_party/abseil-cpp/absl/base/internal/unaligned_access.h @@ -142,7 +142,7 @@ inline void UnalignedStore64(void *p, uint64_t v) { // and 32-bit values (not 64-bit); older versions either raise a fatal signal, // do an unaligned read and rotate the words around a bit, or do the reads very // slowly (trip through kernel mode). There's no simple #define that says just -// “ARMv7 or higher”, so we have to filter away all ARMv5 and ARMv6 +// "ARMv7 or higher", so we have to filter away all ARMv5 and ARMv6 // sub-architectures. Newer gcc (>= 4.6) set an __ARM_FEATURE_ALIGNED #define, // so in time, maybe we can move on to that. // diff --git a/Firestore/third_party/abseil-cpp/absl/base/log_severity.h b/Firestore/third_party/abseil-cpp/absl/base/log_severity.h new file mode 100644 index 0000000..e146bcb --- /dev/null +++ b/Firestore/third_party/abseil-cpp/absl/base/log_severity.h @@ -0,0 +1,61 @@ +// Copyright 2017 The Abseil Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +#ifndef ABSL_BASE_INTERNAL_LOG_SEVERITY_H_ +#define ABSL_BASE_INTERNAL_LOG_SEVERITY_H_ + +#include + +#include "absl/base/attributes.h" + +namespace absl { + +enum class LogSeverity : int { + kInfo = 0, + kWarning = 1, + kError = 2, + kFatal = 3, +}; + +// Returns an iterable of all standard `absl::LogSeverity` values, ordered from +// least to most severe. +constexpr std::array LogSeverities() { + return {{absl::LogSeverity::kInfo, absl::LogSeverity::kWarning, + absl::LogSeverity::kError, absl::LogSeverity::kFatal}}; +} + +constexpr const char* LogSeverityName(absl::LogSeverity s) { + return s == absl::LogSeverity::kInfo + ? "INFO" + : s == absl::LogSeverity::kWarning + ? "WARNING" + : s == absl::LogSeverity::kError + ? "ERROR" + : s == absl::LogSeverity::kFatal ? "FATAL" : "UNKNOWN"; +} + +// Note that out-of-range severities normalize to kInfo or kError, never kFatal. +constexpr absl::LogSeverity NormalizeLogSeverity(absl::LogSeverity s) { + return s < absl::LogSeverity::kInfo + ? absl::LogSeverity::kInfo + : s > absl::LogSeverity::kFatal ? absl::LogSeverity::kError : s; +} +constexpr absl::LogSeverity NormalizeLogSeverity(int s) { + return NormalizeLogSeverity(static_cast(s)); +} + +} // namespace absl + +#endif // ABSL_BASE_INTERNAL_LOG_SEVERITY_H_ diff --git a/Firestore/third_party/abseil-cpp/absl/base/macros.h b/Firestore/third_party/abseil-cpp/absl/base/macros.h index d414087..5ae0f05 100644 --- a/Firestore/third_party/abseil-cpp/absl/base/macros.h +++ b/Firestore/third_party/abseil-cpp/absl/base/macros.h @@ -146,7 +146,7 @@ enum LinkerInitialized { // Every usage of a deprecated entity will trigger a warning when compiled with // clang's `-Wdeprecated-declarations` option. This option is turned off by // default, but the warnings will be reported by clang-tidy. -#if defined(__clang__) && __cplusplus >= 201103L && defined(__has_warning) +#if defined(__clang__) && __cplusplus >= 201103L #define ABSL_DEPRECATED(message) __attribute__((deprecated(message))) #endif diff --git a/Firestore/third_party/abseil-cpp/absl/meta/type_traits.h b/Firestore/third_party/abseil-cpp/absl/meta/type_traits.h index 6f7138c..f36a59a 100644 --- a/Firestore/third_party/abseil-cpp/absl/meta/type_traits.h +++ b/Firestore/third_party/abseil-cpp/absl/meta/type_traits.h @@ -148,11 +148,16 @@ struct negation : std::integral_constant {}; template struct is_trivially_destructible : std::integral_constant::value> { + std::is_destructible::value> { #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE - static_assert(std::is_trivially_destructible::value == - is_trivially_destructible::value, - "Not compliant with std::is_trivially_destructible"); + static constexpr bool compliant = std::is_trivially_destructible::value == + is_trivially_destructible::value; + static_assert(compliant || std::is_trivially_destructible::value, + "Not compliant with std::is_trivially_destructible; " + "Standard: false, Implementation: true"); + static_assert(compliant || !std::is_trivially_destructible::value, + "Not compliant with std::is_trivially_destructible; " + "Standard: true, Implementation: false"); #endif // ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE }; @@ -186,18 +191,23 @@ struct is_trivially_destructible // GCC bug 51452: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51452 // LWG issue 2116: http://cplusplus.github.io/LWG/lwg-active.html#2116. // -// "T obj();" need to be well-formed and not call any non-trivial operation. +// "T obj();" need to be well-formed and not call any nontrivial operation. // Nontrivally destructible types will cause the expression to be nontrivial. template struct is_trivially_default_constructible - : std::integral_constant::value && - is_trivially_destructible::value> { + : std::integral_constant::value && + is_trivially_destructible::value> { #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE - static_assert(std::is_trivially_default_constructible::value == - is_trivially_default_constructible::value, - "Not compliant with std::is_trivially_default_constructible"); + static constexpr bool compliant = + std::is_trivially_default_constructible::value == + is_trivially_default_constructible::value; + static_assert(compliant || std::is_trivially_default_constructible::value, + "Not compliant with std::is_trivially_default_constructible; " + "Standard: false, Implementation: true"); + static_assert(compliant || !std::is_trivially_default_constructible::value, + "Not compliant with std::is_trivially_default_constructible; " + "Standard: true, Implementation: false"); #endif // ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE }; @@ -217,12 +227,18 @@ struct is_trivially_default_constructible template struct is_trivially_copy_constructible : std::integral_constant::value && - is_trivially_destructible::value> { + std::is_copy_constructible::value && + is_trivially_destructible::value> { #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE - static_assert(std::is_trivially_copy_constructible::value == - is_trivially_copy_constructible::value, - "Not compliant with std::is_trivially_copy_constructible"); + static constexpr bool compliant = + std::is_trivially_copy_constructible::value == + is_trivially_copy_constructible::value; + static_assert(compliant || std::is_trivially_copy_constructible::value, + "Not compliant with std::is_trivially_copy_constructible; " + "Standard: false, Implementation: true"); + static_assert(compliant || !std::is_trivially_copy_constructible::value, + "Not compliant with std::is_trivially_copy_constructible; " + "Standard: true, Implementation: false"); #endif // ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE }; @@ -240,15 +256,21 @@ struct is_trivially_copy_constructible // `declval() = declval()` is well-formed when treated as an unevaluated // operand. `is_trivially_assignable` requires the assignment to call no // operation that is not trivial. `is_trivially_copy_assignable` is simply -// `is_trivially_assignable`. +// `is_trivially_assignable`. template struct is_trivially_copy_assignable : std::integral_constant::value> { + std::is_copy_assignable::value> { #ifdef ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE - static_assert(std::is_trivially_copy_assignable::value == - is_trivially_copy_assignable::value, - "Not compliant with std::is_trivially_copy_assignable"); + static constexpr bool compliant = + std::is_trivially_copy_assignable::value == + is_trivially_copy_assignable::value; + static_assert(compliant || std::is_trivially_copy_assignable::value, + "Not compliant with std::is_trivially_copy_assignable; " + "Standard: false, Implementation: true"); + static_assert(compliant || !std::is_trivially_copy_assignable::value, + "Not compliant with std::is_trivially_copy_assignable; " + "Standard: true, Implementation: false"); #endif // ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE }; diff --git a/Firestore/third_party/abseil-cpp/absl/meta/type_traits_test.cc b/Firestore/third_party/abseil-cpp/absl/meta/type_traits_test.cc index 15e1c28..c44d1c5 100644 --- a/Firestore/third_party/abseil-cpp/absl/meta/type_traits_test.cc +++ b/Firestore/third_party/abseil-cpp/absl/meta/type_traits_test.cc @@ -26,6 +26,12 @@ namespace { using ::testing::StaticAssertTypeEq; +template +struct simple_pair { + T first; + U second; +}; + struct Dummy {}; TEST(VoidTTest, BasicUsage) { @@ -93,6 +99,18 @@ class Trivial { int n_; }; +struct TrivialDestructor { + ~TrivialDestructor() = default; +}; + +struct NontrivialDestructor { + ~NontrivialDestructor() {} +}; + +struct DeletedDestructor { + ~DeletedDestructor() = delete; +}; + class TrivialDefaultCtor { public: TrivialDefaultCtor() = default; @@ -102,6 +120,23 @@ class TrivialDefaultCtor { int n_; }; +class NontrivialDefaultCtor { + public: + NontrivialDefaultCtor() : n_(1) {} + + private: + int n_; +}; + +class DeletedDefaultCtor { + public: + DeletedDefaultCtor() = delete; + explicit DeletedDefaultCtor(int n) : n_(n) {} + + private: + int n_; +}; + class TrivialCopyCtor { public: explicit TrivialCopyCtor(int n) : n_(n) {} @@ -115,22 +150,57 @@ class TrivialCopyCtor { int n_; }; +class NontrivialCopyCtor { + public: + explicit NontrivialCopyCtor(int n) : n_(n) {} + NontrivialCopyCtor(const NontrivialCopyCtor& t) : n_(t.n_) {} + NontrivialCopyCtor& operator=(const NontrivialCopyCtor&) = default; + + private: + int n_; +}; + +class DeletedCopyCtor { + public: + explicit DeletedCopyCtor(int n) : n_(n) {} + DeletedCopyCtor(const DeletedCopyCtor&) = delete; + DeletedCopyCtor& operator=(const DeletedCopyCtor&) = default; + + private: + int n_; +}; + class TrivialCopyAssign { public: explicit TrivialCopyAssign(int n) : n_(n) {} TrivialCopyAssign(const TrivialCopyAssign& t) : n_(t.n_) {} TrivialCopyAssign& operator=(const TrivialCopyAssign& t) = default; - ~TrivialCopyAssign() {} // can have non trivial destructor + ~TrivialCopyAssign() {} // can have nontrivial destructor private: int n_; }; -struct NonTrivialDestructor { - ~NonTrivialDestructor() {} +class NontrivialCopyAssign { + public: + explicit NontrivialCopyAssign(int n) : n_(n) {} + NontrivialCopyAssign(const NontrivialCopyAssign&) = default; + NontrivialCopyAssign& operator=(const NontrivialCopyAssign& t) { + n_ = t.n_; + return *this; + } + + private: + int n_; }; -struct TrivialDestructor { - ~TrivialDestructor() = default; +class DeletedCopyAssign { + public: + explicit DeletedCopyAssign(int n) : n_(n) {} + DeletedCopyAssign(const DeletedCopyAssign&) = default; + DeletedCopyAssign& operator=(const DeletedCopyAssign&) = delete; + + private: + int n_; }; struct NonCopyable { @@ -146,19 +216,105 @@ class Base { // In GCC/Clang, std::is_trivially_constructible requires that the destructor is // trivial. However, MSVC doesn't require that. This results in different -// behavior when checking is_trivially_constructible on any type with nontrivial -// destructor. Since absl::is_trivially_default_constructible and +// behavior when checking is_trivially_constructible on any type with +// nontrivial destructor. Since absl::is_trivially_default_constructible and // absl::is_trivially_copy_constructible both follows Clang/GCC's interpretation // and check is_trivially_destructible, it results in inconsistency with // std::is_trivially_xxx_constructible on MSVC. This macro is used to work // around this issue in test. In practice, a trivially constructible type // should also be trivially destructible. // GCC bug 51452: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51452 -// LWG issue 2116: http://cplusplus.github.io/LWG/lwg-active.html#2116. -#ifdef _MSC_VER -#define ABSL_TRIVIALLY_CONSTRUCTIBLE_VERIFY_TRIVIALLY_DESTRUCTIBLE +// LWG issue 2116: http://cplusplus.github.io/LWG/lwg-active.html#2116 +#ifndef _MSC_VER +#define ABSL_TRIVIALLY_CONSTRUCTIBLE_VERIFY_TRIVIALLY_DESTRUCTIBLE 1 +#endif + +// Old versions of libc++, around Clang 3.5 to 3.6, consider deleted destructors +// as also being trivial. With the resolution of CWG 1928 and CWG 1734, this +// is no longer considered true and has thus been amended. +// Compiler Explorer: https://godbolt.org/g/zT59ZL +// CWG issue 1734: http://open-std.org/JTC1/SC22/WG21/docs/cwg_defects.html#1734 +// CWG issue 1928: http://open-std.org/JTC1/SC22/WG21/docs/cwg_closed.html#1928 +#if !defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 3700 +#define ABSL_TRIVIALLY_DESTRUCTIBLE_CONSIDER_DELETED_DESTRUCTOR_NOT_TRIVIAL 1 +#endif + +// As of the moment, GCC versions >5.1 have a problem compiling for +// std::is_trivially_default_constructible, where +// NontrivialDestructor is a struct with a custom nontrivial destructor. Note +// that this problem only occurs for arrays of a known size, so something like +// std::is_trivially_default_constructible does not +// have any problems. +// Compiler Explorer: https://godbolt.org/g/dXRbdK +// GCC bug 83689: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83689 +#if defined(__clang__) || defined(_MSC_VER) || \ + (defined(__GNUC__) && __GNUC__ < 5) +#define ABSL_GCC_BUG_TRIVIALLY_CONSTRUCTIBLE_ON_ARRAY_OF_NONTRIVIAL 1 +#endif + +TEST(TypeTraitsTest, TestTrivialDestructor) { + // Verify that arithmetic types and pointers have trivial destructors. + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + + // classes with destructors + EXPECT_TRUE(absl::is_trivially_destructible::value); + EXPECT_TRUE(absl::is_trivially_destructible::value); + + // Verify that types with a nontrivial or deleted destructor + // are marked as such. + EXPECT_FALSE(absl::is_trivially_destructible::value); +#ifdef ABSL_TRIVIALLY_DESTRUCTIBLE_CONSIDER_DELETED_DESTRUCTOR_NOT_TRIVIAL + EXPECT_FALSE(absl::is_trivially_destructible::value); #endif + // simple_pair of such types is trivial + EXPECT_TRUE((absl::is_trivially_destructible>::value)); + EXPECT_TRUE((absl::is_trivially_destructible< + simple_pair>::value)); + + // Verify that types without trivial destructors are correctly marked as such. + EXPECT_FALSE(absl::is_trivially_destructible::value); + EXPECT_FALSE(absl::is_trivially_destructible>::value); + + // Verify that simple_pairs of types without trivial destructors + // are not marked as trivial. + EXPECT_FALSE((absl::is_trivially_destructible< + simple_pair>::value)); + EXPECT_FALSE((absl::is_trivially_destructible< + simple_pair>::value)); + + // array of such types is trivial + using int10 = int[10]; + EXPECT_TRUE(absl::is_trivially_destructible::value); + using Trivial10 = Trivial[10]; + EXPECT_TRUE(absl::is_trivially_destructible::value); + using TrivialDestructor10 = TrivialDestructor[10]; + EXPECT_TRUE(absl::is_trivially_destructible::value); + + // Conversely, the opposite also holds. + using NontrivialDestructor10 = NontrivialDestructor[10]; + EXPECT_FALSE(absl::is_trivially_destructible::value); +} + TEST(TypeTraitsTest, TestTrivialDefaultCtor) { // arithmetic types and pointers have trivial default constructors. EXPECT_TRUE(absl::is_trivially_default_constructible::value); @@ -178,42 +334,67 @@ TEST(TypeTraitsTest, TestTrivialDefaultCtor) { EXPECT_TRUE(absl::is_trivially_default_constructible::value); EXPECT_TRUE(absl::is_trivially_default_constructible::value); EXPECT_TRUE( - absl::is_trivially_default_constructible::value); - EXPECT_TRUE( - absl::is_trivially_default_constructible::value); + absl::is_trivially_default_constructible::value); + EXPECT_TRUE(absl::is_trivially_default_constructible::value); + EXPECT_TRUE(absl::is_trivially_default_constructible::value); + EXPECT_TRUE(absl::is_trivially_default_constructible::value); // types with compiler generated default ctors EXPECT_TRUE(absl::is_trivially_default_constructible::value); EXPECT_TRUE( absl::is_trivially_default_constructible::value); -#ifndef ABSL_TRIVIALLY_CONSTRUCTIBLE_VERIFY_TRIVIALLY_DESTRUCTIBLE - // types with non trivial destructor are non trivial + // Verify that types without them are not. + EXPECT_FALSE( + absl::is_trivially_default_constructible::value); + EXPECT_FALSE( + absl::is_trivially_default_constructible::value); + +#ifdef ABSL_TRIVIALLY_CONSTRUCTIBLE_VERIFY_TRIVIALLY_DESTRUCTIBLE + // types with nontrivial destructor are nontrivial EXPECT_FALSE( - absl::is_trivially_default_constructible::value); + absl::is_trivially_default_constructible::value); #endif // types with vtables EXPECT_FALSE(absl::is_trivially_default_constructible::value); + // Verify that simple_pair has trivial constructors where applicable. + EXPECT_TRUE((absl::is_trivially_default_constructible< + simple_pair>::value)); + EXPECT_TRUE((absl::is_trivially_default_constructible< + simple_pair>::value)); + EXPECT_TRUE((absl::is_trivially_default_constructible< + simple_pair>::value)); + + // Verify that types without trivial constructors are + // correctly marked as such. + EXPECT_FALSE(absl::is_trivially_default_constructible::value); + EXPECT_FALSE( + absl::is_trivially_default_constructible>::value); + + // Verify that simple_pairs of types without trivial constructors + // are not marked as trivial. + EXPECT_FALSE((absl::is_trivially_default_constructible< + simple_pair>::value)); + EXPECT_FALSE((absl::is_trivially_default_constructible< + simple_pair>::value)); + // Verify that arrays of such types are trivially default constructible - typedef int int10[10]; + using int10 = int[10]; EXPECT_TRUE(absl::is_trivially_default_constructible::value); - typedef Trivial Trivial10[10]; + using Trivial10 = Trivial[10]; EXPECT_TRUE(absl::is_trivially_default_constructible::value); - typedef Trivial TrivialDefaultCtor10[10]; + using TrivialDefaultCtor10 = TrivialDefaultCtor[10]; EXPECT_TRUE( absl::is_trivially_default_constructible::value); - // Verify that std::pair has non-trivial constructors. + // Conversely, the opposite also holds. +#ifdef ABSL_GCC_BUG_TRIVIALLY_CONSTRUCTIBLE_ON_ARRAY_OF_NONTRIVIAL + using NontrivialDefaultCtor10 = NontrivialDefaultCtor[10]; EXPECT_FALSE( - (absl::is_trivially_default_constructible>::value)); - - // Verify that types without trivial constructors are - // correctly marked as such. - EXPECT_FALSE(absl::is_trivially_default_constructible::value); - EXPECT_FALSE( - absl::is_trivially_default_constructible>::value); + absl::is_trivially_default_constructible::value); +#endif } TEST(TypeTraitsTest, TestTrivialCopyCtor) { @@ -235,54 +416,59 @@ TEST(TypeTraitsTest, TestTrivialCopyCtor) { EXPECT_TRUE(absl::is_trivially_copy_constructible::value); EXPECT_TRUE(absl::is_trivially_copy_constructible::value); EXPECT_TRUE(absl::is_trivially_copy_constructible::value); - EXPECT_TRUE( - absl::is_trivially_copy_constructible::value); - EXPECT_TRUE(absl::is_trivially_copy_constructible::value); + EXPECT_TRUE(absl::is_trivially_copy_constructible::value); + EXPECT_TRUE(absl::is_trivially_copy_constructible::value); + EXPECT_TRUE(absl::is_trivially_copy_constructible::value); + EXPECT_TRUE(absl::is_trivially_copy_constructible::value); // types with compiler generated copy ctors EXPECT_TRUE(absl::is_trivially_copy_constructible::value); EXPECT_TRUE(absl::is_trivially_copy_constructible::value); -#ifndef ABSL_TRIVIALLY_CONSTRUCTIBLE_VERIFY_TRIVIALLY_DESTRUCTIBLE - // type with non-trivial destructor are non-trivial copy construbtible + // Verify that types without them (i.e. nontrivial or deleted) are not. EXPECT_FALSE( - absl::is_trivially_copy_constructible::value); + absl::is_trivially_copy_constructible::value); + EXPECT_FALSE(absl::is_trivially_copy_constructible::value); + EXPECT_FALSE( + absl::is_trivially_copy_constructible::value); + +#ifdef ABSL_TRIVIALLY_CONSTRUCTIBLE_VERIFY_TRIVIALLY_DESTRUCTIBLE + // type with nontrivial destructor are nontrivial copy construbtible + EXPECT_FALSE( + absl::is_trivially_copy_constructible::value); #endif // types with vtables EXPECT_FALSE(absl::is_trivially_copy_constructible::value); - // Verify that std pair of such types is trivially copy constructible + // Verify that simple_pair of such types is trivially copy constructible EXPECT_TRUE( - (absl::is_trivially_copy_constructible>::value)); - EXPECT_TRUE( - (absl::is_trivially_copy_constructible>::value)); + (absl::is_trivially_copy_constructible>::value)); + EXPECT_TRUE(( + absl::is_trivially_copy_constructible>::value)); EXPECT_TRUE((absl::is_trivially_copy_constructible< - std::pair>::value)); - - // Verify that arrays are not - typedef int int10[10]; - EXPECT_FALSE(absl::is_trivially_copy_constructible::value); - - // Verify that pairs of types without trivial copy constructors - // are not marked as trivial. - EXPECT_FALSE((absl::is_trivially_copy_constructible< - std::pair>::value)); - EXPECT_FALSE((absl::is_trivially_copy_constructible< - std::pair>::value)); + simple_pair>::value)); // Verify that types without trivial copy constructors are // correctly marked as such. EXPECT_FALSE(absl::is_trivially_copy_constructible::value); EXPECT_FALSE(absl::is_trivially_copy_constructible>::value); - // types with deleted copy constructors are not copy constructible - EXPECT_FALSE(absl::is_trivially_copy_constructible::value); + // Verify that simple_pairs of types without trivial copy constructors + // are not marked as trivial. + EXPECT_FALSE((absl::is_trivially_copy_constructible< + simple_pair>::value)); + EXPECT_FALSE((absl::is_trivially_copy_constructible< + simple_pair>::value)); + + // Verify that arrays are not + using int10 = int[10]; + EXPECT_FALSE(absl::is_trivially_copy_constructible::value); } TEST(TypeTraitsTest, TestTrivialCopyAssign) { // Verify that arithmetic types and pointers have trivial copy - // constructors. + // assignment operators. EXPECT_TRUE(absl::is_trivially_copy_assignable::value); EXPECT_TRUE(absl::is_trivially_copy_assignable::value); EXPECT_TRUE(absl::is_trivially_copy_assignable::value); @@ -299,9 +485,10 @@ TEST(TypeTraitsTest, TestTrivialCopyAssign) { EXPECT_TRUE(absl::is_trivially_copy_assignable::value); EXPECT_TRUE(absl::is_trivially_copy_assignable::value); EXPECT_TRUE(absl::is_trivially_copy_assignable::value); - EXPECT_TRUE( - absl::is_trivially_copy_assignable::value); - EXPECT_TRUE(absl::is_trivially_copy_assignable::value); + EXPECT_TRUE(absl::is_trivially_copy_assignable::value); + EXPECT_TRUE(absl::is_trivially_copy_assignable::value); + EXPECT_TRUE(absl::is_trivially_copy_assignable::value); + EXPECT_TRUE(absl::is_trivially_copy_assignable::value); // const qualified types are not assignable EXPECT_FALSE(absl::is_trivially_copy_assignable::value); @@ -310,65 +497,37 @@ TEST(TypeTraitsTest, TestTrivialCopyAssign) { EXPECT_TRUE(absl::is_trivially_copy_assignable::value); EXPECT_TRUE(absl::is_trivially_copy_assignable::value); + // Verify that types without them (i.e. nontrivial or deleted) are not. + EXPECT_FALSE(absl::is_trivially_copy_assignable::value); + EXPECT_FALSE(absl::is_trivially_copy_assignable::value); + EXPECT_FALSE(absl::is_trivially_copy_assignable::value); + // types with vtables EXPECT_FALSE(absl::is_trivially_copy_assignable::value); - // Verify that arrays are not trivially copy assignable - typedef int int10[10]; - EXPECT_FALSE(absl::is_trivially_copy_assignable::value); - - // Verify that std::pair is not trivially assignable - EXPECT_FALSE( - (absl::is_trivially_copy_assignable>::value)); + // Verify that simple_pair is trivially assignable + EXPECT_TRUE( + (absl::is_trivially_copy_assignable>::value)); + EXPECT_TRUE( + (absl::is_trivially_copy_assignable>::value)); + EXPECT_TRUE((absl::is_trivially_copy_assignable< + simple_pair>::value)); - // Verify that types without trivial copy constructors are + // Verify that types not trivially copy assignable are // correctly marked as such. EXPECT_FALSE(absl::is_trivially_copy_assignable::value); EXPECT_FALSE(absl::is_trivially_copy_assignable>::value); - // types with deleted copy assignment are not copy assignable - EXPECT_FALSE(absl::is_trivially_copy_assignable::value); -} - -TEST(TypeTraitsTest, TestTrivialDestructor) { - // Verify that arithmetic types and pointers have trivial copy - // constructors. - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - - // classes with destructors - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_TRUE(absl::is_trivially_destructible::value); - EXPECT_FALSE(absl::is_trivially_destructible::value); - - // std::pair of such types is trivial - EXPECT_TRUE((absl::is_trivially_destructible>::value)); - EXPECT_TRUE((absl::is_trivially_destructible< - std::pair>::value)); + // Verify that simple_pairs of types not trivially copy assignable + // are not marked as trivial. + EXPECT_FALSE((absl::is_trivially_copy_assignable< + simple_pair>::value)); + EXPECT_FALSE((absl::is_trivially_copy_assignable< + simple_pair>::value)); - // array of such types is trivial - typedef int int10[10]; - EXPECT_TRUE(absl::is_trivially_destructible::value); - typedef TrivialDestructor TrivialDestructor10[10]; - EXPECT_TRUE(absl::is_trivially_destructible::value); - typedef NonTrivialDestructor NonTrivialDestructor10[10]; - EXPECT_FALSE(absl::is_trivially_destructible::value); + // Verify that arrays are not trivially copy assignable + using int10 = int[10]; + EXPECT_FALSE(absl::is_trivially_copy_assignable::value); } #define ABSL_INTERNAL_EXPECT_ALIAS_EQUIVALENCE(trait_name, ...) \ diff --git a/Firestore/third_party/abseil-cpp/absl/strings/CMakeLists.txt b/Firestore/third_party/abseil-cpp/absl/strings/CMakeLists.txt index dcd4974..83cb934 100644 --- a/Firestore/third_party/abseil-cpp/absl/strings/CMakeLists.txt +++ b/Firestore/third_party/abseil-cpp/absl/strings/CMakeLists.txt @@ -35,6 +35,7 @@ list(APPEND STRINGS_INTERNAL_HEADERS "internal/memutil.h" "internal/ostringstream.h" "internal/resize_uninitialized.h" + "internal/stl_type_traits.h" "internal/str_join_internal.h" "internal/str_split_internal.h" "internal/utf8.h" @@ -49,6 +50,7 @@ list(APPEND STRINGS_SRC "internal/memutil.cc" "internal/memutil.h" "internal/utf8.cc" + "internal/ostringstream.cc" "match.cc" "numbers.cc" "str_cat.cc" @@ -205,12 +207,15 @@ absl_test( # test ostringstream_test set(OSTRINGSTREAM_TEST_SRC "internal/ostringstream_test.cc") +set(OSTRINGSTREAM_TEST_PUBLIC_LIBRARIES absl::strings) absl_test( TARGET ostringstream_test SOURCES ${OSTRINGSTREAM_TEST_SRC} + PUBLIC_LIBRARIES + ${OSTRINGSTREAM_TEST_PUBLIC_LIBRARIES} ) diff --git a/Firestore/third_party/abseil-cpp/absl/strings/string_view.h b/Firestore/third_party/abseil-cpp/absl/strings/string_view.h index c3acd72..ddc8934 100644 --- a/Firestore/third_party/abseil-cpp/absl/strings/string_view.h +++ b/Firestore/third_party/abseil-cpp/absl/strings/string_view.h @@ -419,7 +419,7 @@ class string_view { size_type rfind(string_view s, size_type pos = npos) const noexcept; - // Overload of `string_view::rfind()` for finding the given character `c` + // Overload of `string_view::rfind()` for finding the last given character `c` // within the `string_view`. size_type rfind(char c, size_type pos = npos) const noexcept; diff --git a/Firestore/third_party/abseil-cpp/absl/strings/string_view_test.cc b/Firestore/third_party/abseil-cpp/absl/strings/string_view_test.cc index 13fc214..3077d24 100644 --- a/Firestore/third_party/abseil-cpp/absl/strings/string_view_test.cc +++ b/Firestore/third_party/abseil-cpp/absl/strings/string_view_test.cc @@ -684,8 +684,11 @@ TEST(StringViewTest, TruncSubstr) { } TEST(StringViewTest, UTF8) { - EXPECT_EQ(strlen("á"), absl::string_view("á á").find_first_of(" ")); - EXPECT_EQ(strlen("á"), absl::string_view("á á").find_first_of(" \t")); + std::string utf8 = "\u00E1"; + std::string utf8_twice = utf8 + " " + utf8; + int utf8_len = strlen(utf8.data()); + EXPECT_EQ(utf8_len, absl::string_view(utf8_twice).find_first_of(" ")); + EXPECT_EQ(utf8_len, absl::string_view(utf8_twice).find_first_of(" \t")); } TEST(StringViewTest, FindConformance) { @@ -796,11 +799,25 @@ TEST(StringViewTest, FrontBackSingleChar) { EXPECT_EQ(&c, &csp.back()); } +// `std::string_view::string_view(const char*)` calls +// `std::char_traits::length(const char*)` to get the std::string length. In +// libc++, it doesn't allow `nullptr` in the constexpr context, with the error +// "read of dereferenced null pointer is not allowed in a constant expression". +// At run time, the behavior of `std::char_traits::length()` on `nullptr` is +// undefined by the standard and usually results in crash with libc++. This +// conforms to the standard, but `absl::string_view` implements a different +// behavior for historical reasons. We work around tests that construct +// `string_view` from `nullptr` when using libc++. +#if !defined(ABSL_HAVE_STD_STRING_VIEW) || !defined(_LIBCPP_VERSION) +#define ABSL_HAVE_STRING_VIEW_FROM_NULLPTR 1 +#endif // !defined(ABSL_HAVE_STD_STRING_VIEW) || !defined(_LIBCPP_VERSION) + TEST(StringViewTest, NULLInput) { absl::string_view s; EXPECT_EQ(s.data(), nullptr); EXPECT_EQ(s.size(), 0); +#ifdef ABSL_HAVE_STRING_VIEW_FROM_NULLPTR s = absl::string_view(nullptr); EXPECT_EQ(s.data(), nullptr); EXPECT_EQ(s.size(), 0); @@ -808,6 +825,7 @@ TEST(StringViewTest, NULLInput) { // .ToString() on a absl::string_view with nullptr should produce the empty // std::string. EXPECT_EQ("", std::string(s)); +#endif // ABSL_HAVE_STRING_VIEW_FROM_NULLPTR } TEST(StringViewTest, Comparisons2) { @@ -879,7 +897,9 @@ TEST(StringViewTest, NullSafeStringView) { TEST(StringViewTest, ConstexprCompiles) { constexpr absl::string_view sp; +#ifdef ABSL_HAVE_STRING_VIEW_FROM_NULLPTR constexpr absl::string_view cstr(nullptr); +#endif constexpr absl::string_view cstr_len("cstr", 4); #if defined(ABSL_HAVE_STD_STRING_VIEW) @@ -923,10 +943,12 @@ TEST(StringViewTest, ConstexprCompiles) { constexpr absl::string_view::iterator const_end_empty = sp.end(); EXPECT_EQ(const_begin_empty, const_end_empty); +#ifdef ABSL_HAVE_STRING_VIEW_FROM_NULLPTR constexpr absl::string_view::iterator const_begin_nullptr = cstr.begin(); constexpr absl::string_view::iterator const_end_nullptr = cstr.end(); EXPECT_EQ(const_begin_nullptr, const_end_nullptr); -#endif +#endif // ABSL_HAVE_STRING_VIEW_FROM_NULLPTR +#endif // !defined(__clang__) || ... constexpr absl::string_view::iterator const_begin = cstr_len.begin(); constexpr absl::string_view::iterator const_end = cstr_len.end(); @@ -1042,11 +1064,11 @@ TEST(HugeStringView, TwoPointTwoGB) { } #endif // THREAD_SANITIZER -#ifndef NDEBUG +#if !defined(NDEBUG) && !defined(ABSL_HAVE_STD_STRING_VIEW) TEST(NonNegativeLenTest, NonNegativeLen) { EXPECT_DEATH_IF_SUPPORTED(absl::string_view("xyz", -1), "len <= kMaxSize"); } -#endif // NDEBUG +#endif // !defined(NDEBUG) && !defined(ABSL_HAVE_STD_STRING_VIEW) class StringViewStreamTest : public ::testing::Test { public: -- cgit v1.2.3