1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/tools
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
..
bugpoint llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
bugpoint-passes Reverted the remainings of c1c9819ef91aab51b5a23fb3027adac5a2f551cc 2020-02-11 16:20:06 -08:00
dsymutil [dsymutil][DWARFLinker][NFC] Make interface of AddressMap more general. 2020-12-10 14:57:08 +03:00
gold Use basic_string::find(char) instead of basic_string::find(const char *s, size_type pos=0) 2020-12-16 23:28:32 -08:00
llc [ScalarizeMaskedMemIntrin] Add new PM support 2020-12-08 17:15:22 -05:00
lli llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-ar llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-as llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-as-fuzzer Fix several places that were calling verifyFunction or verifyModule without checking the return value. 2020-05-18 13:28:46 -07:00
llvm-bcanalyzer llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-c-test [llvm-c] Delete unimplemented llvm-c/LinkTimeOptimizer.h 2020-12-06 15:18:25 -08:00
llvm-cat llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-cfi-verify llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-config [MinGW] Use lib prefix for libraries 2020-09-12 22:01:29 +03:00
llvm-cov llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-cvtres llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-cxxdump llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-cxxfilt Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
llvm-cxxmap llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-diff Switch from llvm::is_trivially_copyable to std::is_trivially_copyable 2020-12-02 22:02:48 -08:00
llvm-dis llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-dwarfdump llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-dwp llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-elfabi [llvm-elfabi] Emit ELF header and string table sections 2020-11-23 12:18:58 -08:00
llvm-exegesis [llvm-exegesis][PowerPC] Add more register classes 2020-12-04 15:02:12 +00:00
llvm-extract llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-go Reinstate llvm-go to test the go bindings. 2020-02-13 17:24:55 -08:00
llvm-gsymutil [lib/Object, tools] - Make ELFObjectFile::getELFFile return reference. 2020-12-04 16:02:29 +03:00
llvm-ifs llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-isel-fuzzer [AIX] Turn -fdata-sections on by default in Clang 2020-10-14 15:58:31 +00:00
llvm-itanium-demangle-fuzzer Fix file header issues in fuzzers. NFC 2019-02-21 07:57:14 +00:00
llvm-jitlink Re-apply 8904ee8ac7e with missing header included this time. 2020-12-14 13:39:33 +11:00
llvm-jitlistener [MCJIT] Profile the code generated by MCJIT engine using Intel VTune profiler 2020-11-16 19:28:14 +11:00
llvm-libtool-darwin llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-link [llvm-link][NFC] Minor cleanup 2020-12-09 23:16:13 -08:00
llvm-lipo llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-lto Use basic_string::find(char) instead of basic_string::find(const char *s, size_type pos=0) 2020-12-16 23:28:32 -08:00
llvm-lto2 [llvm-lto2] Use NPM with ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER 2020-12-08 11:43:19 -08:00
llvm-mc [llvm][clang][mlir] Add checks for the return values from Target::createXXX to prevent protential null deref 2020-11-21 21:04:12 -08:00
llvm-mc-assemble-fuzzer Add missing include Host.h in llvm-mc-* fuzzers. NFC. 2020-05-18 02:21:22 +07:00
llvm-mc-disassemble-fuzzer Add missing include Host.h in llvm-mc-* fuzzers. NFC. 2020-05-18 02:21:22 +07:00
llvm-mca [llvm][clang][mlir] Add checks for the return values from Target::createXXX to prevent protential null deref 2020-11-21 21:04:12 -08:00
llvm-microsoft-demangle-fuzzer Give microsoftDemangle() an outparam for how many input bytes were consumed. 2020-05-20 16:17:31 -04:00
llvm-ml [ms] [llvm-ml] Support command-line defines 2020-12-01 18:06:05 -05:00
llvm-modextract llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-mt llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-nm [llvm-nm][MachO] Don't call getFlags on redacted symbols 2020-12-04 21:48:53 -08:00
llvm-objcopy [lib/Object, tools] - Make ELFObjectFile::getELFFile return reference. 2020-12-04 16:02:29 +03:00
llvm-objdump Make LLVM build in C++20 mode 2020-12-17 10:44:10 +00:00
llvm-opt-fuzzer [NFC] Clean up PassBuilder 2020-10-30 10:03:59 -07:00
llvm-opt-report Make llvm::StringRef to std::string conversions explicit. 2020-01-28 23:25:25 +01:00
llvm-pdbutil llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-profdata [CSSPGO] Consume pseudo-probe-based AutoFDO profile 2020-12-16 15:57:18 -08:00
llvm-profgen [llvm-profgen][NFC] Fix test failure by making unwinder's output deterministic 2020-12-07 22:36:25 -08:00
llvm-rc [llvm-rc] Handle driveless absolute windows paths when loading external files 2020-12-10 14:11:06 +02:00
llvm-readobj [llvm-readelf/obj] - Handle out-of-order PT_LOADs better. 2020-12-16 12:59:32 +03:00
llvm-reduce llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-rtdyld [llvm][clang][mlir] Add checks for the return values from Target::createXXX to prevent protential null deref 2020-11-21 21:04:12 -08:00
llvm-shlib [Support] On Windows, add optional support for {rpmalloc|snmalloc|mimalloc} 2020-08-27 11:09:46 -04:00
llvm-size llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-special-case-list-fuzzer Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
llvm-split llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-stress llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-strings llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-symbolizer [llvm-symbolizer] Add missing include for config.h 2020-12-15 09:20:31 -08:00
llvm-undname llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
llvm-xray Internalize functions from various tools. NFC 2020-09-26 15:57:13 -07:00
llvm-yaml-numeric-parser-fuzzer Fix file header issues in fuzzers. NFC 2019-02-21 07:57:14 +00:00
llvm-yaml-parser-fuzzer [YAMLIO] Support non-null-terminated inputs 2020-11-18 23:06:03 +00:00
lto [AIX] Turn -fdata-sections on by default in Clang 2020-10-14 15:58:31 +00:00
msbuild vs integration: bump version nbr 2019-06-19 07:39:53 +00:00
obj2yaml [yaml2obj/obj2yaml] - Make Value/Size fields of Symbol optional. 2020-12-16 13:49:57 +03:00
opt [opt][NPM] Pin -lower-amx-type to legacy PM 2020-12-13 19:16:20 -08:00
opt-viewer Convert old python3 cgi method into the new html one 2020-03-25 22:38:55 +01:00
remarks-shlib [tools][remarks-shlib] Don't build libRemarks.so without PIC 2020-09-20 12:40:21 +02:00
sancov [Support] Use InitLLVM in llvm-stress, sancov and TableGen 2020-07-28 07:50:45 -04:00
sanstats Internalize functions from various tools. NFC 2020-09-26 15:57:13 -07:00
split-file [split-file] Fix sys::fs::remove() on Solaris after D83834 2020-08-11 08:05:10 -07:00
verify-uselistorder llvmbuildectomy - replace llvm-build by plain cmake 2020-11-13 10:35:24 +01:00
vfabi-demangle-fuzzer [llvm][VectorUtils] Tweak VFShape for scalable vector functions. 2020-01-30 05:53:56 +00:00
xcode-toolchain [CMake] Use LLVM_ENABLE_IDE instead of CMAKE_CONFIGURATION_TYPES 2018-10-15 21:20:02 +00:00
yaml2obj [llvm] Make obj2yaml and yaml2obj LLVM utilities instead of tools 2020-10-19 10:21:21 -07:00
CMakeLists.txt [Flang] add flang as a new subproject in cmake 2020-04-09 16:13:18 +01:00