forked from OSchip/llvm-project
[ADT] Replace STLForwardCompat.h's C++17 equivalents
STLForwardCompat.h defines several utilities and type traits to mimic that of the ones in the C++17 standard library. Now that LLVM is built with the C++17 standards mode, remove use of these equivalents in favor of the ones from the standard library. Differential Revision: https://reviews.llvm.org/D131717
This commit is contained in:
parent
0581ab65ea
commit
e8578968f6
|
@ -22,6 +22,8 @@
|
|||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/Support/ErrorOr.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace clang {
|
||||
namespace FileMgr {
|
||||
|
||||
|
@ -125,7 +127,7 @@ public:
|
|||
MapEntryOptionalStorage() : MaybeRef(optional_none_tag()) {}
|
||||
|
||||
template <class... ArgTypes>
|
||||
explicit MapEntryOptionalStorage(llvm::in_place_t, ArgTypes &&...Args)
|
||||
explicit MapEntryOptionalStorage(std::in_place_t, ArgTypes &&...Args)
|
||||
: MaybeRef(std::forward<ArgTypes>(Args)...) {}
|
||||
|
||||
void reset() { MaybeRef = optional_none_tag(); }
|
||||
|
@ -189,8 +191,8 @@ public:
|
|||
OptionalStorage() = default;
|
||||
|
||||
template <class... ArgTypes>
|
||||
explicit OptionalStorage(in_place_t, ArgTypes &&...Args)
|
||||
: StorageImpl(in_place_t{}, std::forward<ArgTypes>(Args)...) {}
|
||||
explicit OptionalStorage(std::in_place_t, ArgTypes &&...Args)
|
||||
: StorageImpl(std::in_place_t{}, std::forward<ArgTypes>(Args)...) {}
|
||||
|
||||
OptionalStorage &operator=(clang::DirectoryEntryRef Ref) {
|
||||
StorageImpl::operator=(Ref);
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
#include "llvm/Support/ErrorOr.h"
|
||||
#include "llvm/Support/FileSystem/UniqueID.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class MemoryBuffer;
|
||||
|
@ -222,8 +224,8 @@ public:
|
|||
OptionalStorage() = default;
|
||||
|
||||
template <class... ArgTypes>
|
||||
explicit OptionalStorage(in_place_t, ArgTypes &&...Args)
|
||||
: StorageImpl(in_place_t{}, std::forward<ArgTypes>(Args)...) {}
|
||||
explicit OptionalStorage(std::in_place_t, ArgTypes &&...Args)
|
||||
: StorageImpl(std::in_place_t{}, std::forward<ArgTypes>(Args)...) {}
|
||||
|
||||
OptionalStorage &operator=(clang::FileEntryRef Ref) {
|
||||
StorageImpl::operator=(Ref);
|
||||
|
|
|
@ -68,8 +68,8 @@ public:
|
|||
// instead.
|
||||
template <typename T,
|
||||
std::enable_if_t<
|
||||
llvm::conjunction<
|
||||
llvm::negation<std::is_same<std::decay_t<T>, Any>>,
|
||||
std::conjunction<
|
||||
std::negation<std::is_same<std::decay_t<T>, Any>>,
|
||||
// We also disable this overload when an `Any` object can be
|
||||
// converted to the parameter type because in that case,
|
||||
// this constructor may combine with that conversion during
|
||||
|
@ -80,7 +80,7 @@ public:
|
|||
// DR in `std::any` as well, but we're going ahead and
|
||||
// adopting it to work-around usage of `Any` with types that
|
||||
// need to be implicitly convertible from an `Any`.
|
||||
llvm::negation<std::is_convertible<Any, std::decay_t<T>>>,
|
||||
std::negation<std::is_convertible<Any, std::decay_t<T>>>,
|
||||
std::is_copy_constructible<std::decay_t<T>>>::value,
|
||||
int> = 0>
|
||||
Any(T &&Value) {
|
||||
|
|
|
@ -65,7 +65,7 @@ template <typename CallableT, typename ThisT>
|
|||
using EnableUnlessSameType =
|
||||
std::enable_if_t<!std::is_same<remove_cvref_t<CallableT>, ThisT>::value>;
|
||||
template <typename CallableT, typename Ret, typename... Params>
|
||||
using EnableIfCallable = std::enable_if_t<llvm::disjunction<
|
||||
using EnableIfCallable = std::enable_if_t<std::disjunction<
|
||||
std::is_void<Ret>,
|
||||
std::is_same<decltype(std::declval<CallableT>()(std::declval<Params>()...)),
|
||||
Ret>,
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
}
|
||||
|
||||
template <class... Args>
|
||||
constexpr explicit OptionalStorage(in_place_t, Args &&...args)
|
||||
constexpr explicit OptionalStorage(std::in_place_t, Args &&...args)
|
||||
: val(std::forward<Args>(args)...), hasVal(true) {}
|
||||
|
||||
void reset() noexcept {
|
||||
|
@ -196,7 +196,7 @@ public:
|
|||
OptionalStorage &operator=(OptionalStorage &&other) = default;
|
||||
|
||||
template <class... Args>
|
||||
constexpr explicit OptionalStorage(in_place_t, Args &&...args)
|
||||
constexpr explicit OptionalStorage(std::in_place_t, Args &&...args)
|
||||
: val(std::forward<Args>(args)...), hasVal(true) {}
|
||||
|
||||
void reset() noexcept {
|
||||
|
@ -275,15 +275,15 @@ public:
|
|||
constexpr Optional() = default;
|
||||
constexpr Optional(NoneType) {}
|
||||
|
||||
constexpr Optional(const T &y) : Storage(in_place, y) {}
|
||||
constexpr Optional(const T &y) : Storage(std::in_place, y) {}
|
||||
constexpr Optional(const Optional &O) = default;
|
||||
|
||||
constexpr Optional(T &&y) : Storage(in_place, std::move(y)) {}
|
||||
constexpr Optional(T &&y) : Storage(std::in_place, std::move(y)) {}
|
||||
constexpr Optional(Optional &&O) = default;
|
||||
|
||||
template <typename... ArgTypes>
|
||||
constexpr Optional(in_place_t, ArgTypes &&...Args)
|
||||
: Storage(in_place, std::forward<ArgTypes>(Args)...) {}
|
||||
constexpr Optional(std::in_place_t, ArgTypes &&...Args)
|
||||
: Storage(std::in_place, std::forward<ArgTypes>(Args)...) {}
|
||||
|
||||
Optional &operator=(T &&y) {
|
||||
Storage = std::move(y);
|
||||
|
|
|
@ -155,12 +155,12 @@ struct function_traits<ReturnType (&)(Args...), false>
|
|||
/// traits class for checking whether type T is one of any of the given
|
||||
/// types in the variadic list.
|
||||
template <typename T, typename... Ts>
|
||||
using is_one_of = disjunction<std::is_same<T, Ts>...>;
|
||||
using is_one_of = std::disjunction<std::is_same<T, Ts>...>;
|
||||
|
||||
/// traits class for checking whether type T is a base class for all
|
||||
/// the given types in the variadic list.
|
||||
template <typename T, typename... Ts>
|
||||
using are_base_of = conjunction<std::is_base_of<T, Ts>...>;
|
||||
using are_base_of = std::conjunction<std::is_base_of<T, Ts>...>;
|
||||
|
||||
namespace detail {
|
||||
template <typename T, typename... Us> struct TypesAreDistinct;
|
||||
|
@ -1386,12 +1386,12 @@ template <> struct rank<0> {};
|
|||
/// traits class for checking whether type T is one of any of the given
|
||||
/// types in the variadic list.
|
||||
template <typename T, typename... Ts>
|
||||
using is_one_of = disjunction<std::is_same<T, Ts>...>;
|
||||
using is_one_of = std::disjunction<std::is_same<T, Ts>...>;
|
||||
|
||||
/// traits class for checking whether type T is a base class for all
|
||||
/// the given types in the variadic list.
|
||||
template <typename T, typename... Ts>
|
||||
using are_base_of = conjunction<std::is_base_of<T, Ts>...>;
|
||||
using are_base_of = std::conjunction<std::is_base_of<T, Ts>...>;
|
||||
|
||||
namespace detail {
|
||||
template <typename... Ts> struct Visitor;
|
||||
|
@ -1550,7 +1550,7 @@ namespace detail {
|
|||
template <typename T>
|
||||
// We can use qsort if the iterator type is a pointer and the underlying value
|
||||
// is trivially copyable.
|
||||
using sort_trivially_copyable = conjunction<
|
||||
using sort_trivially_copyable = std::conjunction<
|
||||
std::is_pointer<T>,
|
||||
std::is_trivially_copyable<typename std::iterator_traits<T>::value_type>>;
|
||||
} // namespace detail
|
||||
|
|
|
@ -76,7 +76,7 @@ protected:
|
|||
|
||||
template <typename... ArgTypes>
|
||||
explicit HashBuilderBase(ArgTypes &&...Args)
|
||||
: OptionalHasher(in_place, std::forward<ArgTypes>(Args)...),
|
||||
: OptionalHasher(std::in_place, std::forward<ArgTypes>(Args)...),
|
||||
Hasher(*OptionalHasher) {}
|
||||
|
||||
private:
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <utility>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
|
@ -201,7 +201,7 @@ TEST(OptionalTest, NullCopyConstructionTest) {
|
|||
|
||||
TEST(OptionalTest, InPlaceConstructionNonDefaultConstructibleTest) {
|
||||
NonDefaultConstructible::ResetCounts();
|
||||
{ Optional<NonDefaultConstructible> A{in_place, 1}; }
|
||||
{ Optional<NonDefaultConstructible> A{std::in_place, 1}; }
|
||||
EXPECT_EQ(0u, NonDefaultConstructible::CopyConstructions);
|
||||
EXPECT_EQ(0u, NonDefaultConstructible::CopyAssignments);
|
||||
EXPECT_EQ(1u, NonDefaultConstructible::Destructions);
|
||||
|
@ -247,7 +247,7 @@ static_assert(!std::is_trivially_copyable<Optional<MultiArgConstructor>>::value,
|
|||
TEST(OptionalTest, Emplace) {
|
||||
MultiArgConstructor::ResetCounts();
|
||||
Optional<MultiArgConstructor> A;
|
||||
|
||||
|
||||
A.emplace(1, 2);
|
||||
EXPECT_TRUE(A.has_value());
|
||||
EXPECT_TRUE(A.has_value());
|
||||
|
@ -266,12 +266,12 @@ TEST(OptionalTest, Emplace) {
|
|||
TEST(OptionalTest, InPlaceConstructionMultiArgConstructorTest) {
|
||||
MultiArgConstructor::ResetCounts();
|
||||
{
|
||||
Optional<MultiArgConstructor> A{in_place, 1, 2};
|
||||
Optional<MultiArgConstructor> A{std::in_place, 1, 2};
|
||||
EXPECT_TRUE(A.has_value());
|
||||
EXPECT_TRUE(A.has_value());
|
||||
EXPECT_EQ(1, A->x);
|
||||
EXPECT_EQ(2, A->y);
|
||||
Optional<MultiArgConstructor> B{in_place, 5, false};
|
||||
Optional<MultiArgConstructor> B{std::in_place, 5, false};
|
||||
EXPECT_TRUE(B.has_value());
|
||||
EXPECT_TRUE(B.has_value());
|
||||
EXPECT_EQ(5, B->x);
|
||||
|
@ -284,7 +284,7 @@ TEST(OptionalTest, InPlaceConstructionMultiArgConstructorTest) {
|
|||
TEST(OptionalTest, InPlaceConstructionAndEmplaceEquivalentTest) {
|
||||
MultiArgConstructor::ResetCounts();
|
||||
{
|
||||
Optional<MultiArgConstructor> A{in_place, 1, 2};
|
||||
Optional<MultiArgConstructor> A{std::in_place, 1, 2};
|
||||
Optional<MultiArgConstructor> B;
|
||||
B.emplace(1, 2);
|
||||
EXPECT_EQ(0u, MultiArgConstructor::Destructions);
|
||||
|
@ -442,7 +442,7 @@ TEST(OptionalTest, ImmovableEmplace) {
|
|||
|
||||
TEST(OptionalTest, ImmovableInPlaceConstruction) {
|
||||
Immovable::ResetCounts();
|
||||
Optional<Immovable> A{in_place, 4};
|
||||
Optional<Immovable> A{std::in_place, 4};
|
||||
EXPECT_TRUE((bool)A);
|
||||
EXPECT_EQ(4, A->val);
|
||||
EXPECT_EQ(1u, Immovable::Constructions);
|
||||
|
|
Loading…
Reference in New Issue