1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/unittests/ADT
Barry Revzin 2fc9f32ca3 Make LLVM build in C++20 mode
Part of the <=> changes in C++20 make certain patterns of writing equality
operators ambiguous with themselves (sorry!).
This patch goes through and adjusts all the comparison operators such that
they should work in both C++17 and C++20 modes. It also makes two other small
C++20-specific changes (adding a constructor to a type that cases to be an
aggregate, and adding casts from u8 literals which no longer have type
const char*).

There were four categories of errors that this review fixes.
Here are canonical examples of them, ordered from most to least common:

// 1) Missing const
namespace missing_const {
    struct A {
    #ifndef FIXED
        bool operator==(A const&);
    #else
        bool operator==(A const&) const;
    #endif
    };

    bool a = A{} == A{}; // error
}

// 2) Type mismatch on CRTP
namespace crtp_mismatch {
    template <typename Derived>
    struct Base {
    #ifndef FIXED
        bool operator==(Derived const&) const;
    #else
        // in one case changed to taking Base const&
        friend bool operator==(Derived const&, Derived const&);
    #endif
    };

    struct D : Base<D> { };

    bool b = D{} == D{}; // error
}

// 3) iterator/const_iterator with only mixed comparison
namespace iter_const_iter {
    template <bool Const>
    struct iterator {
        using const_iterator = iterator<true>;

        iterator();

        template <bool B, std::enable_if_t<(Const && !B), int> = 0>
        iterator(iterator<B> const&);

    #ifndef FIXED
        bool operator==(const_iterator const&) const;
    #else
        friend bool operator==(iterator const&, iterator const&);
    #endif
    };

    bool c = iterator<false>{} == iterator<false>{} // error
          || iterator<false>{} == iterator<true>{}
          || iterator<true>{} == iterator<false>{}
          || iterator<true>{} == iterator<true>{};
}

// 4) Same-type comparison but only have mixed-type operator
namespace ambiguous_choice {
    enum Color { Red };

    struct C {
        C();
        C(Color);
        operator Color() const;
        bool operator==(Color) const;
        friend bool operator==(C, C);
    };

    bool c = C{} == C{}; // error
    bool d = C{} == Red;
}

