diff --git a/ntcore/src/main/native/cpp/net/WebSocketConnection.cpp b/ntcore/src/main/native/cpp/net/WebSocketConnection.cpp index 176770db7f6..ab352888879 100644 --- a/ntcore/src/main/native/cpp/net/WebSocketConnection.cpp +++ b/ntcore/src/main/native/cpp/net/WebSocketConnection.cpp @@ -124,7 +124,7 @@ void WebSocketConnection::SendPing(uint64_t time) { WPI_DEBUG4(m_logger, "conn: sending ping {}", time); auto buf = AllocBuf(); buf.len = 8; - wpi::support::endian::write64(buf.base, time); + wpi::support::endian::write64(buf.base, time); m_ws.SendPing({buf}, [selfweak = weak_from_this()](auto bufs, auto err) { if (auto self = selfweak.lock()) { self->m_err = err; diff --git a/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch b/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch index 20b83645e29..5383582d4b0 100644 --- a/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch +++ b/upstream_utils/llvm_patches/0001-Remove-StringRef-ArrayRef-and-Optional.patch @@ -4,37 +4,37 @@ Date: Sat, 7 May 2022 22:09:18 -0400 Subject: [PATCH 01/34] Remove StringRef, ArrayRef, and Optional --- - llvm/include/llvm/ADT/PointerUnion.h | 1 - - llvm/include/llvm/ADT/SmallSet.h | 2 +- - llvm/include/llvm/ADT/SmallString.h | 77 ++++++++++--------- - llvm/include/llvm/ADT/SmallVector.h | 7 +- - llvm/include/llvm/ADT/StringMap.h | 38 ++++----- - llvm/include/llvm/ADT/StringMapEntry.h | 20 ++--- - llvm/include/llvm/Support/Chrono.h | 10 +-- - llvm/include/llvm/Support/Compiler.h | 2 +- - llvm/include/llvm/Support/ConvertUTF.h | 31 ++++---- - llvm/include/llvm/Support/ErrorHandling.h | 9 +-- - .../llvm/Support/SmallVectorMemoryBuffer.h | 6 +- - llvm/include/llvm/Support/VersionTuple.h | 6 -- - .../llvm/Support/Windows/WindowsSupport.h | 4 +- - llvm/include/llvm/Support/raw_ostream.h | 46 ++++++----- - llvm/include/llvm/Support/xxhash.h | 16 ++-- - llvm/lib/Support/ConvertUTFWrapper.cpp | 38 ++++----- - llvm/lib/Support/ErrorHandling.cpp | 13 ++-- - llvm/lib/Support/SmallVector.cpp | 5 +- - llvm/lib/Support/StringMap.cpp | 12 +-- - llvm/lib/Support/raw_ostream.cpp | 25 +++--- - llvm/lib/Support/xxhash.cpp | 10 +-- - llvm/unittests/ADT/DenseMapTest.cpp | 29 +------ - llvm/unittests/ADT/FunctionExtrasTest.cpp | 12 +-- - llvm/unittests/ADT/HashingTest.cpp | 2 +- - llvm/unittests/ADT/SmallPtrSetTest.cpp | 1 - - llvm/unittests/ADT/SmallStringTest.cpp | 50 ++++++------ - llvm/unittests/ADT/SmallVectorTest.cpp | 30 ++------ - llvm/unittests/ADT/StringMapTest.cpp | 32 ++++---- - llvm/unittests/Support/ConvertUTFTest.cpp | 41 +++++----- - llvm/unittests/Support/xxhashTest.cpp | 4 +- - 30 files changed, 264 insertions(+), 315 deletions(-) + llvm/include/llvm/ADT/PointerUnion.h | 1 - + llvm/include/llvm/ADT/SmallSet.h | 2 +- + llvm/include/llvm/ADT/SmallString.h | 103 ++++++++++-------- + llvm/include/llvm/ADT/SmallVector.h | 7 +- + llvm/include/llvm/ADT/StringMap.h | 38 +++---- + llvm/include/llvm/ADT/StringMapEntry.h | 20 ++-- + llvm/include/llvm/Support/Chrono.h | 10 +- + llvm/include/llvm/Support/Compiler.h | 2 +- + llvm/include/llvm/Support/ConvertUTF.h | 31 +++--- + llvm/include/llvm/Support/ErrorHandling.h | 9 +- + .../llvm/Support/SmallVectorMemoryBuffer.h | 6 +- + llvm/include/llvm/Support/VersionTuple.h | 6 - + .../llvm/Support/Windows/WindowsSupport.h | 4 +- + llvm/include/llvm/Support/raw_ostream.h | 46 +++++--- + llvm/include/llvm/Support/xxhash.h | 16 +-- + llvm/lib/Support/ConvertUTFWrapper.cpp | 38 +++---- + llvm/lib/Support/ErrorHandling.cpp | 13 +-- + llvm/lib/Support/SmallVector.cpp | 5 +- + llvm/lib/Support/StringMap.cpp | 12 +- + llvm/lib/Support/raw_ostream.cpp | 25 ++--- + llvm/lib/Support/xxhash.cpp | 10 +- + llvm/unittests/ADT/DenseMapTest.cpp | 29 +---- + llvm/unittests/ADT/FunctionExtrasTest.cpp | 12 +- + llvm/unittests/ADT/HashingTest.cpp | 2 +- + llvm/unittests/ADT/SmallPtrSetTest.cpp | 1 - + llvm/unittests/ADT/SmallStringTest.cpp | 50 ++++----- + llvm/unittests/ADT/SmallVectorTest.cpp | 30 +---- + llvm/unittests/ADT/StringMapTest.cpp | 32 +++--- + llvm/unittests/Support/ConvertUTFTest.cpp | 41 ++++--- + llvm/unittests/Support/xxhashTest.cpp | 4 +- + 30 files changed, 282 insertions(+), 323 deletions(-) diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h index 7d4ed02b622626bb8043acb57b8ce7ed97a5f949..8ac68dbc0a791b8ac0e0ca865e69024cb642aa70 100644 @@ -67,7 +67,7 @@ index a16e8ac6f07552d98250e808190b00ee270f12b3..aeee5f97799aea7e7588d7afba1e47b4 #include #include diff --git a/llvm/include/llvm/ADT/SmallString.h b/llvm/include/llvm/ADT/SmallString.h -index 0052c86fb37b82dcdf577a7acf06e3a47f54da61..4d673cc8b1c49cf8a3f19653de53881cd12662ee 100644 +index a5b9eec50c8257348743f1e32ebd9a9dabd53b25..45fbf13a43a081731186b0f41c553413b0e36e0f 100644 --- a/llvm/include/llvm/ADT/SmallString.h +++ b/llvm/include/llvm/ADT/SmallString.h @@ -15,8 +15,9 @@ @@ -141,155 +141,176 @@ index 0052c86fb37b82dcdf577a7acf06e3a47f54da61..4d673cc8b1c49cf8a3f19653de53881c std::copy(Ref.begin(), Ref.end(), this->begin() + CurrentSize); CurrentSize += Ref.size(); } -@@ -89,30 +90,30 @@ public: +@@ -89,26 +90,30 @@ public: /// Check for string equality. This is more efficient than compare() when /// the relative ordering of inequal strings isn't needed. -- bool equals(StringRef RHS) const { -+ bool equals(std::string_view RHS) const { - return str().equals(RHS); - } +- [[nodiscard]] bool equals(StringRef RHS) const { return str().equals(RHS); } ++ [[nodiscard]] bool equals(std::string_view RHS) const { ++ return str().equals(RHS); ++ } /// Check for string equality, ignoring case. -- bool equals_insensitive(StringRef RHS) const { -+ bool equals_insensitive(std::string_view RHS) const { +- [[nodiscard]] bool equals_insensitive(StringRef RHS) const { ++ [[nodiscard]] bool equals_insensitive(std::string_view RHS) const { return str().equals_insensitive(RHS); } /// compare - Compare two strings; the result is negative, zero, or positive /// if this string is lexicographically less than, equal to, or greater than /// the \p RHS. -- int compare(StringRef RHS) const { -+ int compare(std::string_view RHS) const { - return str().compare(RHS); - } +- [[nodiscard]] int compare(StringRef RHS) const { return str().compare(RHS); } ++ [[nodiscard]] int compare(std::string_view RHS) const { ++ return str().compare(RHS); ++ } /// compare_insensitive - Compare two strings, ignoring case. -- int compare_insensitive(StringRef RHS) const { -+ int compare_insensitive(std::string_view RHS) const { +- [[nodiscard]] int compare_insensitive(StringRef RHS) const { ++ [[nodiscard]] int compare_insensitive(std::string_view RHS) const { return str().compare_insensitive(RHS); } /// compare_numeric - Compare two strings, treating sequences of digits as /// numbers. -- int compare_numeric(StringRef RHS) const { -+ int compare_numeric(std::string_view RHS) const { +- [[nodiscard]] int compare_numeric(StringRef RHS) const { ++ [[nodiscard]] int compare_numeric(std::string_view RHS) const { return str().compare_numeric(RHS); } -@@ -121,12 +122,12 @@ public: +@@ -116,14 +121,14 @@ public: + /// @name String Predicates /// @{ - /// startswith - Check if this string starts with the given \p Prefix. -- bool startswith(StringRef Prefix) const { -+ bool startswith(std::string_view Prefix) const { - return str().startswith(Prefix); +- /// starts_with - Check if this string starts with the given \p Prefix. +- [[nodiscard]] bool starts_with(StringRef Prefix) const { +- return str().starts_with(Prefix); ++ /// startswith - Check if this string starts with the given \p Prefix. ++ [[nodiscard]] bool startswith(std::string_view Prefix) const { ++ return str().startswith(Prefix); } - /// endswith - Check if this string ends with the given \p Suffix. -- bool endswith(StringRef Suffix) const { -+ bool endswith(std::string_view Suffix) const { - return str().endswith(Suffix); +- /// ends_with - Check if this string ends with the given \p Suffix. +- [[nodiscard]] bool ends_with(StringRef Suffix) const { +- return str().ends_with(Suffix); ++ /// endswith - Check if this string ends with the given \p Suffix. ++ [[nodiscard]] bool endswith(std::string_view Suffix) const { ++ return str().endswith(Suffix); } -@@ -146,7 +147,7 @@ public: + /// @} +@@ -142,7 +147,7 @@ public: /// /// \returns The index of the first occurrence of \p Str, or npos if not /// found. -- size_t find(StringRef Str, size_t From = 0) const { -+ size_t find(std::string_view Str, size_t From = 0) const { +- [[nodiscard]] size_t find(StringRef Str, size_t From = 0) const { ++ [[nodiscard]] size_t find(std::string_view Str, size_t From = 0) const { return str().find(Str, From); } -@@ -154,7 +155,7 @@ public: +@@ -150,7 +155,8 @@ public: /// /// \returns The index of the last occurrence of \p C, or npos if not /// found. -- size_t rfind(char C, size_t From = StringRef::npos) const { -+ size_t rfind(char C, size_t From = std::string_view::npos) const { +- [[nodiscard]] size_t rfind(char C, size_t From = StringRef::npos) const { ++ [[nodiscard]] size_t rfind(char C, ++ size_t From = std::string_view::npos) const { return str().rfind(C, From); } -@@ -162,7 +163,7 @@ public: +@@ -158,7 +164,9 @@ public: /// /// \returns The index of the last occurrence of \p Str, or npos if not /// found. -- size_t rfind(StringRef Str) const { -+ size_t rfind(std::string_view Str) const { - return str().rfind(Str); - } +- [[nodiscard]] size_t rfind(StringRef Str) const { return str().rfind(Str); } ++ [[nodiscard]] size_t rfind(std::string_view Str) const { ++ return str().rfind(Str); ++ } -@@ -176,7 +177,7 @@ public: + /// Find the first character in the string that is \p C, or npos if not + /// found. Same as find. +@@ -170,7 +178,8 @@ public: /// not found. /// /// Complexity: O(size() + Chars.size()) -- size_t find_first_of(StringRef Chars, size_t From = 0) const { -+ size_t find_first_of(std::string_view Chars, size_t From = 0) const { +- [[nodiscard]] size_t find_first_of(StringRef Chars, size_t From = 0) const { ++ [[nodiscard]] size_t find_first_of(std::string_view Chars, ++ size_t From = 0) const { return str().find_first_of(Chars, From); } -@@ -190,13 +191,13 @@ public: +@@ -184,15 +193,15 @@ public: /// \p Chars, or npos if not found. /// /// Complexity: O(size() + Chars.size()) -- size_t find_first_not_of(StringRef Chars, size_t From = 0) const { -+ size_t find_first_not_of(std::string_view Chars, size_t From = 0) const { +- [[nodiscard]] size_t find_first_not_of(StringRef Chars, ++ [[nodiscard]] size_t find_first_not_of(std::string_view Chars, + size_t From = 0) const { return str().find_first_not_of(Chars, From); } /// Find the last character in the string that is \p C, or npos if not /// found. -- size_t find_last_of(char C, size_t From = StringRef::npos) const { -+ size_t find_last_of(char C, size_t From = std::string_view::npos) const { +- [[nodiscard]] size_t find_last_of(char C, +- size_t From = StringRef::npos) const { ++ [[nodiscard]] size_t find_last_of( ++ char C, size_t From = std::string_view::npos) const { return str().find_last_of(C, From); } -@@ -205,7 +206,7 @@ public: +@@ -200,8 +209,8 @@ public: + /// found. /// /// Complexity: O(size() + Chars.size()) - size_t find_last_of( -- StringRef Chars, size_t From = StringRef::npos) const { +- [[nodiscard]] size_t find_last_of(StringRef Chars, +- size_t From = StringRef::npos) const { ++ [[nodiscard]] size_t find_last_of( + std::string_view Chars, size_t From = std::string_view::npos) const { return str().find_last_of(Chars, From); } -@@ -220,7 +221,7 @@ public: +@@ -214,7 +223,9 @@ public: /// Return the number of non-overlapped occurrences of \p Str in the /// string. -- size_t count(StringRef Str) const { -+ size_t count(std::string_view Str) const { - return str().count(Str); - } +- [[nodiscard]] size_t count(StringRef Str) const { return str().count(Str); } ++ [[nodiscard]] size_t count(std::string_view Str) const { ++ return str().count(Str); ++ } -@@ -237,7 +238,7 @@ public: + /// @} + /// @name Substring Operations +@@ -229,8 +240,8 @@ public: /// \param N The number of characters to included in the substring. If \p N /// exceeds the number of characters remaining in the string, the string /// suffix (starting with \p Start) will be returned. -- StringRef substr(size_t Start, size_t N = StringRef::npos) const { -+ std::string_view substr(size_t Start, size_t N = std::string_view::npos) const { +- [[nodiscard]] StringRef substr(size_t Start, +- size_t N = StringRef::npos) const { ++ [[nodiscard]] std::string_view substr( ++ size_t Start, size_t N = std::string_view::npos) const { return str().substr(Start, N); } -@@ -251,14 +252,14 @@ public: +@@ -244,15 +255,15 @@ public: /// substring. If this is npos, or less than \p Start, or exceeds the /// number of characters remaining in the string, the string suffix /// (starting with \p Start) will be returned. -- StringRef slice(size_t Start, size_t End) const { -+ std::string_view slice(size_t Start, size_t End) const { +- [[nodiscard]] StringRef slice(size_t Start, size_t End) const { ++ [[nodiscard]] std::string_view slice(size_t Start, size_t End) const { return str().slice(Start, End); } // Extra methods. - /// Explicit conversion to StringRef. -- StringRef str() const { return StringRef(this->data(), this->size()); } +- [[nodiscard]] StringRef str() const { +- return StringRef(this->data(), this->size()); + /// Explicit conversion to std::string_view. -+ std::string_view str() const { return std::string_view(this->begin(), this->size()); } ++ [[nodiscard]] std::string_view str() const { ++ return std::string_view(this->begin(), this->size()); + } // TODO: Make this const, if it's safe... - const char* c_str() { -@@ -267,20 +268,20 @@ public: +@@ -262,20 +273,20 @@ public: return this->data(); } @@ -315,7 +336,7 @@ index 0052c86fb37b82dcdf577a7acf06e3a47f54da61..4d673cc8b1c49cf8a3f19653de53881c return *this; } diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h -index 53a107b1574c6a35c66c7fe3c61deb2ffc84b991..4559864ed231206b098936dae4fc378bfa986371 100644 +index 09676d792dfebd88e5c8eace666b3ab0044a962e..c96fd0e4956ee6d586f85dc79623de137e781ce0 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -27,13 +27,12 @@ @@ -333,7 +354,7 @@ index 53a107b1574c6a35c66c7fe3c61deb2ffc84b991..4559864ed231206b098936dae4fc378b template class iterator_range; template -@@ -117,7 +116,7 @@ template struct SmallVectorAlignmentAndSize { +@@ -127,7 +126,7 @@ template struct SmallVectorAlignmentAndSize { }; /// This is the part of SmallVectorTemplateBase which does not depend on whether @@ -342,7 +363,7 @@ index 53a107b1574c6a35c66c7fe3c61deb2ffc84b991..4559864ed231206b098936dae4fc378b /// to avoid unnecessarily requiring T to be complete. template class SmallVectorTemplateCommon -@@ -1233,7 +1232,7 @@ public: +@@ -1242,7 +1241,7 @@ public: template ::value>> @@ -576,10 +597,10 @@ index 98b51cc1aebd59eba20076e6d8a4eebc0eebb982..388e81c361642113937f7d5680de73a5 #endif // LLVM_ADT_STRINGMAPENTRY_H diff --git a/llvm/include/llvm/Support/Chrono.h b/llvm/include/llvm/Support/Chrono.h -index 9c2bd45d2803e56ed316d8552d899d87f2fbbb07..a7dea19d9193bcff4bc6b553b80a10b2bc7b64af 100644 +index 71859af7c7e4a595140475daf356744f52d14d24..9c9ba7002310eba5113c14957f769702c61f4326 100644 --- a/llvm/include/llvm/Support/Chrono.h +++ b/llvm/include/llvm/Support/Chrono.h -@@ -70,7 +70,7 @@ raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP); +@@ -91,7 +91,7 @@ raw_ostream &operator<<(raw_ostream &OS, sys::UtcTime<> TP); template <> struct format_provider> { static void format(const sys::TimePoint<> &TP, llvm::raw_ostream &OS, @@ -587,8 +608,8 @@ index 9c2bd45d2803e56ed316d8552d899d87f2fbbb07..a7dea19d9193bcff4bc6b553b80a10b2 + std::string_view Style); }; - namespace detail { -@@ -122,7 +122,7 @@ private: + template <> struct format_provider> { +@@ -148,7 +148,7 @@ private: return duration_cast>(D).count(); } @@ -597,7 +618,7 @@ index 9c2bd45d2803e56ed316d8552d899d87f2fbbb07..a7dea19d9193bcff4bc6b553b80a10b2 const Dur &D) { using namespace std::chrono; if (Style.consume_front("ns")) -@@ -140,7 +140,7 @@ private: +@@ -166,7 +166,7 @@ private: return {D.count(), detail::unit::value}; } @@ -606,7 +627,7 @@ index 9c2bd45d2803e56ed316d8552d899d87f2fbbb07..a7dea19d9193bcff4bc6b553b80a10b2 if (Style.empty()) return true; if (Style.consume_front("-")) -@@ -152,9 +152,9 @@ private: +@@ -178,9 +178,9 @@ private: } public: @@ -619,10 +640,10 @@ index 9c2bd45d2803e56ed316d8552d899d87f2fbbb07..a7dea19d9193bcff4bc6b553b80a10b2 bool show_unit = consumeShowUnit(Style); diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h -index 10d5cec231a523c943c37a5464cb3943627239a9..92376629c607461061bc60597a47aed1e535af52 100644 +index 8c315d255bb772d9e3c100adbd2c07b61283219b..6789f0413d8dc94cb465b6e66506b036449ee186 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h -@@ -300,7 +300,7 @@ +@@ -319,7 +319,7 @@ #endif /// LLVM_GSL_POINTER - Apply this to non-owning classes like @@ -800,18 +821,18 @@ index f7f2d4e54e705d6f29812dc93d1fb0a3ca2dee12..b5e321b5f74ce35940649b9d1342b3cd BufferKind getBufferKind() const override { return MemoryBuffer_Malloc; } diff --git a/llvm/include/llvm/Support/VersionTuple.h b/llvm/include/llvm/Support/VersionTuple.h -index 828a6db54708dfa9a1a4b4456a92945a92ad80cb..953b40701dc934c1a356b5413c9c6c692d5f5679 100644 +index 0a4623f049d28825530bf50c8acfe85deaed96ba..e1cdce77ce8659305c99a21e01f9b3cc3481a5fd 100644 --- a/llvm/include/llvm/Support/VersionTuple.h +++ b/llvm/include/llvm/Support/VersionTuple.h -@@ -25,7 +25,6 @@ namespace llvm { - template - class HashBuilderImpl; +@@ -23,7 +23,6 @@ + namespace llvm { + template class HashBuilder; class raw_ostream; -class StringRef; /// Represents a version number in the form major[.minor[.subminor[.build]]]. class VersionTuple { -@@ -182,11 +181,6 @@ public: +@@ -180,11 +179,6 @@ public: /// Retrieve a string representation of the version number. std::string getAsString() const; @@ -846,7 +867,7 @@ index d3aacd14b2097b1e7e13c1003987c1fd52e0cf76..aabdb2f14668a990329b57f5454a0d7d template diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index 1e01eb9ea19c4187302a91457b6d34fbe5b67584..2463f1af612a78cafafe3c0e16d496e607cdc322 100644 +index 42663a9adf2e51ae36209faf7d465094adbf0943..9345348d9ba555022b31f94299684316ffa15939 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -14,13 +14,12 @@ @@ -944,9 +965,9 @@ index 1e01eb9ea19c4187302a91457b6d34fbe5b67584..2463f1af612a78cafafe3c0e16d496e6 - raw_fd_stream(StringRef Filename, std::error_code &EC); + raw_fd_stream(std::string_view Filename, std::error_code &EC); - /// This reads the \p Size bytes into a buffer pointed by \p Ptr. - /// -@@ -693,8 +703,8 @@ public: + raw_fd_stream(int fd, bool shouldClose); + +@@ -695,8 +705,8 @@ public: void flush() = delete; @@ -957,7 +978,7 @@ index 1e01eb9ea19c4187302a91457b6d34fbe5b67584..2463f1af612a78cafafe3c0e16d496e6 void reserveExtraSpace(uint64_t ExtraSize) override { OS.reserve(tell() + ExtraSize); -@@ -751,7 +761,7 @@ class Error; +@@ -753,7 +763,7 @@ class Error; /// for other names. For raw_fd_ostream instances, the stream writes to /// a temporary file. The final output file is atomically replaced with the /// temporary file after the \p Write function is finished. @@ -1178,7 +1199,7 @@ index b8b3b7424ac6b1de782e739782f9671194ce77a1..0aa13a0f78eb370b2a673ca4a773f268 (void)written; // If something went wrong, we deliberately just give up. } diff --git a/llvm/lib/Support/SmallVector.cpp b/llvm/lib/Support/SmallVector.cpp -index f7e7e80332cc337f6dfa388d1e218e6f3ec95cf2..6cefdff7c28060ca18b522acf5279af3a206e23a 100644 +index b6ce37842040b36fc79770ca0296255f2bb42a1a..4f6fee18b659adcbfd79822832f914170cbb1635 100644 --- a/llvm/lib/Support/SmallVector.cpp +++ b/llvm/lib/Support/SmallVector.cpp @@ -11,7 +11,6 @@ @@ -1265,10 +1286,10 @@ index 67c05a87959cf0c243d17646ae2f28f6c9f0d708..7be219323f6d76f32a9a841115f2f146 if (Bucket == -1) return nullptr; diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index a4fc605019c211f93dde009e89e7a79b07400aa3..9966a0056ae4f24a7a38346ee1c2f5d83ac20248 100644 +index 3d3a564af51d120786b358b96a3c90e2b7fbf9f3..220d850b9bc69f8fc2fba7cd23629eca487cde23 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp -@@ -166,7 +166,7 @@ raw_ostream &raw_ostream::write_uuid(const uuid_t UUID) { +@@ -167,7 +167,7 @@ raw_ostream &raw_ostream::write_uuid(const uuid_t UUID) { } @@ -1277,7 +1298,7 @@ index a4fc605019c211f93dde009e89e7a79b07400aa3..9966a0056ae4f24a7a38346ee1c2f5d8 bool UseHexEscapes) { for (unsigned char c : Str) { switch (c) { -@@ -569,7 +569,7 @@ void format_object_base::home() { +@@ -570,7 +570,7 @@ void format_object_base::home() { // raw_fd_ostream //===----------------------------------------------------------------------===// @@ -1286,7 +1307,7 @@ index a4fc605019c211f93dde009e89e7a79b07400aa3..9966a0056ae4f24a7a38346ee1c2f5d8 sys::fs::CreationDisposition Disp, sys::fs::FileAccess Access, sys::fs::OpenFlags Flags) { assert((Access & sys::fs::FA_Write) && -@@ -595,25 +595,25 @@ static int getFD(StringRef Filename, std::error_code &EC, +@@ -596,25 +596,25 @@ static int getFD(StringRef Filename, std::error_code &EC, return FD; } @@ -1317,7 +1338,7 @@ index a4fc605019c211f93dde009e89e7a79b07400aa3..9966a0056ae4f24a7a38346ee1c2f5d8 sys::fs::CreationDisposition Disp, sys::fs::FileAccess Access, sys::fs::OpenFlags Flags) -@@ -685,8 +685,7 @@ raw_fd_ostream::~raw_fd_ostream() { +@@ -686,8 +686,7 @@ raw_fd_ostream::~raw_fd_ostream() { // has_error() and clear the error flag with clear_error() before // destructing raw_ostream objects which may have errors. if (has_error()) @@ -1327,7 +1348,7 @@ index a4fc605019c211f93dde009e89e7a79b07400aa3..9966a0056ae4f24a7a38346ee1c2f5d8 /*gen_crash_diag=*/false); } -@@ -705,7 +704,7 @@ raw_fd_ostream::~raw_fd_ostream() { +@@ -706,7 +705,7 @@ raw_fd_ostream::~raw_fd_ostream() { // the input is UTF-8 or transcode from the local codepage to UTF-8 before // quoting it. If they don't, this may mess up the encoding, but this is still // probably the best compromise we can make. @@ -1336,7 +1357,7 @@ index a4fc605019c211f93dde009e89e7a79b07400aa3..9966a0056ae4f24a7a38346ee1c2f5d8 SmallVector WideText; // Fall back to ::write if it wasn't valid UTF-8. -@@ -748,7 +747,7 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) { +@@ -749,7 +748,7 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) { // If this is a Windows console device, try re-encoding from UTF-8 to UTF-16 // and using WriteConsoleW. If that fails, fall back to plain write(). if (IsWindowsConsole) @@ -1345,7 +1366,7 @@ index a4fc605019c211f93dde009e89e7a79b07400aa3..9966a0056ae4f24a7a38346ee1c2f5d8 return; #endif -@@ -919,7 +918,7 @@ raw_ostream &llvm::nulls() { +@@ -925,7 +924,7 @@ raw_ostream &llvm::nulls() { // File Streams //===----------------------------------------------------------------------===// @@ -1354,7 +1375,7 @@ index a4fc605019c211f93dde009e89e7a79b07400aa3..9966a0056ae4f24a7a38346ee1c2f5d8 : raw_fd_ostream(getFD(Filename, EC, sys::fs::CD_CreateAlways, sys::fs::FA_Write | sys::fs::FA_Read, sys::fs::OF_None), -@@ -997,7 +996,7 @@ void buffer_ostream::anchor() {} +@@ -998,7 +997,7 @@ void buffer_ostream::anchor() {} void buffer_unique_ostream::anchor() {} @@ -1493,7 +1514,7 @@ index fc856a976946bf6decda9b6724cac66afc7bdcd6..aff9d61c7f0d48834123b04b74a2e4f7 TEST(UniqueFunctionTest, SFINAE) { EXPECT_EQ("not a function", returns("boo!")); diff --git a/llvm/unittests/ADT/HashingTest.cpp b/llvm/unittests/ADT/HashingTest.cpp -index 01a8a962b8e2e33ca8f189c049e9548ced42ec3a..62aff9c3b21eea785ca71c6e290c9c4f3a20ae00 100644 +index ab13ee833ce556945fb9526fd13d8bd5f3e5c95a..3e80467ebd0efddcf2cbbe003bb91f1475ca9cb3 100644 --- a/llvm/unittests/ADT/HashingTest.cpp +++ b/llvm/unittests/ADT/HashingTest.cpp @@ -295,7 +295,7 @@ TEST(HashingTest, HashCombineRangeGoldenTest) { diff --git a/upstream_utils/llvm_patches/0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch b/upstream_utils/llvm_patches/0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch index 0648e239f40..5f96d9ae237 100644 --- a/upstream_utils/llvm_patches/0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch +++ b/upstream_utils/llvm_patches/0002-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch @@ -5,10 +5,10 @@ Subject: [PATCH 02/34] Wrap std::min/max calls in parens, for Windows warnings --- llvm/include/llvm/ADT/DenseMap.h | 4 ++-- - llvm/include/llvm/ADT/SmallVector.h | 12 ++++++------ + llvm/include/llvm/ADT/SmallVector.h | 6 +++--- llvm/include/llvm/Support/ConvertUTF.h | 2 +- llvm/include/llvm/Support/MathExtras.h | 18 +++++++++--------- - 4 files changed, 18 insertions(+), 18 deletions(-) + 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h index 3ef6a7cd1b4b587e61fcb9475d9f3516018bf2ee..108193f04486425f3b7f039cd9d2004be6facafb 100644 @@ -33,10 +33,10 @@ index 3ef6a7cd1b4b587e61fcb9475d9f3516018bf2ee..108193f04486425f3b7f039cd9d2004b this->BaseT::initEmpty(); return; diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h -index 4559864ed231206b098936dae4fc378bfa986371..84f4d0931a30f4be29549354c85cb4c0489e14c9 100644 +index c96fd0e4956ee6d586f85dc79623de137e781ce0..d7600fe209a58deb07c63e2553f9dad62e06e973 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h -@@ -55,12 +55,12 @@ protected: +@@ -55,7 +55,7 @@ protected: /// The maximum value of the Size_T used. static constexpr size_t SizeTypeMax() { @@ -45,22 +45,7 @@ index 4559864ed231206b098936dae4fc378bfa986371..84f4d0931a30f4be29549354c85cb4c0 } SmallVectorBase() = delete; - SmallVectorBase(void *FirstEl, size_t TotalCapacity) -- : BeginX(FirstEl), Capacity(TotalCapacity) {} -+ : BeginX(FirstEl), Capacity(static_cast(TotalCapacity)) {} - - /// This is a helper for \a grow() that's out of line to reduce code - /// duplication. This function will report a fatal error if it can't grow at -@@ -99,7 +99,7 @@ protected: - /// This does not construct or destroy any elements in the vector. - void set_size(size_t N) { - assert(N <= capacity()); -- Size = N; -+ Size = static_cast(N); - } - }; - -@@ -279,7 +279,7 @@ public: +@@ -289,7 +289,7 @@ public: size_type size_in_bytes() const { return size() * sizeof(T); } size_type max_size() const { @@ -69,16 +54,7 @@ index 4559864ed231206b098936dae4fc378bfa986371..84f4d0931a30f4be29549354c85cb4c0 } size_t capacity_in_bytes() const { return capacity() * sizeof(T); } -@@ -467,7 +467,7 @@ void SmallVectorTemplateBase::takeAllocationForGrow( - free(this->begin()); - - this->BeginX = NewElts; -- this->Capacity = NewCapacity; -+ this->Capacity = static_cast(NewCapacity); - } - - /// SmallVectorTemplateBase - This is where we put -@@ -712,7 +712,7 @@ public: +@@ -721,7 +721,7 @@ public: } // Assign over existing elements. @@ -101,7 +77,7 @@ index 5c0e3009c25446a34882fb98329b1d955231bb39..72321022beb373945f7935ed72944fd6 /* Some fundamental constants */ #define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index dc095941fdc8a9f2b3b822e6e014f0640676c0d3..0bd572d07fcbf2ff56998dbf366215068b62f527 100644 +index aa4f4d2ed42e262f27e3f7f5ce275baf7e556c2d..5cabfdd6493fee33fbc74b831dc1fa3c91ba725d 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -311,26 +311,26 @@ template <> constexpr inline size_t CTLog2<1>() { return 0; } @@ -135,7 +111,7 @@ index dc095941fdc8a9f2b3b822e6e014f0640676c0d3..0bd572d07fcbf2ff56998dbf36621506 } /// A and B are either alignments or offsets. Return the minimum alignment that -@@ -479,7 +479,7 @@ SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) { +@@ -482,7 +482,7 @@ SaturatingAdd(T X, T Y, bool *ResultOverflowed = nullptr) { T Z = X + Y; Overflowed = (Z < X || Z < Y); if (Overflowed) @@ -144,7 +120,7 @@ index dc095941fdc8a9f2b3b822e6e014f0640676c0d3..0bd572d07fcbf2ff56998dbf36621506 else return Z; } -@@ -492,7 +492,7 @@ std::enable_if_t, T> SaturatingAdd(T X, T Y, T Z, +@@ -495,7 +495,7 @@ std::enable_if_t, T> SaturatingAdd(T X, T Y, T Z, bool Overflowed = false; T XY = SaturatingAdd(X, Y, &Overflowed); if (Overflowed) @@ -153,7 +129,7 @@ index dc095941fdc8a9f2b3b822e6e014f0640676c0d3..0bd572d07fcbf2ff56998dbf36621506 return SaturatingAdd(XY, Z, Args...); } -@@ -516,7 +516,7 @@ SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) { +@@ -519,7 +519,7 @@ SaturatingMultiply(T X, T Y, bool *ResultOverflowed = nullptr) { // Special case: if X or Y is 0, Log2_64 gives -1, and Log2Z // will necessarily be less than Log2Max as desired. int Log2Z = Log2_64(X) + Log2_64(Y); @@ -162,7 +138,7 @@ index dc095941fdc8a9f2b3b822e6e014f0640676c0d3..0bd572d07fcbf2ff56998dbf36621506 int Log2Max = Log2_64(Max); if (Log2Z < Log2Max) { return X * Y; -@@ -636,9 +636,9 @@ std::enable_if_t, T> MulOverflow(T X, T Y, T &Result) { +@@ -639,9 +639,9 @@ std::enable_if_t, T> MulOverflow(T X, T Y, T &Result) { // Check how the max allowed absolute value (2^n for negative, 2^(n-1) for // positive) divided by an argument compares to the other. if (IsNegative) diff --git a/upstream_utils/llvm_patches/0003-Change-unique_function-storage-size.patch b/upstream_utils/llvm_patches/0003-Change-unique_function-storage-size.patch index 765515504af..5576e75698c 100644 --- a/upstream_utils/llvm_patches/0003-Change-unique_function-storage-size.patch +++ b/upstream_utils/llvm_patches/0003-Change-unique_function-storage-size.patch @@ -8,10 +8,10 @@ Subject: [PATCH 03/34] Change unique_function storage size 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h -index 4cf1de488c7bde2692d4878ccb4c4d60241e3a66..9d10b16e3cbe9c0df818a3254fcd3a6032d54b39 100644 +index c0bc30c7450fe4b2bc6b9b448824eedc8b132e52..5641a913d0a35ee2911cf872ad90c3dc864f20f5 100644 --- a/llvm/include/llvm/ADT/FunctionExtras.h +++ b/llvm/include/llvm/ADT/FunctionExtras.h -@@ -78,7 +78,7 @@ using EnableIfCallable = std::enable_if_t class UniqueFunctionBase { protected: @@ -20,7 +20,7 @@ index 4cf1de488c7bde2692d4878ccb4c4d60241e3a66..9d10b16e3cbe9c0df818a3254fcd3a60 template struct IsSizeLessThanThresholdT : std::false_type {}; -@@ -157,7 +157,7 @@ protected: +@@ -158,7 +158,7 @@ protected: "Should always use all of the out-of-line storage for inline storage!"); // For in-line storage, we just provide an aligned character buffer. We diff --git a/upstream_utils/llvm_patches/0004-Threading-updates.patch b/upstream_utils/llvm_patches/0004-Threading-updates.patch index 9cb2cf807fd..72710a7bda0 100644 --- a/upstream_utils/llvm_patches/0004-Threading-updates.patch +++ b/upstream_utils/llvm_patches/0004-Threading-updates.patch @@ -12,10 +12,10 @@ Subject: [PATCH 04/34] Threading updates 3 files changed, 11 insertions(+), 43 deletions(-) diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h -index 92376629c607461061bc60597a47aed1e535af52..2662839b27bf368cd5da0668099c4b44cbc6435d 100644 +index 6789f0413d8dc94cb465b6e66506b036449ee186..e608f8ea3a837a04d9c29c8bb7a1fab527d512bb 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h -@@ -530,7 +530,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -555,7 +555,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); /// initialize to some constant value. In almost all circumstances this is most /// appropriate for use with a pointer, integer, or small aggregation of /// pointers and integers. @@ -23,7 +23,7 @@ index 92376629c607461061bc60597a47aed1e535af52..2662839b27bf368cd5da0668099c4b44 #if __has_feature(cxx_thread_local) || defined(_MSC_VER) #define LLVM_THREAD_LOCAL thread_local #else -@@ -538,11 +537,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -563,11 +562,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); // we only need the restricted functionality that provides. #define LLVM_THREAD_LOCAL __thread #endif diff --git a/upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch b/upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch index 3a9ae569803..3b214e0604d 100644 --- a/upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch +++ b/upstream_utils/llvm_patches/0005-ifdef-guard-safety.patch @@ -9,7 +9,7 @@ Prevents redefinition if someone is pulling in real LLVM, since the macros are i 1 file changed, 42 insertions(+) diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h -index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e848519998685b 100644 +index e608f8ea3a837a04d9c29c8bb7a1fab527d512bb..8f68d79898fe0247f9e17709bf1c1ec2a451c037 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h @@ -90,6 +90,7 @@ @@ -50,7 +50,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 #if defined(__clang__) #define LLVM_DEPRECATED(MSG, FIX) __attribute__((deprecated(MSG, FIX))) -@@ -178,11 +184,13 @@ +@@ -197,11 +203,13 @@ // more portable solution: // (void)unused_var_name; // Prefer cast-to-void wherever it is sufficient. @@ -64,7 +64,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 // FIXME: Provide this for PE/COFF targets. #if __has_attribute(weak) && !defined(__MINGW32__) && !defined(__CYGWIN__) && \ -@@ -192,6 +200,7 @@ +@@ -211,6 +219,7 @@ #define LLVM_ATTRIBUTE_WEAK #endif @@ -72,7 +72,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 // Prior to clang 3.2, clang did not accept any spelling of // __has_attribute(const), so assume it is supported. #if defined(__clang__) || defined(__GNUC__) -@@ -200,13 +209,16 @@ +@@ -219,13 +228,16 @@ #else #define LLVM_READNONE #endif @@ -89,7 +89,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 #if __has_attribute(minsize) #define LLVM_ATTRIBUTE_MINSIZE __attribute__((minsize)) -@@ -214,6 +226,7 @@ +@@ -233,6 +245,7 @@ #define LLVM_ATTRIBUTE_MINSIZE #endif @@ -97,7 +97,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 #if __has_builtin(__builtin_expect) || defined(__GNUC__) #define LLVM_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true) #define LLVM_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false) -@@ -221,9 +234,11 @@ +@@ -240,9 +253,11 @@ #define LLVM_LIKELY(EXPR) (EXPR) #define LLVM_UNLIKELY(EXPR) (EXPR) #endif @@ -109,7 +109,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 #if __has_attribute(noinline) #define LLVM_ATTRIBUTE_NOINLINE __attribute__((noinline)) #elif defined(_MSC_VER) -@@ -231,9 +246,11 @@ +@@ -250,9 +265,11 @@ #else #define LLVM_ATTRIBUTE_NOINLINE #endif @@ -121,7 +121,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 #if __has_attribute(always_inline) #define LLVM_ATTRIBUTE_ALWAYS_INLINE inline __attribute__((always_inline)) #elif defined(_MSC_VER) -@@ -241,6 +258,7 @@ +@@ -260,6 +277,7 @@ #else #define LLVM_ATTRIBUTE_ALWAYS_INLINE inline #endif @@ -129,7 +129,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 /// LLVM_ATTRIBUTE_NO_DEBUG - On compilers where we have a directive to do /// so, mark a method "no debug" because debug info makes the debugger -@@ -251,6 +269,7 @@ +@@ -270,6 +288,7 @@ #define LLVM_ATTRIBUTE_NODEBUG #endif @@ -137,7 +137,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 #if __has_attribute(returns_nonnull) #define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) #elif defined(_MSC_VER) -@@ -258,9 +277,11 @@ +@@ -277,9 +296,11 @@ #else #define LLVM_ATTRIBUTE_RETURNS_NONNULL #endif @@ -149,7 +149,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 #ifdef __GNUC__ #define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__)) #elif defined(_MSC_VER) -@@ -268,8 +289,10 @@ +@@ -287,8 +308,10 @@ #else #define LLVM_ATTRIBUTE_RETURNS_NOALIAS #endif @@ -160,7 +160,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 #if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(fallthrough) #define LLVM_FALLTHROUGH [[fallthrough]] #elif LLVM_HAS_CPP_ATTRIBUTE(gnu::fallthrough) -@@ -281,6 +304,7 @@ +@@ -300,6 +323,7 @@ #else #define LLVM_FALLTHROUGH #endif @@ -168,7 +168,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 /// LLVM_REQUIRE_CONSTANT_INITIALIZATION - Apply this to globals to ensure that /// they are constant initialized. -@@ -309,11 +333,13 @@ +@@ -334,11 +358,13 @@ /// LLVM_EXTENSION - Support compilers where we have a keyword to suppress /// pedantic diagnostics. @@ -182,7 +182,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 /// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands /// to an expression which states that it is undefined behavior for the -@@ -322,14 +348,17 @@ +@@ -347,14 +373,17 @@ /// '#else' is intentionally left out so that other macro logic (e.g., /// LLVM_ASSUME_ALIGNED and llvm_unreachable()) can detect whether /// LLVM_BUILTIN_UNREACHABLE has a definition. @@ -200,7 +200,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 #if __has_builtin(__builtin_trap) || defined(__GNUC__) # define LLVM_BUILTIN_TRAP __builtin_trap() #elif defined(_MSC_VER) -@@ -341,10 +370,12 @@ +@@ -366,10 +395,12 @@ #else # define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0 #endif @@ -213,7 +213,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 #if __has_builtin(__builtin_debugtrap) # define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap() #elif defined(_MSC_VER) -@@ -358,9 +389,11 @@ +@@ -383,9 +414,11 @@ // program to abort if encountered. # define LLVM_BUILTIN_DEBUGTRAP #endif @@ -225,7 +225,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 #if __has_builtin(__builtin_assume_aligned) || defined(__GNUC__) # define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a) #elif defined(LLVM_BUILTIN_UNREACHABLE) -@@ -369,6 +402,7 @@ +@@ -394,6 +427,7 @@ #else # define LLVM_ASSUME_ALIGNED(p, a) (p) #endif @@ -233,7 +233,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 /// \macro LLVM_PACKED /// Used to specify a packed structure. -@@ -388,6 +422,7 @@ +@@ -413,6 +447,7 @@ /// long long l; /// }; /// LLVM_PACKED_END @@ -241,7 +241,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 #ifdef _MSC_VER # define LLVM_PACKED(d) __pragma(pack(push, 1)) d __pragma(pack(pop)) # define LLVM_PACKED_START __pragma(pack(push, 1)) -@@ -397,6 +432,7 @@ +@@ -422,6 +457,7 @@ # define LLVM_PACKED_START _Pragma("pack(push, 1)") # define LLVM_PACKED_END _Pragma("pack(pop)") #endif @@ -249,7 +249,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 /// \macro LLVM_MEMORY_SANITIZER_BUILD /// Whether LLVM itself is built with MemorySanitizer instrumentation. -@@ -488,11 +524,13 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -513,11 +549,13 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); /// \macro LLVM_NO_SANITIZE /// Disable a particular sanitizer for a function. @@ -263,7 +263,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 /// Mark debug helper function definitions like dump() that should not be /// stripped from debug builds. -@@ -500,17 +538,20 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -525,17 +563,20 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); /// `#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)` so they do always /// get stripped in release builds. // FIXME: Move this to a private config.h as it's not usable in public headers. @@ -284,7 +284,7 @@ index 2662839b27bf368cd5da0668099c4b44cbc6435d..ce75702c8c6f99780ecdb6dc77e84851 #if defined(_MSC_VER) #define LLVM_PRETTY_FUNCTION __FUNCSIG__ #elif defined(__GNUC__) || defined(__clang__) -@@ -518,6 +559,7 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -543,6 +584,7 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); #else #define LLVM_PRETTY_FUNCTION __func__ #endif diff --git a/upstream_utils/llvm_patches/0007-Remove-format_provider.patch b/upstream_utils/llvm_patches/0007-Remove-format_provider.patch index 6249648e93a..1430099ddd5 100644 --- a/upstream_utils/llvm_patches/0007-Remove-format_provider.patch +++ b/upstream_utils/llvm_patches/0007-Remove-format_provider.patch @@ -4,13 +4,13 @@ Date: Sat, 7 May 2022 22:53:50 -0400 Subject: [PATCH 07/34] Remove format_provider --- - llvm/include/llvm/Support/Chrono.h | 109 ------------------------ + llvm/include/llvm/Support/Chrono.h | 114 ------------------------ llvm/include/llvm/Support/raw_ostream.h | 6 -- - llvm/unittests/Support/Chrono.cpp | 67 --------------- - 3 files changed, 182 deletions(-) + llvm/unittests/Support/Chrono.cpp | 67 -------------- + 3 files changed, 187 deletions(-) diff --git a/llvm/include/llvm/Support/Chrono.h b/llvm/include/llvm/Support/Chrono.h -index a7dea19d9193bcff4bc6b553b80a10b2bc7b64af..9f9a2b5cab270327898cee3f97d9ae7cf77eb564 100644 +index 9c9ba7002310eba5113c14957f769702c61f4326..b269ff8bb5db7bb3c62c3a87daf255b18ece4cd7 100644 --- a/llvm/include/llvm/Support/Chrono.h +++ b/llvm/include/llvm/Support/Chrono.h @@ -10,7 +10,6 @@ @@ -21,9 +21,9 @@ index a7dea19d9193bcff4bc6b553b80a10b2bc7b64af..9f9a2b5cab270327898cee3f97d9ae7c #include #include -@@ -59,114 +58,6 @@ toTimePoint(std::time_t T, uint32_t nsec) { - +@@ -80,119 +79,6 @@ toTimePoint(std::time_t T, uint32_t nsec) { raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP); + raw_ostream &operator<<(raw_ostream &OS, sys::UtcTime<> TP); -/// Format provider for TimePoint<> -/// @@ -39,6 +39,11 @@ index a7dea19d9193bcff4bc6b553b80a10b2bc7b64af..9f9a2b5cab270327898cee3f97d9ae7c - std::string_view Style); -}; - +-template <> struct format_provider> { +- static void format(const sys::UtcTime &TP, +- llvm::raw_ostream &OS, StringRef Style); +-}; +- -namespace detail { -template struct unit { static const char value[]; }; -template const char unit::value[] = ""; @@ -137,7 +142,7 @@ index a7dea19d9193bcff4bc6b553b80a10b2bc7b64af..9f9a2b5cab270327898cee3f97d9ae7c #endif // LLVM_SUPPORT_CHRONO_H diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index 2463f1af612a78cafafe3c0e16d496e607cdc322..5d08596b4cf6bf9e9b8e2c2c1aef731bb8832da5 100644 +index 9345348d9ba555022b31f94299684316ffa15939..862a1db876e9b8467a8839dae8f6632f18d5e7a0 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -27,12 +27,6 @@ @@ -154,10 +159,10 @@ index 2463f1af612a78cafafe3c0e16d496e607cdc322..5d08596b4cf6bf9e9b8e2c2c1aef731b namespace sys { diff --git a/llvm/unittests/Support/Chrono.cpp b/llvm/unittests/Support/Chrono.cpp -index daf8a8a350f08c748ba05af44f43f3faca8e2c61..3c049de18c0a80465f4b0a8c054df2602d5e9b1c 100644 +index 7dfc5dd2c29348ea8df9ce87c80f357aaad1a73b..a4d166d435d6d679f773dcf3eab985f0631e12d2 100644 --- a/llvm/unittests/Support/Chrono.cpp +++ b/llvm/unittests/Support/Chrono.cpp -@@ -30,43 +30,6 @@ TEST(Chrono, TimeTConversion) { +@@ -29,43 +29,6 @@ TEST(Chrono, TimeTConversion) { EXPECT_EQ(TP, toTimePoint(toTimeT(TP))); } @@ -201,7 +206,7 @@ index daf8a8a350f08c748ba05af44f43f3faca8e2c61..3c049de18c0a80465f4b0a8c054df260 // Test that toTimePoint and toTimeT can be called with a arguments with varying // precisions. TEST(Chrono, ImplicitConversions) { -@@ -84,34 +47,4 @@ TEST(Chrono, ImplicitConversions) { +@@ -83,34 +46,4 @@ TEST(Chrono, ImplicitConversions) { EXPECT_EQ(TimeT, toTimeT(Nano)); } diff --git a/upstream_utils/llvm_patches/0008-Add-compiler-warning-pragmas.patch b/upstream_utils/llvm_patches/0008-Add-compiler-warning-pragmas.patch index 8a889a7b145..bd1c2f6395a 100644 --- a/upstream_utils/llvm_patches/0008-Add-compiler-warning-pragmas.patch +++ b/upstream_utils/llvm_patches/0008-Add-compiler-warning-pragmas.patch @@ -17,10 +17,10 @@ Subject: [PATCH 08/34] Add compiler warning pragmas 10 files changed, 72 insertions(+), 4 deletions(-) diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h -index 9d10b16e3cbe9c0df818a3254fcd3a6032d54b39..1daeae915eb506b32a2d1296d2f0fe4e6dab606e 100644 +index 5641a913d0a35ee2911cf872ad90c3dc864f20f5..043d8d90fff03d571a923c264b49be37a5dffa09 100644 --- a/llvm/include/llvm/ADT/FunctionExtras.h +++ b/llvm/include/llvm/ADT/FunctionExtras.h -@@ -55,6 +55,13 @@ namespace llvm { +@@ -56,6 +56,13 @@ namespace llvm { /// It can hold functions with a non-const operator(), like mutable lambdas. template class unique_function; @@ -34,7 +34,7 @@ index 9d10b16e3cbe9c0df818a3254fcd3a6032d54b39..1daeae915eb506b32a2d1296d2f0fe4e namespace detail { template -@@ -409,6 +416,10 @@ public: +@@ -412,6 +419,10 @@ public: } }; @@ -46,7 +46,7 @@ index 9d10b16e3cbe9c0df818a3254fcd3a6032d54b39..1daeae915eb506b32a2d1296d2f0fe4e #endif // LLVM_ADT_FUNCTIONEXTRAS_H diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h -index ef983105c7bae67bb2ef832e4473939a0406e0df..781bdb7416392e3f60a1ac3a38fbcf5324b5395f 100644 +index a5477362a50793985e1e9df9dc77c8a1d5b5846b..08d6edb14eb3cd51405329aae61b9782266a2590 100644 --- a/llvm/include/llvm/ADT/Hashing.h +++ b/llvm/include/llvm/ADT/Hashing.h @@ -56,6 +56,11 @@ @@ -61,9 +61,9 @@ index ef983105c7bae67bb2ef832e4473939a0406e0df..781bdb7416392e3f60a1ac3a38fbcf53 namespace llvm { template struct DenseMapInfo; -@@ -683,4 +688,8 @@ template <> struct DenseMapInfo { +@@ -697,4 +702,8 @@ struct hash { - } // namespace llvm + } // namespace std; +#ifdef _WIN32 +#pragma warning(pop) @@ -71,7 +71,7 @@ index ef983105c7bae67bb2ef832e4473939a0406e0df..781bdb7416392e3f60a1ac3a38fbcf53 + #endif diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h -index 84f4d0931a30f4be29549354c85cb4c0489e14c9..b42438a9b16c273f9ef5b5cce6192873c78cb964 100644 +index d7600fe209a58deb07c63e2553f9dad62e06e973..d7788e94b5379f5eba6fbddee50e4b4359da9d80 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -14,6 +14,14 @@ @@ -90,7 +90,7 @@ index 84f4d0931a30f4be29549354c85cb4c0489e14c9..b42438a9b16c273f9ef5b5cce6192873 #include "llvm/Support/type_traits.h" #include diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index 0bd572d07fcbf2ff56998dbf366215068b62f527..cd5a64a746b2eb7491e9b6cf8570bdf436d94a6d 100644 +index 5cabfdd6493fee33fbc74b831dc1fa3c91ba725d..7541447fa2db5e1634d952b1f39957eb725611f4 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -208,6 +208,11 @@ inline uint64_t maxUIntN(uint64_t N) { @@ -117,7 +117,7 @@ index 0bd572d07fcbf2ff56998dbf366215068b62f527..cd5a64a746b2eb7491e9b6cf8570bdf4 inline int64_t maxIntN(int64_t N) { assert(N > 0 && N <= 64 && "integer width out of range"); diff --git a/llvm/include/llvm/Support/MemAlloc.h b/llvm/include/llvm/Support/MemAlloc.h -index d6012bd5a6985d8405136039aa85931605cd8a40..01007deb89bba625b1b3ad3e703d0c16ed6f757b 100644 +index f3f378b7697a18f57b189c5322b080fe23d45bec..0028e871f6a05baf6172c60c602b8b26e5f116c6 100644 --- a/llvm/include/llvm/Support/MemAlloc.h +++ b/llvm/include/llvm/Support/MemAlloc.h @@ -22,6 +22,14 @@ @@ -146,7 +146,7 @@ index d6012bd5a6985d8405136039aa85931605cd8a40..01007deb89bba625b1b3ad3e703d0c16 + #endif diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index 9966a0056ae4f24a7a38346ee1c2f5d83ac20248..a23f567a37abdc199363607446f33f29e021d7ad 100644 +index 220d850b9bc69f8fc2fba7cd23629eca487cde23..65810ca93fdc1290e3188b5f4fb292a1e1e79b60 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -10,6 +10,10 @@ @@ -176,7 +176,7 @@ index b710ac07461ba58faa99cedeae7f209dc0f5902b..1f232d3046292c0da940ba4bef7d5060 #include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/DenseMapInfoVariant.h" diff --git a/llvm/unittests/ADT/MapVectorTest.cpp b/llvm/unittests/ADT/MapVectorTest.cpp -index 1a371cbfba81e8ea4b57c4077ca94c86c3db8991..62fafcaf04a67d4c67b98b8f42d837ccca245fe9 100644 +index e0f11b60a0223da7c00a47c20b61136bd608bae6..9c802ab30721c9ce58ed65052a6ab467039226ff 100644 --- a/llvm/unittests/ADT/MapVectorTest.cpp +++ b/llvm/unittests/ADT/MapVectorTest.cpp @@ -6,6 +6,13 @@ diff --git a/upstream_utils/llvm_patches/0009-Remove-unused-functions.patch b/upstream_utils/llvm_patches/0009-Remove-unused-functions.patch index bff9ff2c790..532753feeaa 100644 --- a/upstream_utils/llvm_patches/0009-Remove-unused-functions.patch +++ b/upstream_utils/llvm_patches/0009-Remove-unused-functions.patch @@ -4,49 +4,47 @@ Date: Sun, 8 May 2022 13:43:50 -0400 Subject: [PATCH 09/34] Remove unused functions --- - llvm/include/llvm/ADT/SmallString.h | 85 +----- + llvm/include/llvm/ADT/SmallString.h | 79 ------ llvm/include/llvm/Support/Errno.h | 9 - llvm/include/llvm/Support/VersionTuple.h | 39 --- - llvm/include/llvm/Support/raw_ostream.h | 127 +-------- - llvm/lib/Support/raw_ostream.cpp | 329 ----------------------- - 5 files changed, 10 insertions(+), 579 deletions(-) + llvm/include/llvm/Support/raw_ostream.h | 129 +-------- + llvm/lib/Support/raw_ostream.cpp | 332 ----------------------- + 5 files changed, 8 insertions(+), 580 deletions(-) diff --git a/llvm/include/llvm/ADT/SmallString.h b/llvm/include/llvm/ADT/SmallString.h -index 4d673cc8b1c49cf8a3f19653de53881cd12662ee..bfa965fd68a09d7ca3b332e38585ae37a5982ed0 100644 +index 45fbf13a43a081731186b0f41c553413b0e36e0f..cb6136d8fd1886e8dc444cb807b33a5f1e18aa44 100644 --- a/llvm/include/llvm/ADT/SmallString.h +++ b/llvm/include/llvm/ADT/SmallString.h -@@ -88,49 +88,12 @@ public: +@@ -88,17 +88,6 @@ public: /// @name String Comparison /// @{ - /// Check for string equality. This is more efficient than compare() when - /// the relative ordering of inequal strings isn't needed. -- bool equals(std::string_view RHS) const { +- [[nodiscard]] bool equals(std::string_view RHS) const { - return str().equals(RHS); - } - - /// Check for string equality, ignoring case. -- bool equals_insensitive(std::string_view RHS) const { +- [[nodiscard]] bool equals_insensitive(std::string_view RHS) const { - return str().equals_insensitive(RHS); - } - -- /// compare - Compare two strings; the result is negative, zero, or positive -- /// if this string is lexicographically less than, equal to, or greater than -- /// the \p RHS. -+ /// Compare two strings; the result is -1, 0, or 1 if this string is -+ /// lexicographically less than, equal to, or greater than the \p RHS. - int compare(std::string_view RHS) const { + /// compare - Compare two strings; the result is negative, zero, or positive + /// if this string is lexicographically less than, equal to, or greater than + /// the \p RHS. +@@ -106,31 +95,6 @@ public: return str().compare(RHS); } - /// compare_insensitive - Compare two strings, ignoring case. -- int compare_insensitive(std::string_view RHS) const { +- [[nodiscard]] int compare_insensitive(std::string_view RHS) const { - return str().compare_insensitive(RHS); - } - - /// compare_numeric - Compare two strings, treating sequences of digits as - /// numbers. -- int compare_numeric(std::string_view RHS) const { +- [[nodiscard]] int compare_numeric(std::string_view RHS) const { - return str().compare_numeric(RHS); - } - @@ -55,19 +53,19 @@ index 4d673cc8b1c49cf8a3f19653de53881cd12662ee..bfa965fd68a09d7ca3b332e38585ae37 - /// @{ - - /// startswith - Check if this string starts with the given \p Prefix. -- bool startswith(std::string_view Prefix) const { +- [[nodiscard]] bool startswith(std::string_view Prefix) const { - return str().startswith(Prefix); - } - - /// endswith - Check if this string ends with the given \p Suffix. -- bool endswith(std::string_view Suffix) const { +- [[nodiscard]] bool endswith(std::string_view Suffix) const { - return str().endswith(Suffix); - } - /// @} /// @name String Searching /// @{ -@@ -211,50 +174,6 @@ public: +@@ -215,49 +179,6 @@ public: } /// @} @@ -75,13 +73,11 @@ index 4d673cc8b1c49cf8a3f19653de53881cd12662ee..bfa965fd68a09d7ca3b332e38585ae37 - /// @{ - - /// Return the number of occurrences of \p C in the string. -- size_t count(char C) const { -- return str().count(C); -- } +- [[nodiscard]] size_t count(char C) const { return str().count(C); } - - /// Return the number of non-overlapped occurrences of \p Str in the - /// string. -- size_t count(std::string_view Str) const { +- [[nodiscard]] size_t count(std::string_view Str) const { - return str().count(Str); - } - @@ -98,7 +94,8 @@ index 4d673cc8b1c49cf8a3f19653de53881cd12662ee..bfa965fd68a09d7ca3b332e38585ae37 - /// \param N The number of characters to included in the substring. If \p N - /// exceeds the number of characters remaining in the string, the string - /// suffix (starting with \p Start) will be returned. -- std::string_view substr(size_t Start, size_t N = std::string_view::npos) const { +- [[nodiscard]] std::string_view substr( +- size_t Start, size_t N = std::string_view::npos) const { - return str().substr(Start, N); - } - @@ -112,7 +109,7 @@ index 4d673cc8b1c49cf8a3f19653de53881cd12662ee..bfa965fd68a09d7ca3b332e38585ae37 - /// substring. If this is npos, or less than \p Start, or exceeds the - /// number of characters remaining in the string, the string suffix - /// (starting with \p Start) will be returned. -- std::string_view slice(size_t Start, size_t End) const { +- [[nodiscard]] std::string_view slice(size_t Start, size_t End) const { - return str().slice(Start, End); - } @@ -139,10 +136,10 @@ index e095c66b90860001d90b5c2eb74f6032de6de454..787805dac6c5e3c8cb85dabeb8025444 inline decltype(auto) RetryAfterSignal(const FailT &Fail, const Fun &F, const Args &... As) { diff --git a/llvm/include/llvm/Support/VersionTuple.h b/llvm/include/llvm/Support/VersionTuple.h -index 953b40701dc934c1a356b5413c9c6c692d5f5679..30cf717973fb15ff65a47a2d80795c351b0d2768 100644 +index e1cdce77ce8659305c99a21e01f9b3cc3481a5fd..9102ff063afedc03bd524b2805cba98ea5afeba8 100644 --- a/llvm/include/llvm/Support/VersionTuple.h +++ b/llvm/include/llvm/Support/VersionTuple.h -@@ -168,45 +168,6 @@ public: +@@ -166,45 +166,6 @@ public: friend bool operator>=(const VersionTuple &X, const VersionTuple &Y) { return !(X < Y); } @@ -151,8 +148,8 @@ index 953b40701dc934c1a356b5413c9c6c692d5f5679..30cf717973fb15ff65a47a2d80795c35 - return hash_combine(VT.Major, VT.Minor, VT.Subminor, VT.Build); - } - -- template -- friend void addHash(HashBuilderImpl &HBuilder, +- template +- friend void addHash(HashBuilder &HBuilder, - const VersionTuple &VT) { - HBuilder.add(VT.Major, VT.Minor, VT.Subminor, VT.Build); - } @@ -189,7 +186,7 @@ index 953b40701dc934c1a356b5413c9c6c692d5f5679..30cf717973fb15ff65a47a2d80795c35 } // end namespace llvm diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index 5d08596b4cf6bf9e9b8e2c2c1aef731bb8832da5..95019180a9deb406ed4f2991c664a4cc4e956dac 100644 +index 862a1db876e9b8467a8839dae8f6632f18d5e7a0..95019180a9deb406ed4f2991c664a4cc4e956dac 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h @@ -261,32 +261,6 @@ public: @@ -339,10 +336,12 @@ index 5d08596b4cf6bf9e9b8e2c2c1aef731bb8832da5..95019180a9deb406ed4f2991c664a4cc }; /// This returns a reference to a raw_fd_ostream for standard output. Use it -@@ -619,17 +542,6 @@ public: +@@ -619,19 +542,6 @@ public: /// immediately destroyed. raw_fd_stream(std::string_view Filename, std::error_code &EC); +- raw_fd_stream(int fd, bool shouldClose); +- - /// This reads the \p Size bytes into a buffer pointed by \p Ptr. - /// - /// \param Ptr The start of the buffer to hold data to be read. @@ -357,7 +356,7 @@ index 5d08596b4cf6bf9e9b8e2c2c1aef731bb8832da5..95019180a9deb406ed4f2991c664a4cc /// Check if \p OS is a pointer of type raw_fd_stream*. static bool classof(const raw_ostream *OS); }; -@@ -747,29 +659,6 @@ public: +@@ -749,29 +659,6 @@ public: ~buffer_unique_ostream() override { *OS << str(); } }; @@ -388,18 +387,18 @@ index 5d08596b4cf6bf9e9b8e2c2c1aef731bb8832da5..95019180a9deb406ed4f2991c664a4cc #endif // LLVM_SUPPORT_RAW_OSTREAM_H diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index a23f567a37abdc199363607446f33f29e021d7ad..76c32155b4296fbbf3f4b164cd58d63f472ccd5e 100644 +index 65810ca93fdc1290e3188b5f4fb292a1e1e79b60..c65fb70a4d22db51f4140b910c308333289b6248 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp -@@ -18,7 +18,6 @@ - #include "llvm/ADT/StringExtras.h" +@@ -19,7 +19,6 @@ #include "llvm/Config/config.h" + #include "llvm/Support/AutoConvert.h" #include "llvm/Support/Compiler.h" -#include "llvm/Support/Duration.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Format.h" -@@ -127,49 +126,6 @@ void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size, +@@ -128,49 +127,6 @@ void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size, assert(OutBufStart <= OutBufEnd && "Invalid size!"); } @@ -449,7 +448,7 @@ index a23f567a37abdc199363607446f33f29e021d7ad..76c32155b4296fbbf3f4b164cd58d63f raw_ostream &raw_ostream::write_escaped(std::string_view Str, bool UseHexEscapes) { for (unsigned char c : Str) { -@@ -315,173 +271,6 @@ void raw_ostream::flush_tied_then_write(const char *Ptr, size_t Size) { +@@ -316,173 +272,6 @@ void raw_ostream::flush_tied_then_write(const char *Ptr, size_t Size) { write_impl(Ptr, Size); } @@ -623,7 +622,7 @@ index a23f567a37abdc199363607446f33f29e021d7ad..76c32155b4296fbbf3f4b164cd58d63f template static raw_ostream &write_padding(raw_ostream &OS, unsigned NumChars) { static const char Chars[] = {C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, C, -@@ -512,63 +301,8 @@ raw_ostream &raw_ostream::write_zeros(unsigned NumZeros) { +@@ -513,63 +302,8 @@ raw_ostream &raw_ostream::write_zeros(unsigned NumZeros) { return write_padding<'\0'>(*this, NumZeros); } @@ -687,7 +686,7 @@ index a23f567a37abdc199363607446f33f29e021d7ad..76c32155b4296fbbf3f4b164cd58d63f //===----------------------------------------------------------------------===// // raw_fd_ostream //===----------------------------------------------------------------------===// -@@ -867,31 +601,6 @@ size_t raw_fd_ostream::preferred_buffer_size() const { +@@ -865,31 +599,6 @@ size_t raw_fd_ostream::preferred_buffer_size() const { #endif } @@ -719,10 +718,13 @@ index a23f567a37abdc199363607446f33f29e021d7ad..76c32155b4296fbbf3f4b164cd58d63f void raw_fd_ostream::anchor() {} //===----------------------------------------------------------------------===// -@@ -934,16 +643,6 @@ raw_fd_stream::raw_fd_stream(std::string_view Filename, std::error_code &EC) +@@ -940,19 +649,6 @@ raw_fd_stream::raw_fd_stream(std::string_view Filename, std::error_code &EC) EC = std::make_error_code(std::errc::invalid_argument); } +-raw_fd_stream::raw_fd_stream(int fd, bool shouldClose) +- : raw_fd_ostream(fd, shouldClose, false, OStreamKind::OK_FDStream) {} +- -ssize_t raw_fd_stream::read(char *Ptr, size_t Size) { - assert(get_fd() >= 0 && "File already closed."); - ssize_t Ret = ::read(get_fd(), (void *)Ptr, Size); @@ -736,7 +738,7 @@ index a23f567a37abdc199363607446f33f29e021d7ad..76c32155b4296fbbf3f4b164cd58d63f bool raw_fd_stream::classof(const raw_ostream *OS) { return OS->get_kind() == OStreamKind::OK_FDStream; } -@@ -999,31 +698,3 @@ void raw_pwrite_stream::anchor() {} +@@ -1000,31 +696,3 @@ void raw_pwrite_stream::anchor() {} void buffer_ostream::anchor() {} void buffer_unique_ostream::anchor() {} diff --git a/upstream_utils/llvm_patches/0010-Detemplatize-SmallVectorBase.patch b/upstream_utils/llvm_patches/0010-Detemplatize-SmallVectorBase.patch index 484ac224352..ebd786b5a57 100644 --- a/upstream_utils/llvm_patches/0010-Detemplatize-SmallVectorBase.patch +++ b/upstream_utils/llvm_patches/0010-Detemplatize-SmallVectorBase.patch @@ -4,15 +4,15 @@ Date: Thu, 5 May 2022 23:18:34 -0400 Subject: [PATCH 10/34] Detemplatize SmallVectorBase --- - llvm/include/llvm/ADT/SmallVector.h | 27 +++++++-------------- + llvm/include/llvm/ADT/SmallVector.h | 35 ++++++++++----------------- llvm/lib/Support/SmallVector.cpp | 37 +++++------------------------ - 2 files changed, 14 insertions(+), 50 deletions(-) + 2 files changed, 18 insertions(+), 54 deletions(-) diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h -index b42438a9b16c273f9ef5b5cce6192873c78cb964..7775ed7e8e083908f033529c30b1e4beae91b10a 100644 +index d7788e94b5379f5eba6fbddee50e4b4359da9d80..b953ae45a34772eb7fd04c3af0275a7d093e1242 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h -@@ -56,14 +56,14 @@ using EnableIfConvertibleToInputIterator = std::enable_if_t, where a /// 32 bit size would limit the vector to ~4GB. SmallVectors are used for /// buffering bitcode output - which can exceed 4GB. @@ -23,14 +23,35 @@ index b42438a9b16c273f9ef5b5cce6192873c78cb964..7775ed7e8e083908f033529c30b1e4be - Size_T Size = 0, Capacity; + unsigned Size = 0, Capacity; - /// The maximum value of the Size_T used. +- /// The maximum value of the Size_T used. ++ /// The maximum value of the unsigned used. static constexpr size_t SizeTypeMax() { - return (std::numeric_limits::max)(); + return (std::numeric_limits::max)(); } SmallVectorBase() = delete; -@@ -111,15 +111,10 @@ protected: + SmallVectorBase(void *FirstEl, size_t TotalCapacity) +- : BeginX(FirstEl), Capacity(static_cast(TotalCapacity)) {} ++ : BeginX(FirstEl), Capacity(static_cast(TotalCapacity)) {} + + /// This is a helper for \a grow() that's out of line to reduce code + /// duplication. This function will report a fatal error if it can't grow at +@@ -107,7 +107,7 @@ protected: + /// This does not construct or destroy any elements in the vector. + void set_size(size_t N) { + assert(N <= capacity()); // implies no overflow in assignment +- Size = static_cast(N); ++ Size = static_cast(N); + } + + /// Set the array data pointer to \p Begin and capacity to \p N. +@@ -117,19 +117,14 @@ protected: + void set_allocation_range(void *Begin, size_t N) { + assert(N <= SizeTypeMax()); + BeginX = Begin; +- Capacity = static_cast(N); ++ Capacity = static_cast(N); } }; @@ -48,7 +69,7 @@ index b42438a9b16c273f9ef5b5cce6192873c78cb964..7775ed7e8e083908f033529c30b1e4be alignas(T) char FirstEl[sizeof(T)]; }; -@@ -128,8 +123,8 @@ template struct SmallVectorAlignmentAndSize { +@@ -138,8 +133,8 @@ template struct SmallVectorAlignmentAndSize { /// to avoid unnecessarily requiring T to be complete. template class SmallVectorTemplateCommon @@ -59,7 +80,7 @@ index b42438a9b16c273f9ef5b5cce6192873c78cb964..7775ed7e8e083908f033529c30b1e4be protected: /// Find the address of the first element. For this pointer math to be valid -@@ -451,7 +446,7 @@ template +@@ -461,7 +456,7 @@ template T *SmallVectorTemplateBase::mallocForGrow( size_t MinSize, size_t &NewCapacity) { return static_cast( @@ -68,7 +89,7 @@ index b42438a9b16c273f9ef5b5cce6192873c78cb964..7775ed7e8e083908f033529c30b1e4be this->getFirstEl(), MinSize, sizeof(T), NewCapacity)); } -@@ -1324,12 +1319,6 @@ template SmallVector to_vector_of(R &&Range) { +@@ -1333,12 +1328,6 @@ template SmallVector to_vector_of(R &&Range) { return {std::begin(Range), std::end(Range)}; } @@ -82,7 +103,7 @@ index b42438a9b16c273f9ef5b5cce6192873c78cb964..7775ed7e8e083908f033529c30b1e4be namespace std { diff --git a/llvm/lib/Support/SmallVector.cpp b/llvm/lib/Support/SmallVector.cpp -index 6cefdff7c28060ca18b522acf5279af3a206e23a..ae64a36dcf4b9ceaf8767adbf8100f164f3738ac 100644 +index 4f6fee18b659adcbfd79822832f914170cbb1635..7ef023084d791cf746c346cb1655c9da36a6beb5 100644 --- a/llvm/lib/Support/SmallVector.cpp +++ b/llvm/lib/Support/SmallVector.cpp @@ -51,10 +51,6 @@ static_assert(sizeof(SmallVector) == @@ -144,9 +165,9 @@ index 6cefdff7c28060ca18b522acf5279af3a206e23a..ae64a36dcf4b9ceaf8767adbf8100f16 void *NewElts; if (BeginX == FirstEl) { NewElts = llvm::safe_malloc(NewCapacity * TSize); -@@ -155,20 +147,3 @@ void SmallVectorBase::grow_pod(void *FirstEl, size_t MinSize, - this->BeginX = NewElts; - this->Capacity = NewCapacity; +@@ -154,20 +146,3 @@ void SmallVectorBase::grow_pod(void *FirstEl, size_t MinSize, + + this->set_allocation_range(NewElts, NewCapacity); } - -template class llvm::SmallVectorBase; diff --git a/upstream_utils/llvm_patches/0011-Add-vectors-to-raw_ostream.patch b/upstream_utils/llvm_patches/0011-Add-vectors-to-raw_ostream.patch index 095729e5977..2142028a04d 100644 --- a/upstream_utils/llvm_patches/0011-Add-vectors-to-raw_ostream.patch +++ b/upstream_utils/llvm_patches/0011-Add-vectors-to-raw_ostream.patch @@ -155,10 +155,10 @@ index 95019180a9deb406ed4f2991c664a4cc4e956dac..e7526e016a858ad728feb7cf1c5014b9 class raw_null_ostream : public raw_pwrite_stream { /// See raw_ostream::write_impl. diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index 76c32155b4296fbbf3f4b164cd58d63f472ccd5e..dcdfdfd7a8e3fcc4019538a4fc9e158aeda0a8b8 100644 +index c65fb70a4d22db51f4140b910c308333289b6248..57d3091fd5cc5b416e814f9f33811f0fa7afe9cf 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp -@@ -670,6 +670,53 @@ void raw_svector_ostream::pwrite_impl(const char *Ptr, size_t Size, +@@ -668,6 +668,53 @@ void raw_svector_ostream::pwrite_impl(const char *Ptr, size_t Size, memcpy(OS.data() + Offset, Ptr, Size); } diff --git a/upstream_utils/llvm_patches/0012-Extra-collections-features.patch b/upstream_utils/llvm_patches/0012-Extra-collections-features.patch index 833e80bbcbd..d2118ee0a76 100644 --- a/upstream_utils/llvm_patches/0012-Extra-collections-features.patch +++ b/upstream_utils/llvm_patches/0012-Extra-collections-features.patch @@ -142,10 +142,10 @@ index 34dfbf83c681f4e81a9dadd9382ddca6ef8d6c1d..c133e84f9b2e3a225cdac782c011fadb #endif // LLVM_ADT_STRINGMAP_H diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index dcdfdfd7a8e3fcc4019538a4fc9e158aeda0a8b8..b2a726633b48b179abfd24a5de110a2301e0f877 100644 +index 57d3091fd5cc5b416e814f9f33811f0fa7afe9cf..5bec803ccc76ce287b7ff3ea037d5e490a7af20c 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp -@@ -76,6 +76,14 @@ constexpr raw_ostream::Colors raw_ostream::WHITE; +@@ -77,6 +77,14 @@ constexpr raw_ostream::Colors raw_ostream::WHITE; constexpr raw_ostream::Colors raw_ostream::SAVEDCOLOR; constexpr raw_ostream::Colors raw_ostream::RESET; diff --git a/upstream_utils/llvm_patches/0014-Delete-numbers-from-MathExtras.patch b/upstream_utils/llvm_patches/0014-Delete-numbers-from-MathExtras.patch index d8114c90b4c..40dab4fa1d6 100644 --- a/upstream_utils/llvm_patches/0014-Delete-numbers-from-MathExtras.patch +++ b/upstream_utils/llvm_patches/0014-Delete-numbers-from-MathExtras.patch @@ -8,7 +8,7 @@ Subject: [PATCH 14/34] Delete numbers from MathExtras 1 file changed, 36 deletions(-) diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index cd5a64a746b2eb7491e9b6cf8570bdf436d94a6d..cdf859ccfaca22a04b08a351d7c2c9789a70627e 100644 +index 7541447fa2db5e1634d952b1f39957eb725611f4..60b3b9012a32dda5e7c3ba1dc5923ffa68df8215 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -24,42 +24,6 @@ diff --git a/upstream_utils/llvm_patches/0015-Add-lerp-and-sgn.patch b/upstream_utils/llvm_patches/0015-Add-lerp-and-sgn.patch index c642e12c590..8d6564fe802 100644 --- a/upstream_utils/llvm_patches/0015-Add-lerp-and-sgn.patch +++ b/upstream_utils/llvm_patches/0015-Add-lerp-and-sgn.patch @@ -8,10 +8,10 @@ Subject: [PATCH 15/34] Add lerp and sgn 1 file changed, 20 insertions(+) diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index cdf859ccfaca22a04b08a351d7c2c9789a70627e..b82d9883c41008dcbbd933709c6e854ad74c5b58 100644 +index 60b3b9012a32dda5e7c3ba1dc5923ffa68df8215..daa79d99578e934ca001d1de5d2772ff961b8fc3 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h -@@ -614,6 +614,26 @@ std::enable_if_t, T> MulOverflow(T X, T Y, T &Result) { +@@ -617,6 +617,26 @@ std::enable_if_t, T> MulOverflow(T X, T Y, T &Result) { return UX > (static_cast((std::numeric_limits::max)())) / UY; } diff --git a/upstream_utils/llvm_patches/0016-Fixup-includes.patch b/upstream_utils/llvm_patches/0016-Fixup-includes.patch index 0200b2bef0d..fab7a8f31cb 100644 --- a/upstream_utils/llvm_patches/0016-Fixup-includes.patch +++ b/upstream_utils/llvm_patches/0016-Fixup-includes.patch @@ -91,7 +91,7 @@ index 0b87b375de67dc18647e3ebe646bf323dd05e8c5..3a88178cfbbcf7062a958c7de820247b using namespace llvm; diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index b2a726633b48b179abfd24a5de110a2301e0f877..3b7d8d6db5f0df31e18b91be716a4fd21e7e3549 100644 +index 5bec803ccc76ce287b7ff3ea037d5e490a7af20c..ae5428825f7f62ad8e742490448d40aea7506990 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -15,6 +15,8 @@ @@ -102,8 +102,8 @@ index b2a726633b48b179abfd24a5de110a2301e0f877..3b7d8d6db5f0df31e18b91be716a4fd2 +#include "wpi/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Config/config.h" - #include "llvm/Support/Compiler.h" -@@ -32,12 +34,11 @@ + #include "llvm/Support/AutoConvert.h" +@@ -33,12 +35,11 @@ #include // may provide O_BINARY. @@ -119,7 +119,7 @@ index b2a726633b48b179abfd24a5de110a2301e0f877..3b7d8d6db5f0df31e18b91be716a4fd2 #endif #if defined(__CYGWIN__) -@@ -60,7 +61,7 @@ +@@ -61,7 +62,7 @@ #ifdef _WIN32 #include "llvm/Support/ConvertUTF.h" #include "llvm/Support/Signals.h" diff --git a/upstream_utils/llvm_patches/0018-Use-std-is_trivially_copy_constructible.patch b/upstream_utils/llvm_patches/0018-Use-std-is_trivially_copy_constructible.patch deleted file mode 100644 index 47fdf0a91c6..00000000000 --- a/upstream_utils/llvm_patches/0018-Use-std-is_trivially_copy_constructible.patch +++ /dev/null @@ -1,60 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: PJ Reiniger -Date: Sun, 8 May 2022 16:42:09 -0400 -Subject: [PATCH 18/31] Use std::is_trivially_copy_constructible - ---- - llvm/include/llvm/Support/type_traits.h | 37 ++----------------------- - 1 file changed, 2 insertions(+), 35 deletions(-) - -diff --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h -index a6046de87d1e3e1264a0040826ea347b870a8f9e..292a2cb78b93717647cf88d00f88c2eec14f52f6 100644 ---- a/llvm/include/llvm/Support/type_traits.h -+++ b/llvm/include/llvm/Support/type_traits.h -@@ -92,44 +92,11 @@ union trivial_helper { - - } // end namespace detail - --/// An implementation of `std::is_trivially_copy_constructible` since we have --/// users with STLs that don't yet include it. - template --struct is_trivially_copy_constructible -- : std::is_copy_constructible< -- ::llvm::detail::copy_construction_triviality_helper> {}; --template --struct is_trivially_copy_constructible : std::true_type {}; --template --struct is_trivially_copy_constructible : std::false_type {}; -+using is_trivially_move_constructible = std::is_trivially_move_constructible; - --/// An implementation of `std::is_trivially_move_constructible` since we have --/// users with STLs that don't yet include it. --template --struct is_trivially_move_constructible -- : std::is_move_constructible< -- ::llvm::detail::move_construction_triviality_helper> {}; - template --struct is_trivially_move_constructible : std::true_type {}; --template --struct is_trivially_move_constructible : std::true_type {}; -- -- --template --struct is_copy_assignable { -- template -- static auto get(F*) -> decltype(std::declval() = std::declval(), std::true_type{}); -- static std::false_type get(...); -- static constexpr bool value = decltype(get((T*)nullptr))::value; --}; -- --template --struct is_move_assignable { -- template -- static auto get(F*) -> decltype(std::declval() = std::declval(), std::true_type{}); -- static std::false_type get(...); -- static constexpr bool value = decltype(get((T*)nullptr))::value; --}; -+using is_trivially_copy_constructible = std::is_trivially_copy_constructible; - - } // end namespace llvm - diff --git a/upstream_utils/llvm_patches/0018-Windows-support.patch b/upstream_utils/llvm_patches/0018-Windows-support.patch index 13d4275dfd7..6aea0b60e5a 100644 --- a/upstream_utils/llvm_patches/0018-Windows-support.patch +++ b/upstream_utils/llvm_patches/0018-Windows-support.patch @@ -204,10 +204,10 @@ index bc04c5ab5113563fb82d7b3b168985369b611f4b..57eb64a6017a6964ab14b40b8c6b3563 ConvertUTF_RESTORE_WARNINGS diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index 3b7d8d6db5f0df31e18b91be716a4fd21e7e3549..4769d34a14f3f2cbaaa4df50ea7111fe9fa2792f 100644 +index ae5428825f7f62ad8e742490448d40aea7506990..9ea41cad8fed864b53e2e463450c066fb4e00131 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp -@@ -534,7 +534,6 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) { +@@ -535,7 +535,6 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) { DWORD WinLastError = GetLastError(); if (WinLastError == ERROR_BROKEN_PIPE || (WinLastError == ERROR_NO_DATA && errno == EINVAL)) { diff --git a/upstream_utils/llvm_patches/0021-Remove-unused-functions.patch b/upstream_utils/llvm_patches/0021-Remove-unused-functions.patch index 53c08111d63..817e5b55d0d 100644 --- a/upstream_utils/llvm_patches/0021-Remove-unused-functions.patch +++ b/upstream_utils/llvm_patches/0021-Remove-unused-functions.patch @@ -62,10 +62,10 @@ index 54137a331ca9e752b02c0f16ae996094a6f2fafa..e253d6f7a5ca3aee75823efdb9717dcd #include diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index 4769d34a14f3f2cbaaa4df50ea7111fe9fa2792f..f9928ac969932b6baea60a80750477d78b6a5b02 100644 +index 9ea41cad8fed864b53e2e463450c066fb4e00131..44149e85876f089756dcce151670a6060eadfee1 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp -@@ -175,16 +175,6 @@ raw_ostream &raw_ostream::write_escaped(std::string_view Str, +@@ -176,16 +176,6 @@ raw_ostream &raw_ostream::write_escaped(std::string_view Str, return *this; } @@ -82,7 +82,7 @@ index 4769d34a14f3f2cbaaa4df50ea7111fe9fa2792f..f9928ac969932b6baea60a80750477d7 void raw_ostream::flush_nonempty() { assert(OutBufCur > OutBufStart && "Invalid call to flush_nonempty."); size_t Length = OutBufCur - OutBufStart; -@@ -327,15 +317,22 @@ static int getFD(std::string_view Filename, std::error_code &EC, +@@ -328,15 +318,22 @@ static int getFD(std::string_view Filename, std::error_code &EC, if (Filename == "-") { EC = std::error_code(); // Change stdout's text/binary mode based on the Flags. @@ -110,7 +110,7 @@ index 4769d34a14f3f2cbaaa4df50ea7111fe9fa2792f..f9928ac969932b6baea60a80750477d7 if (EC) return -1; -@@ -395,12 +392,8 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered, +@@ -396,12 +393,8 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered, // Get the starting position. off_t loc = ::lseek(FD, 0, SEEK_CUR); @@ -124,7 +124,7 @@ index 4769d34a14f3f2cbaaa4df50ea7111fe9fa2792f..f9928ac969932b6baea60a80750477d7 #else SupportsSeeking = !EC && loc != (off_t)-1; #endif -@@ -413,10 +406,8 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered, +@@ -414,10 +407,8 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered, raw_fd_ostream::~raw_fd_ostream() { if (FD >= 0) { flush(); @@ -137,7 +137,7 @@ index 4769d34a14f3f2cbaaa4df50ea7111fe9fa2792f..f9928ac969932b6baea60a80750477d7 } #ifdef __MINGW32__ -@@ -511,7 +502,11 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) { +@@ -512,7 +503,11 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) { do { size_t ChunkSize = std::min(Size, MaxWriteSize); @@ -149,7 +149,7 @@ index 4769d34a14f3f2cbaaa4df50ea7111fe9fa2792f..f9928ac969932b6baea60a80750477d7 if (ret < 0) { // If it's a recoverable error, swallow it and retry the write. -@@ -554,8 +549,8 @@ void raw_fd_ostream::close() { +@@ -555,8 +550,8 @@ void raw_fd_ostream::close() { assert(ShouldClose); ShouldClose = false; flush(); diff --git a/upstream_utils/llvm_patches/0024-Prefer-to-use-static-pointers-in-raw_ostream.patch b/upstream_utils/llvm_patches/0024-Prefer-to-use-static-pointers-in-raw_ostream.patch index fd6f137209e..9e1b862865d 100644 --- a/upstream_utils/llvm_patches/0024-Prefer-to-use-static-pointers-in-raw_ostream.patch +++ b/upstream_utils/llvm_patches/0024-Prefer-to-use-static-pointers-in-raw_ostream.patch @@ -9,13 +9,13 @@ See #1401 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index f9928ac969932b6baea60a80750477d78b6a5b02..1de34976844d500970b833fca35324e2948733b7 100644 +index 44149e85876f089756dcce151670a6060eadfee1..8fe686142b8cdba76287a3b8b97569fde922f2bf 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp -@@ -613,15 +613,15 @@ void raw_fd_ostream::anchor() {} - raw_fd_ostream &llvm::outs() { - // Set buffer settings to model stdout behavior. - std::error_code EC; +@@ -615,9 +615,9 @@ raw_fd_ostream &llvm::outs() { + EC = enableAutoConversion(STDOUT_FILENO); + assert(!EC); + #endif - static raw_fd_ostream S("-", EC, sys::fs::OF_None); + static raw_fd_ostream* S = new raw_fd_ostream("-", EC, sys::fs::OF_None); assert(!EC); @@ -24,7 +24,10 @@ index f9928ac969932b6baea60a80750477d78b6a5b02..1de34976844d500970b833fca35324e2 } raw_fd_ostream &llvm::errs() { - // Set standard error to be unbuffered and tied to outs() by default. +@@ -626,8 +626,8 @@ raw_fd_ostream &llvm::errs() { + std::error_code EC = enableAutoConversion(STDERR_FILENO); + assert(!EC); + #endif - static raw_fd_ostream S(STDERR_FILENO, false, true); - return S; + static raw_fd_ostream* S = new raw_fd_ostream(STDERR_FILENO, false, true); diff --git a/upstream_utils/llvm_patches/0025-constexpr-endian-byte-swap.patch b/upstream_utils/llvm_patches/0025-constexpr-endian-byte-swap.patch index 6b3367b4914..19fe1d96a8c 100644 --- a/upstream_utils/llvm_patches/0025-constexpr-endian-byte-swap.patch +++ b/upstream_utils/llvm_patches/0025-constexpr-endian-byte-swap.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: PJ Reiniger -Date: Thu, 19 May 2022 01:12:41 -0400 +Date: Fri, 1 Mar 2024 11:56:17 -0800 Subject: [PATCH 25/34] constexpr endian byte swap --- @@ -8,15 +8,15 @@ Subject: [PATCH 25/34] constexpr endian byte swap 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/Support/Endian.h b/llvm/include/llvm/Support/Endian.h -index 5e7c1e961b9d1e0fd6bcd0c923f678a5e1596860..2e883ff05b7e287151b6031f66d3b4aefd1bf297 100644 +index 4c0405cf1e2f69c6268d708badc2aef6dd968b51..f31fbf70fb723d19634e61ea4f21549fc767e58c 100644 --- a/llvm/include/llvm/Support/Endian.h +++ b/llvm/include/llvm/Support/Endian.h -@@ -55,7 +55,9 @@ inline value_type byte_swap(value_type value, endianness endian) { +@@ -50,7 +50,9 @@ template /// Swap the bytes of value to match the given endianness. - template - inline value_type byte_swap(value_type value) { + template + [[nodiscard]] inline value_type byte_swap(value_type value) { - return byte_swap(value, endian); -+ if constexpr ((endian != native) && (endian != system_endianness())) ++ if constexpr (endian != llvm::endianness::native) + sys::swapByteOrder(value); + return value; } diff --git a/upstream_utils/llvm_patches/0029-Use-C-20-bit-header.patch b/upstream_utils/llvm_patches/0029-Use-C-20-bit-header.patch index cc666286599..bc79b0837b7 100644 --- a/upstream_utils/llvm_patches/0029-Use-C-20-bit-header.patch +++ b/upstream_utils/llvm_patches/0029-Use-C-20-bit-header.patch @@ -6,9 +6,9 @@ Subject: [PATCH 29/34] Use C++20 header --- llvm/include/llvm/ADT/DenseMap.h | 3 +- llvm/include/llvm/ADT/Hashing.h | 35 +-- - llvm/include/llvm/ADT/bit.h | 287 ------------------------- + llvm/include/llvm/ADT/bit.h | 313 ------------------------- llvm/include/llvm/Support/MathExtras.h | 21 +- - 4 files changed, 31 insertions(+), 315 deletions(-) + 4 files changed, 31 insertions(+), 341 deletions(-) diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h index e9bd3bfa4a6fe0fa26ff20069bbadc816c8baa65..93b50c9e53af4ea3af5fd0329a8a03bdce659e9d 100644 @@ -32,7 +32,7 @@ index e9bd3bfa4a6fe0fa26ff20069bbadc816c8baa65..93b50c9e53af4ea3af5fd0329a8a03bd } diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h -index 781bdb7416392e3f60a1ac3a38fbcf5324b5395f..28934add722f518ae1e9cb9c4a23d2212a47cbdf 100644 +index 08d6edb14eb3cd51405329aae61b9782266a2590..e84d53e6bf2f741be562b9d66bf0bdfe4a79f936 100644 --- a/llvm/include/llvm/ADT/Hashing.h +++ b/llvm/include/llvm/ADT/Hashing.h @@ -49,6 +49,7 @@ @@ -123,13 +123,39 @@ index 781bdb7416392e3f60a1ac3a38fbcf5324b5395f..28934add722f518ae1e9cb9c4a23d221 h4 = h0 + h5; mix_32_bytes(s, h3, h4); diff --git a/llvm/include/llvm/ADT/bit.h b/llvm/include/llvm/ADT/bit.h -index 2840c5f608d3ea896e1867dd4710685da9572f2d..0a4a3634820efbc0a8ca675e3ad7c98469260d0b 100644 +index c42b5e686bdc9cf3da71d8edaddc08216fe5fb2a..a19b6a9b80da2965f1308d3e7b0ade593b522a08 100644 --- a/llvm/include/llvm/ADT/bit.h +++ b/llvm/include/llvm/ADT/bit.h -@@ -27,18 +27,6 @@ +@@ -27,44 +27,6 @@ #include // for _byteswap_{ushort,ulong,uint64} #endif +-#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \ +- defined(__Fuchsia__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || \ +- defined(__OpenBSD__) || defined(__DragonFly__) +-#include +-#elif defined(_AIX) +-#include +-#elif defined(__sun) +-/* Solaris provides _BIG_ENDIAN/_LITTLE_ENDIAN selector in sys/types.h */ +-#include +-#define BIG_ENDIAN 4321 +-#define LITTLE_ENDIAN 1234 +-#if defined(_BIG_ENDIAN) +-#define BYTE_ORDER BIG_ENDIAN +-#else +-#define BYTE_ORDER LITTLE_ENDIAN +-#endif +-#elif defined(__MVS__) +-#define BIG_ENDIAN 4321 +-#define LITTLE_ENDIAN 1234 +-#define BYTE_ORDER BIG_ENDIAN +-#else +-#if !defined(BYTE_ORDER) && !defined(_WIN32) +-#include +-#endif +-#endif +- -#ifdef _MSC_VER -// Declare these intrinsics manually rather including intrin.h. It's very -// expensive, and bit.h is popular via MathExtras.h. @@ -144,8 +170,8 @@ index 2840c5f608d3ea896e1867dd4710685da9572f2d..0a4a3634820efbc0a8ca675e3ad7c984 - namespace llvm { - // This implementation of bit_cast is different from the C++20 one in two ways: -@@ -106,281 +94,6 @@ template >> + enum class endianness { +@@ -142,281 +104,6 @@ template >> } } @@ -428,7 +454,7 @@ index 2840c5f608d3ea896e1867dd4710685da9572f2d..0a4a3634820efbc0a8ca675e3ad7c984 #endif diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index b82d9883c41008dcbbd933709c6e854ad74c5b58..5f034b694989d8ef24e0b249abd12a5c20146b97 100644 +index daa79d99578e934ca001d1de5d2772ff961b8fc3..f66e64b601d01f17dc6c7a4e568cc4eb1d9bb985 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -15,6 +15,7 @@ diff --git a/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch b/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch index a8bc557b487..05a3ed8dd22 100644 --- a/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch +++ b/upstream_utils/llvm_patches/0031-Replace-deprecated-std-aligned_storage_t.patch @@ -8,18 +8,18 @@ Subject: [PATCH 31/34] Replace deprecated std::aligned_storage_t 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h -index 1daeae915eb506b32a2d1296d2f0fe4e6dab606e..2e60e34d69914bd9b2197fc0a0e75a8e025674b2 100644 +index 043d8d90fff03d571a923c264b49be37a5dffa09..a62d5ce00d784def5ae21b8d91cea40cee7bf942 100644 --- a/llvm/include/llvm/ADT/FunctionExtras.h +++ b/llvm/include/llvm/ADT/FunctionExtras.h -@@ -37,6 +37,7 @@ - #include "llvm/ADT/STLForwardCompat.h" +@@ -38,6 +38,7 @@ + #include "llvm/Support/Compiler.h" #include "llvm/Support/MemAlloc.h" #include "llvm/Support/type_traits.h" +#include #include #include #include -@@ -167,8 +168,7 @@ protected: +@@ -168,8 +169,7 @@ protected: // provide four pointers worth of storage here. // This is mutable as an inlined `const unique_function` may // still modify its own mutable members. diff --git a/upstream_utils/llvm_patches/0032-Fix-compilation-of-MathExtras.h-on-Windows-with-sdl.patch b/upstream_utils/llvm_patches/0032-Fix-compilation-of-MathExtras.h-on-Windows-with-sdl.patch deleted file mode 100644 index 09b7c03f7fa..00000000000 --- a/upstream_utils/llvm_patches/0032-Fix-compilation-of-MathExtras.h-on-Windows-with-sdl.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Benjamin Hall -Date: Mon, 23 Oct 2023 21:36:40 -0400 -Subject: [PATCH 32/34] Fix compilation of MathExtras.h on Windows with /sdl - -See https://github.com/llvm/llvm-project/pull/68978 ---- - llvm/include/llvm/Support/MathExtras.h | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index 5f034b694989d8ef24e0b249abd12a5c20146b97..03db6e4d92cb3b62ac3d8b3cbd97783817c6326b 100644 ---- a/llvm/include/llvm/Support/MathExtras.h -+++ b/llvm/include/llvm/Support/MathExtras.h -@@ -356,7 +356,10 @@ inline uint64_t alignTo(uint64_t Value, uint64_t Align) { - inline uint64_t alignToPowerOf2(uint64_t Value, uint64_t Align) { - assert(Align != 0 && (Align & (Align - 1)) == 0 && - "Align must be a power of 2"); -- return (Value + Align - 1) & -Align; -+ // Replace unary minus to avoid compilation error on Windows: -+ // "unary minus operator applied to unsigned type, result still unsigned" -+ uint64_t negAlign = (~Align) + 1; -+ return (Value + Align - 1) & negAlign; - } - - /// If non-zero \p Skew is specified, the return value will be a minimal integer diff --git a/upstream_utils/llvm_patches/0033-raw_ostream-Add-SetNumBytesInBuffer.patch b/upstream_utils/llvm_patches/0032-raw_ostream-Add-SetNumBytesInBuffer.patch similarity index 93% rename from upstream_utils/llvm_patches/0033-raw_ostream-Add-SetNumBytesInBuffer.patch rename to upstream_utils/llvm_patches/0032-raw_ostream-Add-SetNumBytesInBuffer.patch index f4699c4dfee..93d6449429b 100644 --- a/upstream_utils/llvm_patches/0033-raw_ostream-Add-SetNumBytesInBuffer.patch +++ b/upstream_utils/llvm_patches/0032-raw_ostream-Add-SetNumBytesInBuffer.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sun, 29 Oct 2023 23:00:08 -0700 -Subject: [PATCH 33/34] raw_ostream: Add SetNumBytesInBuffer +Subject: [PATCH 32/34] raw_ostream: Add SetNumBytesInBuffer --- llvm/include/llvm/Support/raw_ostream.h | 5 +++++ diff --git a/upstream_utils/llvm_patches/0034-type_traits.h-Add-is_constexpr.patch b/upstream_utils/llvm_patches/0033-type_traits.h-Add-is_constexpr.patch similarity index 94% rename from upstream_utils/llvm_patches/0034-type_traits.h-Add-is_constexpr.patch rename to upstream_utils/llvm_patches/0033-type_traits.h-Add-is_constexpr.patch index b881452fb24..b9cdac98ee5 100644 --- a/upstream_utils/llvm_patches/0034-type_traits.h-Add-is_constexpr.patch +++ b/upstream_utils/llvm_patches/0033-type_traits.h-Add-is_constexpr.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Sat, 2 Dec 2023 15:21:32 -0800 -Subject: [PATCH 34/34] type_traits.h: Add is_constexpr() +Subject: [PATCH 33/34] type_traits.h: Add is_constexpr() --- llvm/include/llvm/Support/type_traits.h | 5 +++++ diff --git a/upstream_utils/llvm_patches/0034-Add-back-removed-raw_string_ostream-write_impl.patch b/upstream_utils/llvm_patches/0034-Add-back-removed-raw_string_ostream-write_impl.patch new file mode 100644 index 00000000000..a84a4dcd43d --- /dev/null +++ b/upstream_utils/llvm_patches/0034-Add-back-removed-raw_string_ostream-write_impl.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Tyler Veness +Date: Fri, 1 Mar 2024 11:37:36 -0800 +Subject: [PATCH 34/34] Add back removed raw_string_ostream::write_impl() + +--- + llvm/lib/Support/raw_ostream.cpp | 8 ++++++++ + 1 file changed, 8 insertions(+) + +diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp +index 8fe686142b8cdba76287a3b8b97569fde922f2bf..9134f3d3db220ec5afb87b72cb9aed76c52a80ca 100644 +--- a/llvm/lib/Support/raw_ostream.cpp ++++ b/llvm/lib/Support/raw_ostream.cpp +@@ -656,6 +656,14 @@ bool raw_fd_stream::classof(const raw_ostream *OS) { + return OS->get_kind() == OStreamKind::OK_FDStream; + } + ++//===----------------------------------------------------------------------===// ++// raw_string_ostream ++//===----------------------------------------------------------------------===// ++ ++void raw_string_ostream::write_impl(const char *Ptr, size_t Size) { ++ OS.append(Ptr, Size); ++} ++ + //===----------------------------------------------------------------------===// + // raw_svector_ostream + //===----------------------------------------------------------------------===// diff --git a/upstream_utils/update_llvm.py b/upstream_utils/update_llvm.py index 5c221ee5e7d..bd13c1c34a6 100755 --- a/upstream_utils/update_llvm.py +++ b/upstream_utils/update_llvm.py @@ -171,7 +171,9 @@ def overwrite_tests(wpiutil_root, llvm_root): def main(): - upstream_root = clone_repo("https://github.com/llvm/llvm-project", "llvmorg-17.0.5") + upstream_root = clone_repo( + "https://github.com/llvm/llvm-project", "llvmorg-18.1.0" + ) wpilib_root = get_repo_root() wpiutil = os.path.join(wpilib_root, "wpiutil") @@ -209,9 +211,9 @@ def main(): "0029-Use-C-20-bit-header.patch", "0030-Remove-DenseMap-GTest-printer-test.patch", "0031-Replace-deprecated-std-aligned_storage_t.patch", - "0032-Fix-compilation-of-MathExtras.h-on-Windows-with-sdl.patch", - "0033-raw_ostream-Add-SetNumBytesInBuffer.patch", - "0034-type_traits.h-Add-is_constexpr.patch", + "0032-raw_ostream-Add-SetNumBytesInBuffer.patch", + "0033-type_traits.h-Add-is_constexpr.patch", + "0034-Add-back-removed-raw_string_ostream-write_impl.patch", ]: git_am( os.path.join(wpilib_root, "upstream_utils/llvm_patches", f), diff --git a/wpiutil/src/main/native/cpp/DataLog.cpp b/wpiutil/src/main/native/cpp/DataLog.cpp index bbde5e7b7c7..ab9cbf7c6c4 100644 --- a/wpiutil/src/main/native/cpp/DataLog.cpp +++ b/wpiutil/src/main/native/cpp/DataLog.cpp @@ -20,6 +20,7 @@ #endif #include +#include #include #include #include @@ -821,8 +822,7 @@ void DataLog::AppendFloat(int entry, float value, int64_t timestamp) { [[unlikely]] return; } uint8_t* buf = StartRecord(entry, timestamp, 4, 4); - if constexpr (wpi::support::endian::system_endianness() == - wpi::support::little) { + if constexpr (std::endian::native == std::endian::little) { std::memcpy(buf, &value, 4); } else { wpi::support::endian::write32le(buf, wpi::bit_cast(value)); @@ -838,8 +838,7 @@ void DataLog::AppendDouble(int entry, double value, int64_t timestamp) { [[unlikely]] return; } uint8_t* buf = StartRecord(entry, timestamp, 8, 8); - if constexpr (wpi::support::endian::system_endianness() == - wpi::support::little) { + if constexpr (std::endian::native == std::endian::little) { std::memcpy(buf, &value, 8); } else { wpi::support::endian::write64le(buf, wpi::bit_cast(value)); @@ -908,8 +907,7 @@ void DataLog::AppendBooleanArray(int entry, std::span arr, void DataLog::AppendIntegerArray(int entry, std::span arr, int64_t timestamp) { - if constexpr (wpi::support::endian::system_endianness() == - wpi::support::little) { + if constexpr (std::endian::native == std::endian::little) { AppendRaw(entry, {reinterpret_cast(arr.data()), arr.size() * 8}, timestamp); @@ -941,8 +939,7 @@ void DataLog::AppendIntegerArray(int entry, std::span arr, void DataLog::AppendFloatArray(int entry, std::span arr, int64_t timestamp) { - if constexpr (wpi::support::endian::system_endianness() == - wpi::support::little) { + if constexpr (std::endian::native == std::endian::little) { AppendRaw(entry, {reinterpret_cast(arr.data()), arr.size() * 4}, timestamp); @@ -974,8 +971,7 @@ void DataLog::AppendFloatArray(int entry, std::span arr, void DataLog::AppendDoubleArray(int entry, std::span arr, int64_t timestamp) { - if constexpr (wpi::support::endian::system_endianness() == - wpi::support::little) { + if constexpr (std::endian::native == std::endian::little) { AppendRaw(entry, {reinterpret_cast(arr.data()), arr.size() * 8}, timestamp); diff --git a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/AutoConvert.cpp b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/AutoConvert.cpp new file mode 100644 index 00000000000..45caf7693e7 --- /dev/null +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/AutoConvert.cpp @@ -0,0 +1,118 @@ +//===- AutoConvert.cpp - Auto conversion between ASCII/EBCDIC -------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file contains functions used for auto conversion between +// ASCII/EBCDIC codepages specific to z/OS. +// +//===----------------------------------------------------------------------===// + +#ifdef __MVS__ + +#include "wpi/AutoConvert.h" +#include +#include +#include +#include + +static int savedStdHandleAutoConversionMode[3] = {-1, -1, -1}; + +int disableAutoConversion(int FD) { + static const struct f_cnvrt Convert = { + SETCVTOFF, // cvtcmd + 0, // pccsid + 0, // fccsid + }; + + return fcntl(FD, F_CONTROL_CVT, &Convert); +} + +int restoreStdHandleAutoConversion(int FD) { + assert(FD == STDIN_FILENO || FD == STDOUT_FILENO || FD == STDERR_FILENO); + if (savedStdHandleAutoConversionMode[FD] == -1) + return 0; + struct f_cnvrt Cvt = { + savedStdHandleAutoConversionMode[FD], // cvtcmd + 0, // pccsid + 0, // fccsid + }; + return (fcntl(FD, F_CONTROL_CVT, &Cvt)); +} + +int enableAutoConversion(int FD) { + struct f_cnvrt Query = { + QUERYCVT, // cvtcmd + 0, // pccsid + 0, // fccsid + }; + + if (fcntl(FD, F_CONTROL_CVT, &Query) == -1) + return -1; + + // We don't need conversion for UTF-8 tagged files. + // TODO: Remove the assumption of ISO8859-1 = UTF-8 here when we fully resolve + // problems related to UTF-8 tagged source files. + // When the pccsid is not ISO8859-1, autoconversion is still needed. + if (Query.pccsid == CCSID_ISO8859_1 && + (Query.fccsid == CCSID_UTF_8 || Query.fccsid == CCSID_ISO8859_1)) + return 0; + + // Save the state of std handles before we make changes to it. + if ((FD == STDIN_FILENO || FD == STDOUT_FILENO || FD == STDERR_FILENO) && + savedStdHandleAutoConversionMode[FD] == -1) + savedStdHandleAutoConversionMode[FD] = Query.cvtcmd; + + if (FD == STDOUT_FILENO || FD == STDERR_FILENO) + Query.cvtcmd = SETCVTON; + else + Query.cvtcmd = SETCVTALL; + + Query.pccsid = + (FD == STDIN_FILENO || FD == STDOUT_FILENO || FD == STDERR_FILENO) + ? 0 + : CCSID_UTF_8; + // Assume untagged files to be IBM-1047 encoded. + Query.fccsid = (Query.fccsid == FT_UNTAGGED) ? CCSID_IBM_1047 : Query.fccsid; + return fcntl(FD, F_CONTROL_CVT, &Query); +} + +std::error_code wpi::disableAutoConversion(int FD) { + if (::disableAutoConversion(FD) == -1) + return std::error_code(errno, std::generic_category()); + + return std::error_code(); +} + +std::error_code wpi::enableAutoConversion(int FD) { + if (::enableAutoConversion(FD) == -1) + return std::error_code(errno, std::generic_category()); + + return std::error_code(); +} + +std::error_code wpi::restoreStdHandleAutoConversion(int FD) { + if (::restoreStdHandleAutoConversion(FD) == -1) + return std::error_code(errno, std::generic_category()); + + return std::error_code(); +} + +std::error_code wpi::setFileTag(int FD, int CCSID, bool Text) { + assert((!Text || (CCSID != FT_UNTAGGED && CCSID != FT_BINARY)) && + "FT_UNTAGGED and FT_BINARY are not allowed for text files"); + struct file_tag Tag; + Tag.ft_ccsid = CCSID; + Tag.ft_txtflag = Text; + Tag.ft_deferred = 0; + Tag.ft_rsvflags = 0; + + if (fcntl(FD, F_SETTAG, &Tag) == -1) + return std::error_code(errno, std::generic_category()); + return std::error_code(); +} + +#endif // __MVS__ diff --git a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/SmallVector.cpp b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/SmallVector.cpp index 803523af25f..488fb7aea9f 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/SmallVector.cpp +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/SmallVector.cpp @@ -144,6 +144,5 @@ void SmallVectorBase::grow_pod(void *FirstEl, size_t MinSize, NewElts = replaceAllocation(NewElts, TSize, NewCapacity, size()); } - this->BeginX = NewElts; - this->Capacity = NewCapacity; + this->set_allocation_range(NewElts, NewCapacity); } diff --git a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/raw_ostream.cpp b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/raw_ostream.cpp index 05036a84a3e..9bdfd8e2a6f 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/raw_ostream.cpp +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/raw_ostream.cpp @@ -18,6 +18,7 @@ #include "wpi/SmallString.h" #include "wpi/SmallVector.h" #include "wpi/StringExtras.h" +#include "wpi/AutoConvert.h" #include "wpi/Compiler.h" #include "wpi/ErrorHandling.h" #include "wpi/fs.h" @@ -578,8 +579,7 @@ size_t raw_fd_ostream::preferred_buffer_size() const { if (IsWindowsConsole) return 0; return raw_ostream::preferred_buffer_size(); -#elif !defined(__minix) - // Minix has no st_blksize. +#else assert(FD >= 0 && "File not yet open!"); struct stat statbuf; if (fstat(FD, &statbuf) != 0) @@ -592,8 +592,6 @@ size_t raw_fd_ostream::preferred_buffer_size() const { return 0; // Return the preferred block size. return statbuf.st_blksize; -#else - return raw_ostream::preferred_buffer_size(); #endif } @@ -606,6 +604,10 @@ void raw_fd_ostream::anchor() {} raw_fd_ostream &wpi::outs() { // Set buffer settings to model stdout behavior. std::error_code EC; +#ifdef __MVS__ + EC = enableAutoConversion(STDOUT_FILENO); + assert(!EC); +#endif static raw_fd_ostream* S = new raw_fd_ostream("-", EC, fs::OF_None); assert(!EC); return *S; @@ -613,6 +615,10 @@ raw_fd_ostream &wpi::outs() { raw_fd_ostream &wpi::errs() { // Set standard error to be unbuffered and tied to outs() by default. +#ifdef __MVS__ + std::error_code EC = enableAutoConversion(STDERR_FILENO); + assert(!EC); +#endif static raw_fd_ostream* S = new raw_fd_ostream(STDERR_FILENO, false, true); return *S; } diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AutoConvert.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AutoConvert.h new file mode 100644 index 00000000000..b83632068b0 --- /dev/null +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AutoConvert.h @@ -0,0 +1,60 @@ +//===- AutoConvert.h - Auto conversion between ASCII/EBCDIC -----*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file contains functions used for auto conversion between +// ASCII/EBCDIC codepages specific to z/OS. +// +//===----------------------------------------------------------------------===//i + +#ifndef WPIUTIL_WPI_AUTOCONVERT_H +#define WPIUTIL_WPI_AUTOCONVERT_H + +#ifdef __MVS__ +#include <_Ccsid.h> +#ifdef __cplusplus +#include +#endif // __cplusplus + +#define CCSID_IBM_1047 1047 +#define CCSID_UTF_8 1208 +#define CCSID_ISO8859_1 819 + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus +int enableAutoConversion(int FD); +int disableAutoConversion(int FD); +int restoreStdHandleAutoConversion(int FD); +#ifdef __cplusplus +} +#endif // __cplusplus + +#ifdef __cplusplus +namespace wpi { + +/// \brief Disable the z/OS enhanced ASCII auto-conversion for the file +/// descriptor. +std::error_code disableAutoConversion(int FD); + +/// \brief Query the z/OS enhanced ASCII auto-conversion status of a file +/// descriptor and force the conversion if the file is not tagged with a +/// codepage. +std::error_code enableAutoConversion(int FD); + +/// Restore the z/OS enhanced ASCII auto-conversion for the std handle. +std::error_code restoreStdHandleAutoConversion(int FD); + +/// \brief Set the tag information for a file descriptor. +std::error_code setFileTag(int FD, int CCSID, bool Text); + +} // namespace wpi +#endif // __cplusplus + +#endif // __MVS__ + +#endif // WPIUTIL_WPI_AUTOCONVERT_H diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Casting.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Casting.h index c91f1b772a9..60692f2b4de 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Casting.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Casting.h @@ -351,10 +351,10 @@ struct UniquePtrCast : public CastIsPossible { static inline CastResultType castFailed() { return CastResultType(nullptr); } - static inline CastResultType doCastIfPossible(std::unique_ptr &&f) { - if (!Self::isPossible(f)) + static inline CastResultType doCastIfPossible(std::unique_ptr &f) { + if (!Self::isPossible(f.get())) return castFailed(); - return doCast(f); + return doCast(std::move(f)); } }; @@ -664,10 +664,9 @@ template } template -[[nodiscard]] inline decltype(auto) dyn_cast(std::unique_ptr &&Val) { +[[nodiscard]] inline decltype(auto) dyn_cast(std::unique_ptr &Val) { assert(detail::isPresent(Val) && "dyn_cast on a non-existent value"); - return CastInfo>::doCastIfPossible( - std::forward &&>(Val)); + return CastInfo>::doCastIfPossible(Val); } /// isa_and_present - Functionally identical to isa, except that a null value diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Chrono.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Chrono.h index 221f6dc19bc..299e8226513 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Chrono.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Chrono.h @@ -32,6 +32,19 @@ namespace sys { template using TimePoint = std::chrono::time_point; +// utc_clock and utc_time are only available since C++20. Add enough code to +// support formatting date/time in UTC. +class UtcClock : public std::chrono::system_clock {}; + +template +using UtcTime = std::chrono::time_point; + +/// Convert a std::time_t to a UtcTime +inline UtcTime toUtcTime(std::time_t T) { + using namespace std::chrono; + return UtcTime(seconds(T)); +} + /// Convert a TimePoint to std::time_t inline std::time_t toTimeT(TimePoint<> TP) { using namespace std::chrono; @@ -39,6 +52,13 @@ inline std::time_t toTimeT(TimePoint<> TP) { time_point_cast(TP)); } +/// Convert a UtcTime to std::time_t +inline std::time_t toTimeT(UtcTime<> TP) { + using namespace std::chrono; + return system_clock::to_time_t(time_point( + duration_cast(TP.time_since_epoch()))); +} + /// Convert a std::time_t to a TimePoint inline TimePoint toTimePoint(std::time_t T) { @@ -57,6 +77,7 @@ toTimePoint(std::time_t T, uint32_t nsec) { } // namespace sys raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP); +raw_ostream &operator<<(raw_ostream &OS, sys::UtcTime<> TP); } // namespace wpi diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Compiler.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Compiler.h index 121ed5416d7..59362dc1dab 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Compiler.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Compiler.h @@ -162,6 +162,25 @@ #define LLVM_DEPRECATED(MSG, FIX) [[deprecated(MSG)]] #endif +// clang-format off +#if defined(__clang__) || defined(__GNUC__) +#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") +#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP \ + _Pragma("GCC diagnostic pop") +#elif defined(_MSC_VER) +#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH \ + _Pragma("warning(push)") \ + _Pragma("warning(disable : 4996)") +#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP \ + _Pragma("warning(pop)") +#else +#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_PUSH +#define LLVM_SUPPRESS_DEPRECATED_DECLARATIONS_POP +#endif +// clang-format on + // Indicate that a non-static, non-const C++ member function reinitializes // the entire object to a known state, independent of the previous state of // the object. @@ -330,6 +349,12 @@ #define LLVM_GSL_POINTER #endif +#if LLVM_HAS_CPP_ATTRIBUTE(nodiscard) >= 201907L +#define LLVM_CTOR_NODISCARD [[nodiscard]] +#else +#define LLVM_CTOR_NODISCARD +#endif + /// LLVM_EXTENSION - Support compilers where we have a keyword to suppress /// pedantic diagnostics. #ifndef LLVM_EXTENSION @@ -598,4 +623,12 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); #define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION #endif +/// \macro LLVM_PREFERRED_TYPE +/// Adjust type of bit-field in debug info. +#if __has_attribute(preferred_type) +#define LLVM_PREFERRED_TYPE(T) __attribute__((preferred_type(T))) +#else +#define LLVM_PREFERRED_TYPE(T) +#endif + #endif diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Endian.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Endian.h index d243a13c4f9..bfbf1e7eb34 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Endian.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Endian.h @@ -13,6 +13,7 @@ #ifndef WPIUTIL_WPI_ENDIAN_H #define WPIUTIL_WPI_ENDIAN_H +#include "wpi/bit.h" #include "wpi/Compiler.h" #include "wpi/SwapByteOrder.h" #include @@ -24,8 +25,6 @@ namespace wpi { namespace support { -enum endianness {big, little, native}; - // These are named values for common alignments. enum {aligned = 0, unaligned = 1}; @@ -41,28 +40,24 @@ struct PickAlignment { namespace endian { -constexpr endianness system_endianness() { - return sys::IsBigEndianHost ? big : little; -} - template -inline value_type byte_swap(value_type value, endianness endian) { - if ((endian != native) && (endian != system_endianness())) +[[nodiscard]] inline value_type byte_swap(value_type value, endianness endian) { + if (endian != wpi::endianness::native) sys::swapByteOrder(value); return value; } /// Swap the bytes of value to match the given endianness. -template -inline value_type byte_swap(value_type value) { - if constexpr ((endian != native) && (endian != system_endianness())) +template +[[nodiscard]] inline value_type byte_swap(value_type value) { + if constexpr (endian != wpi::endianness::native) sys::swapByteOrder(value); return value; } /// Read a value of a particular endianness from memory. -template -inline value_type read(const void *memory, endianness endian) { +template +[[nodiscard]] inline value_type read(const void *memory, endianness endian) { value_type ret; memcpy(&ret, @@ -72,30 +67,29 @@ inline value_type read(const void *memory, endianness endian) { return byte_swap(ret, endian); } -template -inline value_type read(const void *memory) { +template +[[nodiscard]] inline value_type read(const void *memory) { return read(memory, endian); } /// Read a value of a particular endianness from a buffer, and increment the /// buffer past that value. template -inline value_type readNext(const CharT *&memory, endianness endian) { +[[nodiscard]] inline value_type readNext(const CharT *&memory, + endianness endian) { value_type ret = read(memory, endian); memory += sizeof(value_type); return ret; } -template -inline value_type readNext(const CharT *&memory) { +template +[[nodiscard]] inline value_type readNext(const CharT *&memory) { return readNext(memory, endian); } /// Write a value to memory with a particular endianness. -template +template inline void write(void *memory, value_type value, endianness endian) { value = byte_swap(value, endian); memcpy(LLVM_ASSUME_ALIGNED( @@ -116,7 +110,8 @@ using make_unsigned_t = std::make_unsigned_t; /// Read a value of a particular endianness from memory, for a location /// that starts at the given bit offset within the first byte. template -inline value_type readAtBitAlignment(const void *memory, uint64_t startBit) { +[[nodiscard]] inline value_type readAtBitAlignment(const void *memory, + uint64_t startBit) { assert(startBit < 8); if (startBit == 0) return read(memory); @@ -269,125 +264,164 @@ struct packed_endian_specific_integral { } // end namespace detail using ulittle16_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using ulittle32_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using ulittle64_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using little16_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using little32_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using little64_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using aligned_ulittle16_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using aligned_ulittle32_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using aligned_ulittle64_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using aligned_little16_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using aligned_little32_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using aligned_little64_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using ubig16_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using ubig32_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using ubig64_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using big16_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using big32_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using big64_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using aligned_ubig16_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using aligned_ubig32_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using aligned_ubig64_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using aligned_big16_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using aligned_big32_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using aligned_big64_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using unaligned_uint16_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using unaligned_uint32_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using unaligned_uint64_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using unaligned_int16_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using unaligned_int32_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; using unaligned_int64_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; template -using little_t = detail::packed_endian_specific_integral; +using little_t = + detail::packed_endian_specific_integral; template -using big_t = detail::packed_endian_specific_integral; +using big_t = detail::packed_endian_specific_integral; template using aligned_little_t = - detail::packed_endian_specific_integral; + detail::packed_endian_specific_integral; template -using aligned_big_t = detail::packed_endian_specific_integral; +using aligned_big_t = + detail::packed_endian_specific_integral; namespace endian { -template inline T read(const void *P, endianness E) { - return read(P, E); -} - -template inline T read(const void *P) { +template [[nodiscard]] inline T read(const void *P) { return *(const detail::packed_endian_specific_integral *)P; } -inline uint16_t read16(const void *P, endianness E) { +[[nodiscard]] inline uint16_t read16(const void *P, endianness E) { return read(P, E); } -inline uint32_t read32(const void *P, endianness E) { +[[nodiscard]] inline uint32_t read32(const void *P, endianness E) { return read(P, E); } -inline uint64_t read64(const void *P, endianness E) { +[[nodiscard]] inline uint64_t read64(const void *P, endianness E) { return read(P, E); } -template inline uint16_t read16(const void *P) { +template [[nodiscard]] inline uint16_t read16(const void *P) { return read(P); } -template inline uint32_t read32(const void *P) { +template [[nodiscard]] inline uint32_t read32(const void *P) { return read(P); } -template inline uint64_t read64(const void *P) { +template [[nodiscard]] inline uint64_t read64(const void *P) { return read(P); } -inline uint16_t read16le(const void *P) { return read16(P); } -inline uint32_t read32le(const void *P) { return read32(P); } -inline uint64_t read64le(const void *P) { return read64(P); } -inline uint16_t read16be(const void *P) { return read16(P); } -inline uint32_t read32be(const void *P) { return read32(P); } -inline uint64_t read64be(const void *P) { return read64(P); } - -template inline void write(void *P, T V, endianness E) { - write(P, V, E); +[[nodiscard]] inline uint16_t read16le(const void *P) { + return read16(P); +} +[[nodiscard]] inline uint32_t read32le(const void *P) { + return read32(P); +} +[[nodiscard]] inline uint64_t read64le(const void *P) { + return read64(P); +} +[[nodiscard]] inline uint16_t read16be(const void *P) { + return read16(P); +} +[[nodiscard]] inline uint32_t read32be(const void *P) { + return read32(P); +} +[[nodiscard]] inline uint64_t read64be(const void *P) { + return read64(P); } template inline void write(void *P, T V) { @@ -414,12 +448,24 @@ template inline void write64(void *P, uint64_t V) { write(P, V); } -inline void write16le(void *P, uint16_t V) { write16(P, V); } -inline void write32le(void *P, uint32_t V) { write32(P, V); } -inline void write64le(void *P, uint64_t V) { write64(P, V); } -inline void write16be(void *P, uint16_t V) { write16(P, V); } -inline void write32be(void *P, uint32_t V) { write32(P, V); } -inline void write64be(void *P, uint64_t V) { write64(P, V); } +inline void write16le(void *P, uint16_t V) { + write16(P, V); +} +inline void write32le(void *P, uint32_t V) { + write32(P, V); +} +inline void write64le(void *P, uint64_t V) { + write64(P, V); +} +inline void write16be(void *P, uint16_t V) { + write16(P, V); +} +inline void write32be(void *P, uint32_t V) { + write32(P, V); +} +inline void write64be(void *P, uint64_t V) { + write64(P, V); +} } // end namespace endian diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/FunctionExtras.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/FunctionExtras.h index 8c6d8472a2e..a0ae149fb36 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/FunctionExtras.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/FunctionExtras.h @@ -35,6 +35,7 @@ #include "wpi/PointerIntPair.h" #include "wpi/PointerUnion.h" #include "wpi/STLForwardCompat.h" +#include "wpi/Compiler.h" #include "wpi/MemAlloc.h" #include "wpi/type_traits.h" #include @@ -324,8 +325,10 @@ template class UniqueFunctionBase { // Clear the old callback and inline flag to get back to as-if-null. RHS.CallbackAndInlineFlag = {}; -#ifndef NDEBUG - // In debug builds, we also scribble across the rest of the storage. +#if !defined(NDEBUG) && !LLVM_ADDRESS_SANITIZER_BUILD + // In debug builds without ASan, we also scribble across the rest of the + // storage. Scribbling under AddressSanitizer (ASan) is disabled to prevent + // overwriting poisoned objects (e.g., annotated short strings). memset(RHS.getInlineStorage(), 0xAD, InlineStorageSize); #endif } diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Hashing.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Hashing.h index bdb439c2172..a232488ef56 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Hashing.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Hashing.h @@ -682,12 +682,26 @@ template hash_code hash_value(const std::optional &arg) { template <> struct DenseMapInfo { static inline hash_code getEmptyKey() { return hash_code(-1); } static inline hash_code getTombstoneKey() { return hash_code(-2); } - static unsigned getHashValue(hash_code val) { return val; } + static unsigned getHashValue(hash_code val) { + return static_cast(size_t(val)); + } static bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; } }; } // namespace wpi +/// Implement std::hash so that hash_code can be used in STL containers. +namespace std { + +template<> +struct hash { + size_t operator()(wpi::hash_code const& Val) const { + return Val; + } +}; + +} // namespace std; + #ifdef _WIN32 #pragma warning(pop) #endif diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MapVector.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MapVector.h index ce6fe78702f..9d845af31bc 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MapVector.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MapVector.h @@ -114,29 +114,50 @@ class MapVector { return Pos == Map.end()? ValueT() : Vector[Pos->second].second; } - std::pair insert(const std::pair &KV) { - std::pair Pair = std::make_pair(KV.first, 0); - std::pair Result = Map.insert(Pair); - auto &I = Result.first->second; - if (Result.second) { - Vector.push_back(std::make_pair(KV.first, KV.second)); - I = Vector.size() - 1; + template + std::pair try_emplace(const KeyT &Key, Ts &&...Args) { + auto [It, Inserted] = Map.insert(std::make_pair(Key, 0)); + if (Inserted) { + It->second = Vector.size(); + Vector.emplace_back(std::piecewise_construct, std::forward_as_tuple(Key), + std::forward_as_tuple(std::forward(Args)...)); return std::make_pair(std::prev(end()), true); } - return std::make_pair(begin() + I, false); + return std::make_pair(begin() + It->second, false); } - - std::pair insert(std::pair &&KV) { - // Copy KV.first into the map, then move it into the vector. - std::pair Pair = std::make_pair(KV.first, 0); - std::pair Result = Map.insert(Pair); - auto &I = Result.first->second; - if (Result.second) { - Vector.push_back(std::move(KV)); - I = Vector.size() - 1; + template + std::pair try_emplace(KeyT &&Key, Ts &&...Args) { + auto [It, Inserted] = Map.insert(std::make_pair(Key, 0)); + if (Inserted) { + It->second = Vector.size(); + Vector.emplace_back(std::piecewise_construct, + std::forward_as_tuple(std::move(Key)), + std::forward_as_tuple(std::forward(Args)...)); return std::make_pair(std::prev(end()), true); } - return std::make_pair(begin() + I, false); + return std::make_pair(begin() + It->second, false); + } + + std::pair insert(const std::pair &KV) { + return try_emplace(KV.first, KV.second); + } + std::pair insert(std::pair &&KV) { + return try_emplace(std::move(KV.first), std::move(KV.second)); + } + + template + std::pair insert_or_assign(const KeyT &Key, V &&Val) { + auto Ret = try_emplace(Key, std::forward(Val)); + if (!Ret.second) + Ret.first->second = std::forward(Val); + return Ret; + } + template + std::pair insert_or_assign(KeyT &&Key, V &&Val) { + auto Ret = try_emplace(std::move(Key), std::forward(Val)); + if (!Ret.second) + Ret.first->second = std::forward(Val); + return Ret; } bool contains(const KeyT &Key) const { return Map.find(Key) != Map.end(); } diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MathExtras.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MathExtras.h index ed3b2b1efc3..4ccea3e3f8e 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MathExtras.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MathExtras.h @@ -333,9 +333,9 @@ constexpr inline uint64_t NextPowerOf2(uint64_t A) { /// Returns the power of two which is greater than or equal to the given value. /// Essentially, it is a ceil operation across the domain of powers of two. inline uint64_t PowerOf2Ceil(uint64_t A) { - if (!A) + if (!A || A > UINT64_MAX / 2) return 0; - return NextPowerOf2(A - 1); + return UINT64_C(1) << Log2_64_Ceil(A); } /// Returns the next integer (mod 2**64) that is greater than or equal to diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MemAlloc.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MemAlloc.h index 32909ff38da..cf5354589ea 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MemAlloc.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MemAlloc.h @@ -72,7 +72,7 @@ LLVM_ATTRIBUTE_RETURNS_NONNULL inline void *safe_realloc(void *Ptr, size_t Sz) { /// Allocate a buffer of memory with the given size and alignment. /// -/// When the compiler supports aligned operator new, this will use it to to +/// When the compiler supports aligned operator new, this will use it to /// handle even over-aligned allocations. /// /// However, this doesn't make any attempt to leverage the fancier techniques diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/STLForwardCompat.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/STLForwardCompat.h index 02cf826989b..d39f8ca65ff 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/STLForwardCompat.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/STLForwardCompat.h @@ -60,6 +60,13 @@ auto transformOptional(std::optional &&O, const Function &F) return std::nullopt; } +/// Returns underlying integer value of an enum. Backport of C++23 +/// std::to_underlying. +template +[[nodiscard]] constexpr std::underlying_type_t to_underlying(Enum E) { + return static_cast>(E); +} + } // namespace wpi #endif // WPIUTIL_WPI_STLFORWARDCOMPAT_H diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallString.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallString.h index 4a53feee59a..35d0a4a8189 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallString.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallString.h @@ -88,9 +88,10 @@ class SmallString : public SmallVector { /// @name String Comparison /// @{ - /// Compare two strings; the result is -1, 0, or 1 if this string is - /// lexicographically less than, equal to, or greater than the \p RHS. - int compare(std::string_view RHS) const { + /// compare - Compare two strings; the result is negative, zero, or positive + /// if this string is lexicographically less than, equal to, or greater than + /// the \p RHS. + [[nodiscard]] int compare(std::string_view RHS) const { return str().compare(RHS); } @@ -102,7 +103,7 @@ class SmallString : public SmallVector { /// /// \return - The index of the first occurrence of \p C, or npos if not /// found. - size_t find(char C, size_t From = 0) const { + [[nodiscard]] size_t find(char C, size_t From = 0) const { return str().find(C, From); } @@ -110,7 +111,7 @@ class SmallString : public SmallVector { /// /// \returns The index of the first occurrence of \p Str, or npos if not /// found. - size_t find(std::string_view Str, size_t From = 0) const { + [[nodiscard]] size_t find(std::string_view Str, size_t From = 0) const { return str().find(Str, From); } @@ -118,7 +119,8 @@ class SmallString : public SmallVector { /// /// \returns The index of the last occurrence of \p C, or npos if not /// found. - size_t rfind(char C, size_t From = std::string_view::npos) const { + [[nodiscard]] size_t rfind(char C, + size_t From = std::string_view::npos) const { return str().rfind(C, From); } @@ -126,13 +128,13 @@ class SmallString : public SmallVector { /// /// \returns The index of the last occurrence of \p Str, or npos if not /// found. - size_t rfind(std::string_view Str) const { + [[nodiscard]] size_t rfind(std::string_view Str) const { return str().rfind(Str); } /// Find the first character in the string that is \p C, or npos if not /// found. Same as find. - size_t find_first_of(char C, size_t From = 0) const { + [[nodiscard]] size_t find_first_of(char C, size_t From = 0) const { return str().find_first_of(C, From); } @@ -140,13 +142,14 @@ class SmallString : public SmallVector { /// not found. /// /// Complexity: O(size() + Chars.size()) - size_t find_first_of(std::string_view Chars, size_t From = 0) const { + [[nodiscard]] size_t find_first_of(std::string_view Chars, + size_t From = 0) const { return str().find_first_of(Chars, From); } /// Find the first character in the string that is not \p C or npos if not /// found. - size_t find_first_not_of(char C, size_t From = 0) const { + [[nodiscard]] size_t find_first_not_of(char C, size_t From = 0) const { return str().find_first_not_of(C, From); } @@ -154,13 +157,15 @@ class SmallString : public SmallVector { /// \p Chars, or npos if not found. /// /// Complexity: O(size() + Chars.size()) - size_t find_first_not_of(std::string_view Chars, size_t From = 0) const { + [[nodiscard]] size_t find_first_not_of(std::string_view Chars, + size_t From = 0) const { return str().find_first_not_of(Chars, From); } /// Find the last character in the string that is \p C, or npos if not /// found. - size_t find_last_of(char C, size_t From = std::string_view::npos) const { + [[nodiscard]] size_t find_last_of( + char C, size_t From = std::string_view::npos) const { return str().find_last_of(C, From); } @@ -168,7 +173,7 @@ class SmallString : public SmallVector { /// found. /// /// Complexity: O(size() + Chars.size()) - size_t find_last_of( + [[nodiscard]] size_t find_last_of( std::string_view Chars, size_t From = std::string_view::npos) const { return str().find_last_of(Chars, From); } @@ -178,7 +183,9 @@ class SmallString : public SmallVector { // Extra methods. /// Explicit conversion to std::string_view. - std::string_view str() const { return std::string_view(this->begin(), this->size()); } + [[nodiscard]] std::string_view str() const { + return std::string_view(this->begin(), this->size()); + } // TODO: Make this const, if it's safe... const char* c_str() { diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallVector.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallVector.h index 3b4b890db54..3e69345e40b 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallVector.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallVector.h @@ -61,7 +61,7 @@ class SmallVectorBase { void *BeginX; unsigned Size = 0, Capacity; - /// The maximum value of the Size_T used. + /// The maximum value of the unsigned used. static constexpr size_t SizeTypeMax() { return (std::numeric_limits::max)(); } @@ -106,9 +106,19 @@ class SmallVectorBase { /// /// This does not construct or destroy any elements in the vector. void set_size(size_t N) { - assert(N <= capacity()); + assert(N <= capacity()); // implies no overflow in assignment Size = static_cast(N); } + + /// Set the array data pointer to \p Begin and capacity to \p N. + /// + /// This does not construct or destroy any elements in the vector. + // This does not clean up any existing allocation. + void set_allocation_range(void *Begin, size_t N) { + assert(N <= SizeTypeMax()); + BeginX = Begin; + Capacity = static_cast(N); + } }; /// Figure out the offset of the first element. @@ -469,8 +479,7 @@ void SmallVectorTemplateBase::takeAllocationForGrow( if (!this->isSmall()) free(this->begin()); - this->BeginX = NewElts; - this->Capacity = static_cast(NewCapacity); + this->set_allocation_range(NewElts, NewCapacity); } /// SmallVectorTemplateBase - This is where we put @@ -603,9 +612,6 @@ class SmallVectorImpl : public SmallVectorTemplateBase { RHS.resetToSmall(); } -public: - SmallVectorImpl(const SmallVectorImpl &) = delete; - ~SmallVectorImpl() { // Subclass has already destructed this vector's elements. // If this wasn't grown from the inline copy, deallocate the old space. @@ -613,6 +619,9 @@ class SmallVectorImpl : public SmallVectorTemplateBase { free(this->begin()); } +public: + SmallVectorImpl(const SmallVectorImpl &) = delete; + void clear() { this->destroy_range(this->begin(), this->end()); this->Size = 0; diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SwapByteOrder.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SwapByteOrder.h index af7fcf9eb88..c908401c4e2 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SwapByteOrder.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SwapByteOrder.h @@ -14,45 +14,17 @@ #ifndef WPIUTIL_WPI_SWAPBYTEORDER_H #define WPIUTIL_WPI_SWAPBYTEORDER_H +#include "wpi/STLForwardCompat.h" #include "wpi/bit.h" -#include #include #include -#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) || \ - defined(__Fuchsia__) || defined(__EMSCRIPTEN__) -#include -#elif defined(_AIX) -#include -#elif defined(__sun) -/* Solaris provides _BIG_ENDIAN/_LITTLE_ENDIAN selector in sys/types.h */ -#include -#define BIG_ENDIAN 4321 -#define LITTLE_ENDIAN 1234 -#if defined(_BIG_ENDIAN) -#define BYTE_ORDER BIG_ENDIAN -#else -#define BYTE_ORDER LITTLE_ENDIAN -#endif -#elif defined(__MVS__) -#define BIG_ENDIAN 4321 -#define LITTLE_ENDIAN 1234 -#define BYTE_ORDER BIG_ENDIAN -#else -#if !defined(BYTE_ORDER) && !defined(_WIN32) -#include -#endif -#endif - namespace wpi { namespace sys { -#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN -constexpr bool IsBigEndianHost = true; -#else -constexpr bool IsBigEndianHost = false; -#endif +constexpr bool IsBigEndianHost = + wpi::endianness::native == wpi::endianness::big; static const bool IsLittleEndianHost = !IsBigEndianHost; @@ -73,29 +45,16 @@ inline unsigned long long getSwappedBytes(unsigned long long C) { return wpi::by inline signed long long getSwappedBytes( signed long long C) { return wpi::byteswap(C); } inline float getSwappedBytes(float C) { - union { - uint32_t i; - float f; - } in, out; - in.f = C; - out.i = wpi::byteswap(in.i); - return out.f; + return wpi::bit_cast(wpi::byteswap(wpi::bit_cast(C))); } inline double getSwappedBytes(double C) { - union { - uint64_t i; - double d; - } in, out; - in.d = C; - out.i = wpi::byteswap(in.i); - return out.d; + return wpi::bit_cast(wpi::byteswap(wpi::bit_cast(C))); } template inline std::enable_if_t, T> getSwappedBytes(T C) { - return static_cast( - wpi::byteswap(static_cast>(C))); + return static_cast(wpi::byteswap(wpi::to_underlying(C))); } template diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/VersionTuple.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/VersionTuple.h index 02f24dd7c45..3c6d5d0122c 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/VersionTuple.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/VersionTuple.h @@ -16,14 +16,12 @@ #include "wpi/DenseMapInfo.h" #include "wpi/Hashing.h" -#include "wpi/Endian.h" #include #include #include namespace wpi { -template -class HashBuilderImpl; +template class HashBuilder; class raw_ostream; /// Represents a version number in the form major[.minor[.subminor[.build]]]. diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/bit.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/bit.h index fce6d85201f..8fa495af379 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/bit.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/bit.h @@ -29,6 +29,16 @@ namespace wpi { +enum class endianness { + big, + little, +#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN + native = big +#else + native = little +#endif +}; + // This implementation of bit_cast is different from the C++20 one in two ways: // - It isn't constexpr because that requires compiler support. // - It requires trivially-constructible To, to avoid UB in the implementation. diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/iterator_range.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/iterator_range.h index afb73436365..3e0b56b7043 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/iterator_range.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/iterator_range.h @@ -43,8 +43,8 @@ class iterator_range { IteratorT begin_iterator, end_iterator; public: -#if __GNUC__ == 7 - // Be careful no to break gcc-7 on the mlir target. +#if __GNUC__ == 7 || (__GNUC__ == 8 && __GNUC_MINOR__ < 4) + // Be careful no to break gcc-7 and gcc-8 < 8.4 on the mlir target. // See https://github.com/llvm/llvm-project/issues/63843 template #else @@ -53,8 +53,7 @@ class iterator_range { detail::IterOfRange, IteratorT>::value> * = nullptr> #endif iterator_range(Container &&c) - : begin_iterator(adl_begin(std::forward(c))), - end_iterator(adl_end(std::forward(c))) { + : begin_iterator(adl_begin(c)), end_iterator(adl_end(c)) { } iterator_range(IteratorT begin_iterator, IteratorT end_iterator) : begin_iterator(std::move(begin_iterator)), diff --git a/wpiutil/src/test/native/cpp/llvm/Chrono.cpp b/wpiutil/src/test/native/cpp/llvm/Chrono.cpp index 5fe3e65af34..1a8369ff98b 100644 --- a/wpiutil/src/test/native/cpp/llvm/Chrono.cpp +++ b/wpiutil/src/test/native/cpp/llvm/Chrono.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "wpi/Chrono.h" -#include "wpi/SmallVector.h" #include "gtest/gtest.h" using namespace wpi; diff --git a/wpiutil/src/test/native/cpp/llvm/EndianTest.cpp b/wpiutil/src/test/native/cpp/llvm/EndianTest.cpp index 89edec49904..a8234552f79 100644 --- a/wpiutil/src/test/native/cpp/llvm/EndianTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/EndianTest.cpp @@ -22,12 +22,17 @@ TEST(Endian, Read) { unsigned char bigval[] = {0x00, 0x01, 0x02, 0x03, 0x04}; unsigned char littleval[] = {0x00, 0x04, 0x03, 0x02, 0x01}; int32_t BigAsHost = 0x00010203; - EXPECT_EQ(BigAsHost, (endian::read(bigval))); + EXPECT_EQ(BigAsHost, + (endian::read(bigval))); int32_t LittleAsHost = 0x02030400; - EXPECT_EQ(LittleAsHost,(endian::read(littleval))); + EXPECT_EQ( + LittleAsHost, + (endian::read(littleval))); - EXPECT_EQ((endian::read(bigval + 1)), - (endian::read(littleval + 1))); + EXPECT_EQ( + (endian::read(bigval + 1)), + (endian::read(littleval + + 1))); } TEST(Endian, ReadBitAligned) { @@ -35,35 +40,43 @@ TEST(Endian, ReadBitAligned) { unsigned char littleval[] = {0x3f, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff}; unsigned char bigval[] = {0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xc0}; EXPECT_EQ( - (endian::readAtBitAlignment(&littleval[0], 6)), + (endian::readAtBitAlignment( + &littleval[0], 6)), 0x0); - EXPECT_EQ((endian::readAtBitAlignment(&bigval[0], 6)), + EXPECT_EQ((endian::readAtBitAlignment( + &bigval[0], 6)), 0x0); // Test to make sure that signed right shift of 0xf0000000 is masked // properly. unsigned char littleval2[] = {0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00}; unsigned char bigval2[] = {0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; EXPECT_EQ( - (endian::readAtBitAlignment(&littleval2[0], 4)), + (endian::readAtBitAlignment( + &littleval2[0], 4)), 0x0f000000); - EXPECT_EQ((endian::readAtBitAlignment(&bigval2[0], 4)), + EXPECT_EQ((endian::readAtBitAlignment( + &bigval2[0], 4)), 0x0f000000); // Test to make sure left shift of start bit doesn't overflow. EXPECT_EQ( - (endian::readAtBitAlignment(&littleval2[0], 1)), + (endian::readAtBitAlignment( + &littleval2[0], 1)), 0x78000000); - EXPECT_EQ((endian::readAtBitAlignment(&bigval2[0], 1)), + EXPECT_EQ((endian::readAtBitAlignment( + &bigval2[0], 1)), 0x78000000); // Test to make sure 64-bit int doesn't overflow. unsigned char littleval3[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; unsigned char bigval3[] = {0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - EXPECT_EQ((endian::readAtBitAlignment( - &littleval3[0], 4)), - 0x0f00000000000000); EXPECT_EQ( - (endian::readAtBitAlignment(&bigval3[0], 4)), + (endian::readAtBitAlignment( + &littleval3[0], 4)), + 0x0f00000000000000); + EXPECT_EQ( + (endian::readAtBitAlignment( + &bigval3[0], 4)), 0x0f00000000000000); } @@ -71,8 +84,8 @@ TEST(Endian, WriteBitAligned) { // This test ensures that signed right shift of 0xffffaa is masked // properly. unsigned char bigval[8] = {0x00}; - endian::writeAtBitAlignment(bigval, (int)0xffffaaaa, - 4); + endian::writeAtBitAlignment( + bigval, (int)0xffffaaaa, 4); EXPECT_EQ(bigval[0], 0xff); EXPECT_EQ(bigval[1], 0xfa); EXPECT_EQ(bigval[2], 0xaa); @@ -83,8 +96,8 @@ TEST(Endian, WriteBitAligned) { EXPECT_EQ(bigval[7], 0x0f); unsigned char littleval[8] = {0x00}; - endian::writeAtBitAlignment(littleval, - (int)0xffffaaaa, 4); + endian::writeAtBitAlignment( + littleval, (int)0xffffaaaa, 4); EXPECT_EQ(littleval[0], 0xa0); EXPECT_EQ(littleval[1], 0xaa); EXPECT_EQ(littleval[2], 0xfa); @@ -97,8 +110,8 @@ TEST(Endian, WriteBitAligned) { // This test makes sure 1<<31 doesn't overflow. // Test to make sure left shift of start bit doesn't overflow. unsigned char bigval2[8] = {0x00}; - endian::writeAtBitAlignment(bigval2, (int)0xffffffff, - 1); + endian::writeAtBitAlignment( + bigval2, (int)0xffffffff, 1); EXPECT_EQ(bigval2[0], 0xff); EXPECT_EQ(bigval2[1], 0xff); EXPECT_EQ(bigval2[2], 0xff); @@ -109,8 +122,8 @@ TEST(Endian, WriteBitAligned) { EXPECT_EQ(bigval2[7], 0x01); unsigned char littleval2[8] = {0x00}; - endian::writeAtBitAlignment(littleval2, - (int)0xffffffff, 1); + endian::writeAtBitAlignment( + littleval2, (int)0xffffffff, 1); EXPECT_EQ(littleval2[0], 0xfe); EXPECT_EQ(littleval2[1], 0xff); EXPECT_EQ(littleval2[2], 0xff); @@ -122,7 +135,7 @@ TEST(Endian, WriteBitAligned) { // Test to make sure 64-bit int doesn't overflow. unsigned char bigval64[16] = {0x00}; - endian::writeAtBitAlignment( + endian::writeAtBitAlignment( bigval64, (int64_t)0xffffffffffffffff, 1); EXPECT_EQ(bigval64[0], 0xff); EXPECT_EQ(bigval64[1], 0xff); @@ -142,7 +155,7 @@ TEST(Endian, WriteBitAligned) { EXPECT_EQ(bigval64[15], 0x01); unsigned char littleval64[16] = {0x00}; - endian::writeAtBitAlignment( + endian::writeAtBitAlignment( littleval64, (int64_t)0xffffffffffffffff, 1); EXPECT_EQ(littleval64[0], 0xfe); EXPECT_EQ(littleval64[1], 0xff); @@ -164,23 +177,26 @@ TEST(Endian, WriteBitAligned) { TEST(Endian, Write) { unsigned char data[5]; - endian::write(data, -1362446643); + endian::write(data, -1362446643); EXPECT_EQ(data[0], 0xAE); EXPECT_EQ(data[1], 0xCA); EXPECT_EQ(data[2], 0xB6); EXPECT_EQ(data[3], 0xCD); - endian::write(data + 1, -1362446643); + endian::write(data + 1, + -1362446643); EXPECT_EQ(data[1], 0xAE); EXPECT_EQ(data[2], 0xCA); EXPECT_EQ(data[3], 0xB6); EXPECT_EQ(data[4], 0xCD); - endian::write(data, -1362446643); + endian::write(data, + -1362446643); EXPECT_EQ(data[0], 0xCD); EXPECT_EQ(data[1], 0xB6); EXPECT_EQ(data[2], 0xCA); EXPECT_EQ(data[3], 0xAE); - endian::write(data + 1, -1362446643); + endian::write(data + 1, + -1362446643); EXPECT_EQ(data[1], 0xCD); EXPECT_EQ(data[2], 0xB6); EXPECT_EQ(data[3], 0xCA); diff --git a/wpiutil/src/test/native/cpp/llvm/MapVectorTest.cpp b/wpiutil/src/test/native/cpp/llvm/MapVectorTest.cpp index 4bfa6b2040c..c3507dd4146 100644 --- a/wpiutil/src/test/native/cpp/llvm/MapVectorTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/MapVectorTest.cpp @@ -16,10 +16,38 @@ #include "wpi/MapVector.h" #include "wpi/iterator_range.h" #include "gtest/gtest.h" +#include #include using namespace wpi; +namespace { +struct CountCopyAndMove { + CountCopyAndMove() = default; + CountCopyAndMove(const CountCopyAndMove &) { copy = 1; } + CountCopyAndMove(CountCopyAndMove &&) { move = 1; } + void operator=(const CountCopyAndMove &) { ++copy; } + void operator=(CountCopyAndMove &&) { ++move; } + int copy = 0; + int move = 0; +}; + +struct A : CountCopyAndMove { + A(int v) : v(v) {} + int v; +}; +} // namespace + +namespace wpi { +template <> struct DenseMapInfo { + static inline A getEmptyKey() { return 0x7fffffff; } + static inline A getTombstoneKey() { return -0x7fffffff - 1; } + static unsigned getHashValue(const A &Val) { return (unsigned)(Val.v * 37U); } + static bool isEqual(const A &LHS, const A &RHS) { return LHS.v == RHS.v; } +}; +} // namespace wpi + +namespace { TEST(MapVectorTest, swap) { MapVector MV1, MV2; std::pair::iterator, bool> R; @@ -86,6 +114,87 @@ TEST(MapVectorTest, insert_pop) { EXPECT_EQ(MV[4], 7); } +TEST(MapVectorTest, try_emplace) { + struct AAndU { + A a; + std::unique_ptr b; + AAndU(A a, std::unique_ptr b) : a(a), b(std::move(b)) {} + }; + MapVector mv; + + A zero(0); + auto try0 = mv.try_emplace(zero, zero, nullptr); + EXPECT_TRUE(try0.second); + EXPECT_EQ(0, try0.first->second.a.v); + EXPECT_EQ(1, try0.first->second.a.copy); + EXPECT_EQ(0, try0.first->second.a.move); + + auto try1 = mv.try_emplace(zero, zero, nullptr); + EXPECT_FALSE(try1.second); + EXPECT_EQ(0, try1.first->second.a.v); + EXPECT_EQ(1, try1.first->second.a.copy); + EXPECT_EQ(0, try1.first->second.a.move); + + EXPECT_EQ(try0.first, try1.first); + EXPECT_EQ(1, try1.first->first.copy); + EXPECT_EQ(0, try1.first->first.move); + + A two(2); + auto try2 = mv.try_emplace(2, std::move(two), std::make_unique(2)); + EXPECT_TRUE(try2.second); + EXPECT_EQ(2, try2.first->second.a.v); + EXPECT_EQ(0, try2.first->second.a.move); + + std::unique_ptr p(new int(3)); + auto try3 = mv.try_emplace(std::move(two), 3, std::move(p)); + EXPECT_FALSE(try3.second); + EXPECT_EQ(2, try3.first->second.a.v); + EXPECT_EQ(1, try3.first->second.a.copy); + EXPECT_EQ(0, try3.first->second.a.move); + + EXPECT_EQ(try2.first, try3.first); + EXPECT_EQ(0, try3.first->first.copy); + EXPECT_EQ(1, try3.first->first.move); + EXPECT_NE(nullptr, p); +} + +TEST(MapVectorTest, insert_or_assign) { + MapVector mv; + + A zero(0); + auto try0 = mv.insert_or_assign(zero, zero); + EXPECT_TRUE(try0.second); + EXPECT_EQ(0, try0.first->second.v); + EXPECT_EQ(1, try0.first->second.copy); + EXPECT_EQ(0, try0.first->second.move); + + auto try1 = mv.insert_or_assign(zero, zero); + EXPECT_FALSE(try1.second); + EXPECT_EQ(0, try1.first->second.v); + EXPECT_EQ(2, try1.first->second.copy); + EXPECT_EQ(0, try1.first->second.move); + + EXPECT_EQ(try0.first, try1.first); + EXPECT_EQ(1, try1.first->first.copy); + EXPECT_EQ(0, try1.first->first.move); + + A two(2); + auto try2 = mv.try_emplace(2, std::move(two)); + EXPECT_TRUE(try2.second); + EXPECT_EQ(2, try2.first->second.v); + EXPECT_EQ(1, try2.first->second.move); + + auto try3 = mv.insert_or_assign(std::move(two), 3); + EXPECT_FALSE(try3.second); + EXPECT_EQ(3, try3.first->second.v); + EXPECT_EQ(0, try3.first->second.copy); + EXPECT_EQ(2, try3.first->second.move); + + EXPECT_EQ(try2.first, try3.first); + EXPECT_EQ(0, try3.first->first.copy); + EXPECT_EQ(1, try3.first->first.move); +} + TEST(MapVectorTest, erase) { MapVector MV; @@ -430,3 +539,4 @@ TEST(SmallMapVectorLargeTest, iteration_test) { count--; } } +} // namespace diff --git a/wpiutil/src/test/native/cpp/llvm/STLForwardCompatTest.cpp b/wpiutil/src/test/native/cpp/llvm/STLForwardCompatTest.cpp index 153305bb214..0f0af563cfe 100644 --- a/wpiutil/src/test/native/cpp/llvm/STLForwardCompatTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/STLForwardCompatTest.cpp @@ -119,4 +119,21 @@ TEST(TransformTest, MoveTransformLlvm) { EXPECT_EQ(0u, MoveOnly::Destructions); } +TEST(TransformTest, ToUnderlying) { + enum E { A1 = 0, B1 = -1 }; + static_assert(wpi::to_underlying(A1) == 0); + static_assert(wpi::to_underlying(B1) == -1); + + enum E2 : unsigned char { A2 = 0, B2 }; + static_assert( + std::is_same_v); + static_assert(wpi::to_underlying(A2) == 0); + static_assert(wpi::to_underlying(B2) == 1); + + enum class E3 { A3 = -1, B3 }; + static_assert(std::is_same_v); + static_assert(wpi::to_underlying(E3::A3) == -1); + static_assert(wpi::to_underlying(E3::B3) == 0); +} + } // namespace