From 5aa5d282eac56a21e74611c1cdbaa97bb5db2dca Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Tue, 8 Feb 2022 02:05:36 +0300 Subject: chore(3p/abseil_cpp): unvendor abseil_cpp we weren't actually using these sources anymore, okay? Change-Id: If701571d9716de308d3512e1eb22c35db0877a66 Reviewed-on: https://cl.tvl.fyi/c/depot/+/5248 Tested-by: BuildkiteCI Reviewed-by: grfn Autosubmit: tazjin --- third_party/abseil_cpp/absl/memory/BUILD.bazel | 65 -- third_party/abseil_cpp/absl/memory/CMakeLists.txt | 55 -- third_party/abseil_cpp/absl/memory/memory.h | 699 --------------------- .../absl/memory/memory_exception_safety_test.cc | 57 -- third_party/abseil_cpp/absl/memory/memory_test.cc | 650 ------------------- 5 files changed, 1526 deletions(-) delete mode 100644 third_party/abseil_cpp/absl/memory/BUILD.bazel delete mode 100644 third_party/abseil_cpp/absl/memory/CMakeLists.txt delete mode 100644 third_party/abseil_cpp/absl/memory/memory.h delete mode 100644 third_party/abseil_cpp/absl/memory/memory_exception_safety_test.cc delete mode 100644 third_party/abseil_cpp/absl/memory/memory_test.cc (limited to 'third_party/abseil_cpp/absl/memory') diff --git a/third_party/abseil_cpp/absl/memory/BUILD.bazel b/third_party/abseil_cpp/absl/memory/BUILD.bazel deleted file mode 100644 index d2824a05adda..000000000000 --- a/third_party/abseil_cpp/absl/memory/BUILD.bazel +++ /dev/null @@ -1,65 +0,0 @@ -# -# Copyright 2019 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 -# -# https://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. -# - -load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") -load( - "//absl:copts/configure_copts.bzl", - "ABSL_DEFAULT_COPTS", - "ABSL_DEFAULT_LINKOPTS", - "ABSL_TEST_COPTS", -) - -package(default_visibility = ["//visibility:public"]) - -licenses(["notice"]) - -cc_library( - name = "memory", - hdrs = ["memory.h"], - copts = ABSL_DEFAULT_COPTS, - linkopts = ABSL_DEFAULT_LINKOPTS, - deps = [ - "//absl/base:core_headers", - "//absl/meta:type_traits", - ], -) - -cc_test( - name = "memory_test", - srcs = ["memory_test.cc"], - copts = ABSL_TEST_COPTS, - linkopts = ABSL_DEFAULT_LINKOPTS, - deps = [ - ":memory", - "//absl/base:core_headers", - "@com_google_googletest//:gtest_main", - ], -) - -cc_test( - name = "memory_exception_safety_test", - srcs = [ - "memory_exception_safety_test.cc", - ], - copts = ABSL_TEST_COPTS, - linkopts = ABSL_DEFAULT_LINKOPTS, - deps = [ - ":memory", - "//absl/base:config", - "//absl/base:exception_safety_testing", - "@com_google_googletest//:gtest_main", - ], -) diff --git a/third_party/abseil_cpp/absl/memory/CMakeLists.txt b/third_party/abseil_cpp/absl/memory/CMakeLists.txt deleted file mode 100644 index 78fb7e1b316b..000000000000 --- a/third_party/abseil_cpp/absl/memory/CMakeLists.txt +++ /dev/null @@ -1,55 +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 -# -# https://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. -# - -absl_cc_library( - NAME - memory - HDRS - "memory.h" - COPTS - ${ABSL_DEFAULT_COPTS} - DEPS - absl::core_headers - absl::meta - PUBLIC -) - -absl_cc_test( - NAME - memory_test - SRCS - "memory_test.cc" - COPTS - ${ABSL_TEST_COPTS} - DEPS - absl::memory - absl::core_headers - gmock_main -) - -absl_cc_test( - NAME - memory_exception_safety_test - SRCS - "memory_exception_safety_test.cc" - COPTS - ${ABSL_TEST_COPTS} - DEPS - absl::memory - absl::config - absl::exception_safety_testing - gmock_main -) diff --git a/third_party/abseil_cpp/absl/memory/memory.h b/third_party/abseil_cpp/absl/memory/memory.h deleted file mode 100644 index 2b5ff623d430..000000000000 --- a/third_party/abseil_cpp/absl/memory/memory.h +++ /dev/null @@ -1,699 +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 -// -// https://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. -// -// ----------------------------------------------------------------------------- -// File: memory.h -// ----------------------------------------------------------------------------- -// -// This header file contains utility functions for managing the creation and -// conversion of smart pointers. This file is an extension to the C++ -// standard library header file. - -#ifndef ABSL_MEMORY_MEMORY_H_ -#define ABSL_MEMORY_MEMORY_H_ - -#include -#include -#include -#include -#include -#include - -#include "absl/base/macros.h" -#include "absl/meta/type_traits.h" - -namespace absl { -ABSL_NAMESPACE_BEGIN - -// ----------------------------------------------------------------------------- -// Function Template: WrapUnique() -// ----------------------------------------------------------------------------- -// -// Adopts ownership from a raw pointer and transfers it to the returned -// `std::unique_ptr`, whose type is deduced. Because of this deduction, *do not* -// specify the template type `T` when calling `WrapUnique`. -// -// Example: -// X* NewX(int, int); -// auto x = WrapUnique(NewX(1, 2)); // 'x' is std::unique_ptr. -// -// Do not call WrapUnique with an explicit type, as in -// `WrapUnique(NewX(1, 2))`. The purpose of WrapUnique is to automatically -// deduce the pointer type. If you wish to make the type explicit, just use -// `std::unique_ptr` directly. -// -// auto x = std::unique_ptr(NewX(1, 2)); -// - or - -// std::unique_ptr x(NewX(1, 2)); -// -// While `absl::WrapUnique` is useful for capturing the output of a raw -// pointer factory, prefer 'absl::make_unique(args...)' over -// 'absl::WrapUnique(new T(args...))'. -// -// auto x = WrapUnique(new X(1, 2)); // works, but nonideal. -// auto x = make_unique(1, 2); // safer, standard, avoids raw 'new'. -// -// Note that `absl::WrapUnique(p)` is valid only if `delete p` is a valid -// expression. In particular, `absl::WrapUnique()` cannot wrap pointers to -// arrays, functions or void, and it must not be used to capture pointers -// obtained from array-new expressions (even though that would compile!). -template -std::unique_ptr WrapUnique(T* ptr) { - static_assert(!std::is_array::value, "array types are unsupported"); - static_assert(std::is_object::value, "non-object types are unsupported"); - return std::unique_ptr(ptr); -} - -namespace memory_internal { - -// Traits to select proper overload and return type for `absl::make_unique<>`. -template -struct MakeUniqueResult { - using scalar = std::unique_ptr; -}; -template -struct MakeUniqueResult { - using array = std::unique_ptr; -}; -template -struct MakeUniqueResult { - using invalid = void; -}; - -} // namespace memory_internal - -// gcc 4.8 has __cplusplus at 201301 but the libstdc++ shipped with it doesn't -// define make_unique. Other supported compilers either just define __cplusplus -// as 201103 but have make_unique (msvc), or have make_unique whenever -// __cplusplus > 201103 (clang). -#if (__cplusplus > 201103L || defined(_MSC_VER)) && \ - !(defined(__GLIBCXX__) && !defined(__cpp_lib_make_unique)) -using std::make_unique; -#else -// ----------------------------------------------------------------------------- -// Function Template: make_unique() -// ----------------------------------------------------------------------------- -// -// Creates a `std::unique_ptr<>`, while avoiding issues creating temporaries -// during the construction process. `absl::make_unique<>` also avoids redundant -// type declarations, by avoiding the need to explicitly use the `new` operator. -// -// This implementation of `absl::make_unique<>` is designed for C++11 code and -// will be replaced in C++14 by the equivalent `std::make_unique<>` abstraction. -// `absl::make_unique<>` is designed to be 100% compatible with -// `std::make_unique<>` so that the eventual migration will involve a simple -// rename operation. -// -// For more background on why `std::unique_ptr(new T(a,b))` is problematic, -// see Herb Sutter's explanation on -// (Exception-Safe Function Calls)[https://herbsutter.com/gotw/_102/]. -// (In general, reviewers should treat `new T(a,b)` with scrutiny.) -// -// Example usage: -// -// auto p = make_unique(args...); // 'p' is a std::unique_ptr -// auto pa = make_unique(5); // 'pa' is a std::unique_ptr -// -// Three overloads of `absl::make_unique` are required: -// -// - For non-array T: -// -// Allocates a T with `new T(std::forward args...)`, -// forwarding all `args` to T's constructor. -// Returns a `std::unique_ptr` owning that object. -// -// - For an array of unknown bounds T[]: -// -// `absl::make_unique<>` will allocate an array T of type U[] with -// `new U[n]()` and return a `std::unique_ptr` owning that array. -// -// Note that 'U[n]()' is different from 'U[n]', and elements will be -// value-initialized. Note as well that `std::unique_ptr` will perform its -// own destruction of the array elements upon leaving scope, even though -// the array [] does not have a default destructor. -// -// NOTE: an array of unknown bounds T[] may still be (and often will be) -// initialized to have a size, and will still use this overload. E.g: -// -// auto my_array = absl::make_unique(10); -// -// - For an array of known bounds T[N]: -// -// `absl::make_unique<>` is deleted (like with `std::make_unique<>`) as -// this overload is not useful. -// -// NOTE: an array of known bounds T[N] is not considered a useful -// construction, and may cause undefined behavior in templates. E.g: -// -// auto my_array = absl::make_unique(); -// -// In those cases, of course, you can still use the overload above and -// simply initialize it to its desired size: -// -// auto my_array = absl::make_unique(10); - -// `absl::make_unique` overload for non-array types. -template -typename memory_internal::MakeUniqueResult::scalar make_unique( - Args&&... args) { - return std::unique_ptr(new T(std::forward(args)...)); -} - -// `absl::make_unique` overload for an array T[] of unknown bounds. -// The array allocation needs to use the `new T[size]` form and cannot take -// element constructor arguments. The `std::unique_ptr` will manage destructing -// these array elements. -template -typename memory_internal::MakeUniqueResult::array make_unique(size_t n) { - return std::unique_ptr(new typename absl::remove_extent_t[n]()); -} - -// `absl::make_unique` overload for an array T[N] of known bounds. -// This construction will be rejected. -template -typename memory_internal::MakeUniqueResult::invalid make_unique( - Args&&... /* args */) = delete; -#endif - -// ----------------------------------------------------------------------------- -// Function Template: RawPtr() -// ----------------------------------------------------------------------------- -// -// Extracts the raw pointer from a pointer-like value `ptr`. `absl::RawPtr` is -// useful within templates that need to handle a complement of raw pointers, -// `std::nullptr_t`, and smart pointers. -template -auto RawPtr(T&& ptr) -> decltype(std::addressof(*ptr)) { - // ptr is a forwarding reference to support Ts with non-const operators. - return (ptr != nullptr) ? std::addressof(*ptr) : nullptr; -} -inline std::nullptr_t RawPtr(std::nullptr_t) { return nullptr; } - -// ----------------------------------------------------------------------------- -// Function Template: ShareUniquePtr() -// ----------------------------------------------------------------------------- -// -// Adopts a `std::unique_ptr` rvalue and returns a `std::shared_ptr` of deduced -// type. Ownership (if any) of the held value is transferred to the returned -// shared pointer. -// -// Example: -// -// auto up = absl::make_unique(10); -// auto sp = absl::ShareUniquePtr(std::move(up)); // shared_ptr -// CHECK_EQ(*sp, 10); -// CHECK(up == nullptr); -// -// Note that this conversion is correct even when T is an array type, and more -// generally it works for *any* deleter of the `unique_ptr` (single-object -// deleter, array deleter, or any custom deleter), since the deleter is adopted -// by the shared pointer as well. The deleter is copied (unless it is a -// reference). -// -// Implements the resolution of [LWG 2415](http://wg21.link/lwg2415), by which a -// null shared pointer does not attempt to call the deleter. -template -std::shared_ptr ShareUniquePtr(std::unique_ptr&& ptr) { - return ptr ? std::shared_ptr(std::move(ptr)) : std::shared_ptr(); -} - -// ----------------------------------------------------------------------------- -// Function Template: WeakenPtr() -// ----------------------------------------------------------------------------- -// -// Creates a weak pointer associated with a given shared pointer. The returned -// value is a `std::weak_ptr` of deduced type. -// -// Example: -// -// auto sp = std::make_shared(10); -// auto wp = absl::WeakenPtr(sp); -// CHECK_EQ(sp.get(), wp.lock().get()); -// sp.reset(); -// CHECK(wp.lock() == nullptr); -// -template -std::weak_ptr WeakenPtr(const std::shared_ptr& ptr) { - return std::weak_ptr(ptr); -} - -namespace memory_internal { - -// ExtractOr::type evaluates to E if possible. Otherwise, D. -template