Differential revision: https://reviews.llvm.org/D78938
2020-12-17 10:44:10 +00:00
..
AnyTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
APFixedPointTest.cpp [Fixed Point] Add floating point methods to APFixedPoint. 2020-10-09 10:27:42 +02:00
APFloatTest.cpp [APFloat] convert SNaN to QNaN in convert() and raise Invalid signal 2020-10-01 14:37:38 -04:00
APIntTest.cpp [APInt] Add the truncOrSelf resizing operator to APInt 2020-11-23 11:27:30 +00:00
APSIntTest.cpp ADT: Fix that APSInt's string constructor claims it requires 5 bits to store a zero 2020-06-10 16:36:33 +02:00
ArrayRefTest.cpp Switch from llvm::is_trivially_copyable to std::is_trivially_copyable 2020-12-02 22:02:48 -08:00
BitFieldsTest.cpp [Bitfields][NFC] Make sure bitfields are contiguous 2020-07-07 14:35:13 +00:00
BitmaskEnumTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
BitVectorTest.cpp Fix bug in SmallBitVector::find_next_unset 2020-04-24 13:50:30 -07:00
BreadthFirstIteratorTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
BumpPtrListTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
CMakeLists.txt [ADT] Move FixedPoint.h from Clang to LLVM. 2020-08-20 10:29:45 +02:00
CoalescingBitVectorTest.cpp [LiveDebugValues] Speed up removeEntryValue, NFC 2020-06-01 11:02:36 -07:00
DAGDeltaAlgorithmTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DeltaAlgorithmTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DenseMapTest.cpp [ADT] Allow K to be incomplete during DenseMap<K*, V> instantiation 2020-02-28 14:24:04 -08:00
DenseSetTest.cpp [llvm] Add contains(KeyType) -> bool methods to DenseSet 2020-07-17 11:26:26 -07:00
DepthFirstIteratorTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
DirectedGraphTest.cpp [DDG] DirectedGraph as a base class for various dependence graphs such 2019-07-25 18:23:22 +00:00
EnumeratedArrayTest.cpp [DDG] Data Dependence Graph - Pi Block 2019-11-08 15:46:08 -05:00
EquivalenceClassesTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FallibleIteratorTest.cpp [ADT] Add a fallible_iterator wrapper. 2019-02-05 23:17:11 +00:00
FloatingPointMode.cpp Separately track input and output denormal mode 2020-02-04 12:59:21 -05:00
FoldingSet.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
FunctionExtrasTest.cpp Reland [ADT] Support const-qualified unique_functions 2020-06-29 21:40:16 +02:00
FunctionRefTest.cpp [ADT] Fix accidental pointer comparison in test 2020-10-27 18:11:45 +01:00
HashingTest.cpp Add hashing support for std::tuple 2020-07-16 19:01:25 +02:00
IListBaseTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
IListIteratorTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
IListNodeBaseTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
IListNodeTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
IListSentinelTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
IListTest.cpp [ADT] Notify ilist traits about in-list transfers 2019-01-23 22:59:52 +00:00
ImmutableListTest.cpp Switch from llvm::is_trivially_copyable to std::is_trivially_copyable 2020-12-02 22:02:48 -08:00
ImmutableMapTest.cpp [ADT] Fix for ImmutableMapRef 2020-10-29 13:19:51 +01:00
ImmutableSetTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
IntEqClassesTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
IntervalMapTest.cpp [ADT] Add CoalescingBitVector, implemented using IntervalMap [1/3] 2020-02-27 12:39:46 -08:00
IntrusiveRefCntPtrTest.cpp ADT: Allow IntrusiveRefCntPtr construction from std::unique_ptr, NFC 2020-12-08 17:33:19 -08:00
IteratorTest.cpp [ADT] Move drop_begin from iterator_range.h into STLExtras. 2019-11-14 08:10:59 -08:00
MappedIteratorTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
MapVectorTest.cpp Github access test: remove unnecessary whitespaces. 2020-05-20 09:53:44 +01:00
OptionalTest.cpp ADT: Add hash_value overload for Optional 2020-12-08 15:25:03 -08:00
PackedVectorTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
PointerEmbeddedIntTest.cpp PointerLikeTypeTraits: Standardize NumLowBitsAvailable on static constexpr rather than anonymous enum 2020-01-16 15:30:50 -08:00
PointerIntPairTest.cpp Switch from llvm::is_trivially_copyable to std::is_trivially_copyable 2020-12-02 22:02:48 -08:00
PointerSumTypeTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
PointerUnionTest.cpp Removed PointerUnion3 and PointerUnion4 aliases in favor of the variadic template 2020-01-14 18:56:29 +01:00
PostOrderIteratorTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
PriorityWorklistTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
RangeAdapterTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SCCIteratorTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
ScopeExitTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SequenceTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SetVectorTest.cpp [llvm] Add contains(KeyType) -> bool methods to SetVector 2020-07-17 11:26:27 -07:00
SimpleIListTest.cpp [ADT/STLExtras.h] - Add llvm::is_sorted wrapper and update callers. 2020-04-14 14:11:02 +03:00
SmallPtrSetTest.cpp [llvm] Add contains(KeyType) -> bool methods to SmallPtrSet 2020-07-17 11:26:27 -07:00
SmallSetTest.cpp [llvm] Add contains(KeyType) -> bool methods to SmallSet 2020-07-17 11:26:27 -07:00
SmallStringTest.cpp [ADT] Add methods to SmallString for efficient concatenation 2020-10-30 10:07:40 +00:00
SmallVectorTest.cpp [SmallVector] Allow SmallVector<T> 2020-12-03 17:21:44 -08:00
SparseBitVectorTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SparseMultiSetTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
SparseSetTest.cpp [llvm] Add contains(KeyType) -> bool methods to SparseSet 2020-07-17 11:26:27 -07:00
StatisticTest.cpp [ADT][Statistics] Fix test after rL374490 2019-10-11 07:19:54 +00:00
STLExtrasTest.cpp Make LLVM build in C++20 mode 2020-12-17 10:44:10 +00:00
StringExtrasTest.cpp [llvm][StringExtras] Add a fail-able version of fromHex 2020-10-28 16:58:06 -07:00
StringMapTest.cpp [clang-tidy] remove duplicate fixes of alias checkers 2020-06-19 20:40:59 +01:00
StringRefTest.cpp Switch from llvm::is_trivially_copyable to std::is_trivially_copyable 2020-12-02 22:02:48 -08:00
StringSetTest.cpp [llvm] Add contains(KeyType) -> bool methods to StringSet 2020-07-17 11:26:27 -07:00
StringSwitchTest.cpp Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
TestGraph.h [ADT] Fixed -Wdeprecated-copy warning. NFCI 2019-11-28 00:49:42 +01:00
TinyPtrVectorTest.cpp Add TinyPtrVector support for general pointer-like things. 2019-08-20 23:29:28 +00:00
TripleTest.cpp [Triple][MachO] Define "arm64e", an AArch64 subarch for Pointer Auth. 2020-12-03 07:53:59 -08:00
TwineTest.cpp [llvm][NFC] Add missing 'override's in unittests/ 2020-07-17 17:35:59 -07:00
TypeSwitchTest.cpp [llvm][ADT] Move TypeSwitch class from MLIR to LLVM 2020-04-14 15:14:41 -07:00
TypeTraitsTest.cpp [mlir][NFC] Remove the STLExtras.h header file now that it has been merged into LLVM. 2020-04-14 15:14:41 -07:00
WaymarkingTest.cpp [ADT] Implement the Waymarking as an independent utility 2020-03-31 17:08:24 +03:00