1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 12:43:36 +01:00
llvm-mirror/lib/IR
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
..
AbstractCallSite.cpp
AsmWriter.cpp Adding PoisonValue for representing poison value explicitly in IR 2020-11-25 17:33:51 -07:00
Assumptions.cpp [Clang][Attr] Introduce the assume function attribute 2020-12-15 16:51:34 -06:00
AttributeImpl.h
Attributes.cpp Make LLVM build in C++20 mode 2020-12-17 10:44:10 +00:00
AutoUpgrade.cpp OpaquePtr: Require byval on x86_intrcc parameter 0 2020-12-14 16:34:37 -05:00
BasicBlock.cpp Revert "Ensure SplitEdge to return the new block between the two given blocks" 2020-12-16 11:52:30 +00:00
CMakeLists.txt [CSSPGO] Consume pseudo-probe-based AutoFDO profile 2020-12-16 15:57:18 -08:00
Comdat.cpp
ConstantFold.cpp [ConstantFold] Don't fold and/or i1 poison to poison (NFC) 2020-11-30 22:58:31 +09:00
ConstantFold.h
ConstantRange.cpp
Constants.cpp [llvm] Fix for failing test from fdbd84c6c819d4462546961f6086c1524d5d5ae8 2020-12-01 15:47:55 -08:00
ConstantsContext.h
Core.cpp Creating a named struct requires only a Context and a name, but looking up a struct by name requires a Module. The method on Module merely accesses the LLVMContextImpl and no data from the module itself, so this patch moves getTypeByName to a static method on StructType that takes a Context and a name. 2020-11-30 11:34:12 -08:00
DataLayout.cpp [DL] Inline getAlignmentInfo() implementation (NFC) 2020-11-30 20:56:15 +01:00
DebugInfo.cpp Migrate deprecated DebugLoc::get to DILocation::get 2020-12-11 12:45:22 -08:00
DebugInfoMetadata.cpp
DebugLoc.cpp [IR] Delete deprecated DebugLoc::get 2020-12-15 14:53:12 -08:00
DiagnosticHandler.cpp
DiagnosticInfo.cpp [Support] Introduce a new InstructionCost class 2020-12-11 08:12:54 +00:00
DiagnosticPrinter.cpp
DIBuilder.cpp
Dominators.cpp
FPEnv.cpp
Function.cpp Small improvements to Intrinsic::getName 2020-12-02 16:49:12 -08:00
Globals.cpp
GVMaterializer.cpp
InlineAsm.cpp
Instruction.cpp
Instructions.cpp [CallBase] Add hasRetAttr version that takes StringRef. 2020-12-10 17:00:16 +00:00
IntrinsicInst.cpp [VP] Build VP SDNodes 2020-12-09 11:36:51 +01:00
IRBuilder.cpp [LoopVectorizer][SVE] Vectorize a simple loop with with a scalable VF. 2020-12-09 11:25:21 +00:00
IRPrintingPasses.cpp [NewPM] Support --print-before/after in NPM 2020-12-03 16:52:14 -08:00
LegacyPassManager.cpp [NewPM] Support --print-before/after in NPM 2020-12-03 16:52:14 -08:00
LLVMContext.cpp [Remarks][2/2] Expand remarks hotness threshold option support in more tools 2020-11-30 21:55:50 -08:00
LLVMContextImpl.cpp Fix use-of-uninitialized-value in rG75f50e15bf8f 2020-11-26 01:39:22 -07:00
LLVMContextImpl.h [Remarks][1/2] Expand remarks hotness threshold option support in more tools 2020-11-30 21:55:49 -08:00
LLVMRemarkStreamer.cpp [Remarks][2/2] Expand remarks hotness threshold option support in more tools 2020-11-30 21:55:50 -08:00
Mangler.cpp
MDBuilder.cpp [CSSPGO] Pseudo probe encoding and emission. 2020-12-10 17:29:28 -08:00
Metadata.cpp [IR] Use llvm::is_contained (NFC) 2020-12-08 19:06:37 -08:00
MetadataImpl.h
Module.cpp [Remarks][2/2] Expand remarks hotness threshold option support in more tools 2020-11-30 21:55:50 -08:00
ModuleSummaryIndex.cpp
Operator.cpp
OptBisect.cpp
Pass.cpp [LegacyPM] Remove unused undocumented parameter. NFC. 2020-11-27 10:41:38 +00:00
PassInstrumentation.cpp [NewPM] Support --print-before/after in NPM 2020-12-03 16:52:14 -08:00
PassManager.cpp [NewPM] Make pass adaptors less templatey 2020-12-04 08:30:50 -08:00
PassRegistry.cpp
PassTimingInfo.cpp [Time-report] Add a flag -ftime-report={per-pass,per-pass-run} to control the pass timing aggregation 2020-12-08 10:13:19 -08:00
PrintPasses.cpp [IR] Use llvm::is_contained (NFC) 2020-12-08 19:06:37 -08:00
ProfileSummary.cpp
PseudoProbe.cpp [CSSPGO] Consume pseudo-probe-based AutoFDO profile 2020-12-16 15:57:18 -08:00
SafepointIRVerifier.cpp
Statepoint.cpp
StructuralHash.cpp
SymbolTableListTraitsImpl.h
Type.cpp [IR] Remove isPowerOf2ByteWidth 2020-12-14 23:00:17 -08:00
TypeFinder.cpp
Use.cpp
User.cpp
Value.cpp
ValueSymbolTable.cpp
Verifier.cpp [clang][IR] Add support for leaf attribute 2020-12-14 14:48:17 -08:00