aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/third_party
diff options
context:
space:
mode:
authorGravatar Gil <mcg@google.com>2018-02-06 09:28:30 -0800
committerGravatar GitHub <noreply@github.com>2018-02-06 09:28:30 -0800
commit28850292d4397562dde0d108fb848b405c689d76 (patch)
treec4683acd6074a564bc0d63fa0b497bd5e18d2097 /Firestore/third_party
parentcd17b85587d1a827389ea1e18d0ce5622606cd5f (diff)
Update abseil-cpp to a new upstream (#754)
Diffstat (limited to 'Firestore/third_party')
-rw-r--r--Firestore/third_party/abseil-cpp/CMakeLists.txt48
-rw-r--r--Firestore/third_party/abseil-cpp/absl/base/CMakeLists.txt64
-rw-r--r--Firestore/third_party/abseil-cpp/absl/base/attributes.h15
-rw-r--r--Firestore/third_party/abseil-cpp/absl/base/config.h41
-rw-r--r--Firestore/third_party/abseil-cpp/absl/base/internal/endian.h2
-rw-r--r--Firestore/third_party/abseil-cpp/absl/base/internal/raw_logging.cc7
-rw-r--r--Firestore/third_party/abseil-cpp/absl/base/internal/raw_logging.h2
-rw-r--r--Firestore/third_party/abseil-cpp/absl/base/internal/unaligned_access.h2
-rw-r--r--Firestore/third_party/abseil-cpp/absl/base/log_severity.h (renamed from Firestore/third_party/abseil-cpp/absl/base/internal/log_severity.h)11
-rw-r--r--Firestore/third_party/abseil-cpp/absl/base/macros.h2
-rw-r--r--Firestore/third_party/abseil-cpp/absl/meta/type_traits.h66
-rw-r--r--Firestore/third_party/abseil-cpp/absl/meta/type_traits_test.cc369
-rw-r--r--Firestore/third_party/abseil-cpp/absl/strings/CMakeLists.txt5
-rw-r--r--Firestore/third_party/abseil-cpp/absl/strings/string_view.h2
-rw-r--r--Firestore/third_party/abseil-cpp/absl/strings/string_view_test.cc32
15 files changed, 488 insertions, 180 deletions
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<void *>(__start_##name))
#define ABSL_ATTRIBUTE_SECTION_STOP(name) \
(reinterpret_cast<void *>(__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<void *>(0))
#define ABSL_ATTRIBUTE_SECTION_STOP(name) (reinterpret_cast<void *>(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 <libkern/OSByteOrder.h>
+#elif defined(__FreeBSD__)
+#include <sys/endian.h>
#elif defined(__GLIBC__)
#include <byteswap.h> // IWYU pragma: export
#endif
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 <unistd.h>
@@ -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 <sys/syscall.h>
#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/internal/log_severity.h b/Firestore/third_party/abseil-cpp/absl/base/log_severity.h
index deaf6a5..e146bcb 100644
--- a/Firestore/third_party/abseil-cpp/absl/base/internal/log_severity.h
+++ b/Firestore/third_party/abseil-cpp/absl/base/log_severity.h
@@ -16,6 +16,8 @@
#ifndef ABSL_BASE_INTERNAL_LOG_SEVERITY_H_
#define ABSL_BASE_INTERNAL_LOG_SEVERITY_H_
+#include <array>
+
#include "absl/base/attributes.h"
namespace absl {
@@ -27,6 +29,13 @@ enum class LogSeverity : int {
kFatal = 3,
};
+// Returns an iterable of all standard `absl::LogSeverity` values, ordered from
+// least to most severe.
+constexpr std::array<absl::LogSeverity, 4> 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"
@@ -37,7 +46,7 @@ constexpr const char* LogSeverityName(absl::LogSeverity s) {
: s == absl::LogSeverity::kFatal ? "FATAL" : "UNKNOWN";
}
-// Note that out-of-range large severities normalize to kError, not kFatal.
+// 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
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<bool, !T::value> {};
template <typename T>
struct is_trivially_destructible
: std::integral_constant<bool, __has_trivial_destructor(T) &&
- std::is_destructible<T>::value> {
+ std::is_destructible<T>::value> {
#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_DESTRUCTIBLE
- static_assert(std::is_trivially_destructible<T>::value ==
- is_trivially_destructible::value,
- "Not compliant with std::is_trivially_destructible");
+ static constexpr bool compliant = std::is_trivially_destructible<T>::value ==
+ is_trivially_destructible::value;
+ static_assert(compliant || std::is_trivially_destructible<T>::value,
+ "Not compliant with std::is_trivially_destructible; "
+ "Standard: false, Implementation: true");
+ static_assert(compliant || !std::is_trivially_destructible<T>::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 <typename T>
struct is_trivially_default_constructible
- : std::integral_constant<bool,
- __has_trivial_constructor(T) &&
- std::is_default_constructible<T>::value &&
- is_trivially_destructible<T>::value> {
+ : std::integral_constant<bool, __has_trivial_constructor(T) &&
+ std::is_default_constructible<T>::value &&
+ is_trivially_destructible<T>::value> {
#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE
- static_assert(std::is_trivially_default_constructible<T>::value ==
- is_trivially_default_constructible::value,
- "Not compliant with std::is_trivially_default_constructible");
+ static constexpr bool compliant =
+ std::is_trivially_default_constructible<T>::value ==
+ is_trivially_default_constructible::value;
+ static_assert(compliant || std::is_trivially_default_constructible<T>::value,
+ "Not compliant with std::is_trivially_default_constructible; "
+ "Standard: false, Implementation: true");
+ static_assert(compliant || !std::is_trivially_default_constructible<T>::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 <typename T>
struct is_trivially_copy_constructible
: std::integral_constant<bool, __has_trivial_copy(T) &&
- std::is_copy_constructible<T>::value &&
- is_trivially_destructible<T>::value> {
+ std::is_copy_constructible<T>::value &&
+ is_trivially_destructible<T>::value> {
#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_CONSTRUCTIBLE
- static_assert(std::is_trivially_copy_constructible<T>::value ==
- is_trivially_copy_constructible::value,
- "Not compliant with std::is_trivially_copy_constructible");
+ static constexpr bool compliant =
+ std::is_trivially_copy_constructible<T>::value ==
+ is_trivially_copy_constructible::value;
+ static_assert(compliant || std::is_trivially_copy_constructible<T>::value,
+ "Not compliant with std::is_trivially_copy_constructible; "
+ "Standard: false, Implementation: true");
+ static_assert(compliant || !std::is_trivially_copy_constructible<T>::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<T>() = declval<U>()` is well-formed when treated as an unevaluated
// operand. `is_trivially_assignable<T, U>` requires the assignment to call no
// operation that is not trivial. `is_trivially_copy_assignable<T>` is simply
-// `is_trivially_assignable<T, const T&>`.
+// `is_trivially_assignable<T&, const T&>`.
template <typename T>
struct is_trivially_copy_assignable
: std::integral_constant<bool, __has_trivial_assign(T) &&
- std::is_copy_assignable<T>::value> {
+ std::is_copy_assignable<T>::value> {
#ifdef ABSL_HAVE_STD_IS_TRIVIALLY_ASSIGNABLE
- static_assert(std::is_trivially_copy_assignable<T>::value ==
- is_trivially_copy_assignable::value,
- "Not compliant with std::is_trivially_copy_assignable");
+ static constexpr bool compliant =
+ std::is_trivially_copy_assignable<T>::value ==
+ is_trivially_copy_assignable::value;
+ static_assert(compliant || std::is_trivially_copy_assignable<T>::value,
+ "Not compliant with std::is_trivially_copy_assignable; "
+ "Standard: false, Implementation: true");
+ static_assert(compliant || !std::is_trivially_copy_assignable<T>::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 <class T, class U>
+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<NontrivialDestructor[10]>, 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<NontrivialDestructor[]> 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<bool>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<char>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<unsigned char>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<signed char>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<wchar_t>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<int>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<unsigned int>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<int16_t>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<uint16_t>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<int64_t>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<uint64_t>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<float>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<double>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<long double>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<std::string*>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<Trivial*>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<const std::string*>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<const Trivial*>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<std::string**>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<Trivial**>::value);
+
+ // classes with destructors
+ EXPECT_TRUE(absl::is_trivially_destructible<Trivial>::value);
+ EXPECT_TRUE(absl::is_trivially_destructible<TrivialDestructor>::value);
+
+ // Verify that types with a nontrivial or deleted destructor
+ // are marked as such.
+ EXPECT_FALSE(absl::is_trivially_destructible<NontrivialDestructor>::value);
+#ifdef ABSL_TRIVIALLY_DESTRUCTIBLE_CONSIDER_DELETED_DESTRUCTOR_NOT_TRIVIAL
+ EXPECT_FALSE(absl::is_trivially_destructible<DeletedDestructor>::value);
#endif
+ // simple_pair of such types is trivial
+ EXPECT_TRUE((absl::is_trivially_destructible<simple_pair<int, int>>::value));
+ EXPECT_TRUE((absl::is_trivially_destructible<
+ simple_pair<Trivial, TrivialDestructor>>::value));
+
+ // Verify that types without trivial destructors are correctly marked as such.
+ EXPECT_FALSE(absl::is_trivially_destructible<std::string>::value);
+ EXPECT_FALSE(absl::is_trivially_destructible<std::vector<int>>::value);
+
+ // Verify that simple_pairs of types without trivial destructors
+ // are not marked as trivial.
+ EXPECT_FALSE((absl::is_trivially_destructible<
+ simple_pair<int, std::string>>::value));
+ EXPECT_FALSE((absl::is_trivially_destructible<
+ simple_pair<std::string, int>>::value));
+
+ // array of such types is trivial
+ using int10 = int[10];
+ EXPECT_TRUE(absl::is_trivially_destructible<int10>::value);
+ using Trivial10 = Trivial[10];
+ EXPECT_TRUE(absl::is_trivially_destructible<Trivial10>::value);
+ using TrivialDestructor10 = TrivialDestructor[10];
+ EXPECT_TRUE(absl::is_trivially_destructible<TrivialDestructor10>::value);
+
+ // Conversely, the opposite also holds.
+ using NontrivialDestructor10 = NontrivialDestructor[10];
+ EXPECT_FALSE(absl::is_trivially_destructible<NontrivialDestructor10>::value);
+}
+
TEST(TypeTraitsTest, TestTrivialDefaultCtor) {
// arithmetic types and pointers have trivial default constructors.
EXPECT_TRUE(absl::is_trivially_default_constructible<bool>::value);
@@ -178,42 +334,67 @@ TEST(TypeTraitsTest, TestTrivialDefaultCtor) {
EXPECT_TRUE(absl::is_trivially_default_constructible<std::string*>::value);
EXPECT_TRUE(absl::is_trivially_default_constructible<Trivial*>::value);
EXPECT_TRUE(
- absl::is_trivially_default_constructible<const TrivialCopyCtor*>::value);
- EXPECT_TRUE(
- absl::is_trivially_default_constructible<TrivialCopyCtor**>::value);
+ absl::is_trivially_default_constructible<const std::string*>::value);
+ EXPECT_TRUE(absl::is_trivially_default_constructible<const Trivial*>::value);
+ EXPECT_TRUE(absl::is_trivially_default_constructible<std::string**>::value);
+ EXPECT_TRUE(absl::is_trivially_default_constructible<Trivial**>::value);
// types with compiler generated default ctors
EXPECT_TRUE(absl::is_trivially_default_constructible<Trivial>::value);
EXPECT_TRUE(
absl::is_trivially_default_constructible<TrivialDefaultCtor>::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<NontrivialDefaultCtor>::value);
+ EXPECT_FALSE(
+ absl::is_trivially_default_constructible<DeletedDefaultCtor>::value);
+
+#ifdef ABSL_TRIVIALLY_CONSTRUCTIBLE_VERIFY_TRIVIALLY_DESTRUCTIBLE
+ // types with nontrivial destructor are nontrivial
EXPECT_FALSE(
- absl::is_trivially_default_constructible<NonTrivialDestructor>::value);
+ absl::is_trivially_default_constructible<NontrivialDestructor>::value);
#endif
// types with vtables
EXPECT_FALSE(absl::is_trivially_default_constructible<Base>::value);
+ // Verify that simple_pair has trivial constructors where applicable.
+ EXPECT_TRUE((absl::is_trivially_default_constructible<
+ simple_pair<int, char*>>::value));
+ EXPECT_TRUE((absl::is_trivially_default_constructible<
+ simple_pair<int, Trivial>>::value));
+ EXPECT_TRUE((absl::is_trivially_default_constructible<
+ simple_pair<int, TrivialDefaultCtor>>::value));
+
+ // Verify that types without trivial constructors are
+ // correctly marked as such.
+ EXPECT_FALSE(absl::is_trivially_default_constructible<std::string>::value);
+ EXPECT_FALSE(
+ absl::is_trivially_default_constructible<std::vector<int>>::value);
+
+ // Verify that simple_pairs of types without trivial constructors
+ // are not marked as trivial.
+ EXPECT_FALSE((absl::is_trivially_default_constructible<
+ simple_pair<int, std::string>>::value));
+ EXPECT_FALSE((absl::is_trivially_default_constructible<
+ simple_pair<std::string, int>>::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<int10>::value);
- typedef Trivial Trivial10[10];
+ using Trivial10 = Trivial[10];
EXPECT_TRUE(absl::is_trivially_default_constructible<Trivial10>::value);
- typedef Trivial TrivialDefaultCtor10[10];
+ using TrivialDefaultCtor10 = TrivialDefaultCtor[10];
EXPECT_TRUE(
absl::is_trivially_default_constructible<TrivialDefaultCtor10>::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<std::pair<int, char*>>::value));
-
- // Verify that types without trivial constructors are
- // correctly marked as such.
- EXPECT_FALSE(absl::is_trivially_default_constructible<std::string>::value);
- EXPECT_FALSE(
- absl::is_trivially_default_constructible<std::vector<int>>::value);
+ absl::is_trivially_default_constructible<NontrivialDefaultCtor10>::value);
+#endif
}
TEST(TypeTraitsTest, TestTrivialCopyCtor) {
@@ -235,54 +416,59 @@ TEST(TypeTraitsTest, TestTrivialCopyCtor) {
EXPECT_TRUE(absl::is_trivially_copy_constructible<long double>::value);
EXPECT_TRUE(absl::is_trivially_copy_constructible<std::string*>::value);
EXPECT_TRUE(absl::is_trivially_copy_constructible<Trivial*>::value);
- EXPECT_TRUE(
- absl::is_trivially_copy_constructible<const TrivialCopyCtor*>::value);
- EXPECT_TRUE(absl::is_trivially_copy_constructible<TrivialCopyCtor**>::value);
+ EXPECT_TRUE(absl::is_trivially_copy_constructible<const std::string*>::value);
+ EXPECT_TRUE(absl::is_trivially_copy_constructible<const Trivial*>::value);
+ EXPECT_TRUE(absl::is_trivially_copy_constructible<std::string**>::value);
+ EXPECT_TRUE(absl::is_trivially_copy_constructible<Trivial**>::value);
// types with compiler generated copy ctors
EXPECT_TRUE(absl::is_trivially_copy_constructible<Trivial>::value);
EXPECT_TRUE(absl::is_trivially_copy_constructible<TrivialCopyCtor>::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<NonTrivialDestructor>::value);
+ absl::is_trivially_copy_constructible<NontrivialCopyCtor>::value);
+ EXPECT_FALSE(absl::is_trivially_copy_constructible<DeletedCopyCtor>::value);
+ EXPECT_FALSE(
+ absl::is_trivially_copy_constructible<NonCopyable>::value);
+
+#ifdef ABSL_TRIVIALLY_CONSTRUCTIBLE_VERIFY_TRIVIALLY_DESTRUCTIBLE
+ // type with nontrivial destructor are nontrivial copy construbtible
+ EXPECT_FALSE(
+ absl::is_trivially_copy_constructible<NontrivialDestructor>::value);
#endif
// types with vtables
EXPECT_FALSE(absl::is_trivially_copy_constructible<Base>::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<std::pair<int, char*>>::value));
- EXPECT_TRUE(
- (absl::is_trivially_copy_constructible<std::pair<int, Trivial>>::value));
+ (absl::is_trivially_copy_constructible<simple_pair<int, char*>>::value));
+ EXPECT_TRUE((
+ absl::is_trivially_copy_constructible<simple_pair<int, Trivial>>::value));
EXPECT_TRUE((absl::is_trivially_copy_constructible<
- std::pair<int, TrivialCopyCtor>>::value));
-
- // Verify that arrays are not
- typedef int int10[10];
- EXPECT_FALSE(absl::is_trivially_copy_constructible<int10>::value);
-
- // Verify that pairs of types without trivial copy constructors
- // are not marked as trivial.
- EXPECT_FALSE((absl::is_trivially_copy_constructible<
- std::pair<int, std::string>>::value));
- EXPECT_FALSE((absl::is_trivially_copy_constructible<
- std::pair<std::string, int>>::value));
+ simple_pair<int, TrivialCopyCtor>>::value));
// Verify that types without trivial copy constructors are
// correctly marked as such.
EXPECT_FALSE(absl::is_trivially_copy_constructible<std::string>::value);
EXPECT_FALSE(absl::is_trivially_copy_constructible<std::vector<int>>::value);
- // types with deleted copy constructors are not copy constructible
- EXPECT_FALSE(absl::is_trivially_copy_constructible<NonCopyable>::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<int, std::string>>::value));
+ EXPECT_FALSE((absl::is_trivially_copy_constructible<
+ simple_pair<std::string, int>>::value));
+
+ // Verify that arrays are not
+ using int10 = int[10];
+ EXPECT_FALSE(absl::is_trivially_copy_constructible<int10>::value);
}
TEST(TypeTraitsTest, TestTrivialCopyAssign) {
// Verify that arithmetic types and pointers have trivial copy
- // constructors.
+ // assignment operators.
EXPECT_TRUE(absl::is_trivially_copy_assignable<bool>::value);
EXPECT_TRUE(absl::is_trivially_copy_assignable<char>::value);
EXPECT_TRUE(absl::is_trivially_copy_assignable<unsigned char>::value);
@@ -299,9 +485,10 @@ TEST(TypeTraitsTest, TestTrivialCopyAssign) {
EXPECT_TRUE(absl::is_trivially_copy_assignable<long double>::value);
EXPECT_TRUE(absl::is_trivially_copy_assignable<std::string*>::value);
EXPECT_TRUE(absl::is_trivially_copy_assignable<Trivial*>::value);
- EXPECT_TRUE(
- absl::is_trivially_copy_assignable<const TrivialCopyCtor*>::value);
- EXPECT_TRUE(absl::is_trivially_copy_assignable<TrivialCopyCtor**>::value);
+ EXPECT_TRUE(absl::is_trivially_copy_assignable<const std::string*>::value);
+ EXPECT_TRUE(absl::is_trivially_copy_assignable<const Trivial*>::value);
+ EXPECT_TRUE(absl::is_trivially_copy_assignable<std::string**>::value);
+ EXPECT_TRUE(absl::is_trivially_copy_assignable<Trivial**>::value);
// const qualified types are not assignable
EXPECT_FALSE(absl::is_trivially_copy_assignable<const int>::value);
@@ -310,65 +497,37 @@ TEST(TypeTraitsTest, TestTrivialCopyAssign) {
EXPECT_TRUE(absl::is_trivially_copy_assignable<Trivial>::value);
EXPECT_TRUE(absl::is_trivially_copy_assignable<TrivialCopyAssign>::value);
+ // Verify that types without them (i.e. nontrivial or deleted) are not.
+ EXPECT_FALSE(absl::is_trivially_copy_assignable<NontrivialCopyAssign>::value);
+ EXPECT_FALSE(absl::is_trivially_copy_assignable<DeletedCopyAssign>::value);
+ EXPECT_FALSE(absl::is_trivially_copy_assignable<NonCopyable>::value);
+
// types with vtables
EXPECT_FALSE(absl::is_trivially_copy_assignable<Base>::value);
- // Verify that arrays are not trivially copy assignable
- typedef int int10[10];
- EXPECT_FALSE(absl::is_trivially_copy_assignable<int10>::value);
-
- // Verify that std::pair is not trivially assignable
- EXPECT_FALSE(
- (absl::is_trivially_copy_assignable<std::pair<int, char*>>::value));
+ // Verify that simple_pair is trivially assignable
+ EXPECT_TRUE(
+ (absl::is_trivially_copy_assignable<simple_pair<int, char*>>::value));
+ EXPECT_TRUE(
+ (absl::is_trivially_copy_assignable<simple_pair<int, Trivial>>::value));
+ EXPECT_TRUE((absl::is_trivially_copy_assignable<
+ simple_pair<int, TrivialCopyAssign>>::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<std::string>::value);
EXPECT_FALSE(absl::is_trivially_copy_assignable<std::vector<int>>::value);
- // types with deleted copy assignment are not copy assignable
- EXPECT_FALSE(absl::is_trivially_copy_assignable<NonCopyable>::value);
-}
-
-TEST(TypeTraitsTest, TestTrivialDestructor) {
- // Verify that arithmetic types and pointers have trivial copy
- // constructors.
- EXPECT_TRUE(absl::is_trivially_destructible<bool>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<char>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<unsigned char>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<signed char>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<wchar_t>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<int>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<unsigned int>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<int16_t>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<uint16_t>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<int64_t>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<uint64_t>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<float>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<double>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<long double>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<std::string*>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<Trivial*>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<const TrivialCopyCtor*>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<TrivialCopyCtor**>::value);
-
- // classes with destructors
- EXPECT_TRUE(absl::is_trivially_destructible<Trivial>::value);
- EXPECT_TRUE(absl::is_trivially_destructible<TrivialDestructor>::value);
- EXPECT_FALSE(absl::is_trivially_destructible<NonTrivialDestructor>::value);
-
- // std::pair of such types is trivial
- EXPECT_TRUE((absl::is_trivially_destructible<std::pair<int, int>>::value));
- EXPECT_TRUE((absl::is_trivially_destructible<
- std::pair<Trivial, TrivialDestructor>>::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<int, std::string>>::value));
+ EXPECT_FALSE((absl::is_trivially_copy_assignable<
+ simple_pair<std::string, int>>::value));
- // array of such types is trivial
- typedef int int10[10];
- EXPECT_TRUE(absl::is_trivially_destructible<int10>::value);
- typedef TrivialDestructor TrivialDestructor10[10];
- EXPECT_TRUE(absl::is_trivially_destructible<TrivialDestructor10>::value);
- typedef NonTrivialDestructor NonTrivialDestructor10[10];
- EXPECT_FALSE(absl::is_trivially_destructible<NonTrivialDestructor10>::value);
+ // Verify that arrays are not trivially copy assignable
+ using int10 = int[10];
+ EXPECT_FALSE(absl::is_trivially_copy_assignable<int10>::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<char>::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: