aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-objdump/llvm-objdump.cpp
diff options
context:
space:
mode:
authorBarry Revzin <barry.revzin@gmail.com>2020-12-17 10:41:35 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2020-12-17 10:44:10 +0000
commit92310454bf0f1f9686f38afd11756c7d046495c9 (patch)
tree215f441a9d33a725247cd3df57ca8c8ec0808bdc /llvm/tools/llvm-objdump/llvm-objdump.cpp
parentcdb692ee0c6745ea008ee6cc00fe1e65021516bb (diff)
downloadllvm-92310454bf0f1f9686f38afd11756c7d046495c9.zip
llvm-92310454bf0f1f9686f38afd11756c7d046495c9.tar.gz
llvm-92310454bf0f1f9686f38afd11756c7d046495c9.tar.bz2
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
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r--llvm/tools/llvm-objdump/llvm-objdump.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 6fda093..5ac25d7 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -806,19 +806,19 @@ public:
bool IsASCII = DbgVariables == DVASCII;
switch (C) {
case LineChar::RangeStart:
- return IsASCII ? "^" : u8"\u2548";
+ return IsASCII ? "^" : (const char *)u8"\u2548";
case LineChar::RangeMid:
- return IsASCII ? "|" : u8"\u2503";
+ return IsASCII ? "|" : (const char *)u8"\u2503";
case LineChar::RangeEnd:
- return IsASCII ? "v" : u8"\u253b";
+ return IsASCII ? "v" : (const char *)u8"\u253b";
case LineChar::LabelVert:
- return IsASCII ? "|" : u8"\u2502";
+ return IsASCII ? "|" : (const char *)u8"\u2502";
case LineChar::LabelCornerNew:
- return IsASCII ? "/" : u8"\u250c";
+ return IsASCII ? "/" : (const char *)u8"\u250c";
case LineChar::LabelCornerActive:
- return IsASCII ? "|" : u8"\u2520";
+ return IsASCII ? "|" : (const char *)u8"\u2520";
case LineChar::LabelHoriz:
- return IsASCII ? "-" : u8"\u2500";
+ return IsASCII ? "-" : (const char *)u8"\u2500";
}
llvm_unreachable("Unhandled LineChar enum");
}