diff --git a/cscore/src/main/native/linux/UsbUtil.cpp b/cscore/src/main/native/linux/UsbUtil.cpp index 7d22054c83..fc6cbd2971 100644 --- a/cscore/src/main/native/linux/UsbUtil.cpp +++ b/cscore/src/main/native/linux/UsbUtil.cpp @@ -58,13 +58,13 @@ static std::string GetUsbNameFromFile(int vendor, int product) { // next vendor, but didn't match product? if (line[0] != '\t') { buf += "Unknown"; - return buf; + return std::string{buf}; } // look for product if (wpi::starts_with(wpi::substr(line, 1), productStr)) { buf += wpi::trim(wpi::substr(line, 6)); - return buf; + return std::string{buf}; } } } diff --git a/cscore/src/main/native/windows/UsbCameraImpl.cpp b/cscore/src/main/native/windows/UsbCameraImpl.cpp index efabf15f1c..0216919123 100644 --- a/cscore/src/main/native/windows/UsbCameraImpl.cpp +++ b/cscore/src/main/native/windows/UsbCameraImpl.cpp @@ -1098,13 +1098,13 @@ std::vector EnumerateUsbCameras(CS_Status* status) { sizeof(buf) / sizeof(WCHAR), &characters); storage.clear(); wpi::sys::windows::UTF16ToUTF8(buf, characters, storage); - info.name = storage.string(); + info.name = std::string{storage}; ppDevices[i]->GetString( MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, buf, sizeof(buf) / sizeof(WCHAR), &characters); storage.clear(); wpi::sys::windows::UTF16ToUTF8(buf, characters, storage); - info.path = storage.string(); + info.path = std::string{storage}; // Try to parse path from symbolic link ParseVidAndPid(info.path, &info.productId, &info.vendorId); diff --git a/upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch b/upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch index aa82e795aa..5d6916ddc2 100644 --- a/upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch +++ b/upstream_utils/llvm_patches/0001-Fix-spelling-language-errors.patch @@ -1,31 +1,17 @@ -From e5c61a18376a34b94bf1761f30e017a741e52b0b Mon Sep 17 00:00:00 2001 +From 3d09b3d7b78ffc037a32725cc4002976b908d965 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 20:50:26 -0400 -Subject: [PATCH 01/27] Fix spelling / language errors +Subject: [PATCH 01/28] Fix spelling/language errors --- - llvm/include/llvm/Support/Chrono.h | 2 +- llvm/include/llvm/Support/ErrorHandling.h | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) + 1 file changed, 1 insertion(+), 1 deletion(-) -diff --git a/llvm/include/llvm/Support/Chrono.h b/llvm/include/llvm/Support/Chrono.h -index f478549a7e4e..004519a883fd 100644 ---- a/llvm/include/llvm/Support/Chrono.h -+++ b/llvm/include/llvm/Support/Chrono.h -@@ -22,7 +22,7 @@ class raw_ostream; - namespace sys { - - /// A time point on the system clock. This is provided for two reasons: --/// - to insulate us agains subtle differences in behavoir to differences in -+/// - to insulate us against subtle differences in behavior to differences in - /// system clock precision (which is implementation-defined and differs between - /// platforms). - /// - to shorten the type name diff --git a/llvm/include/llvm/Support/ErrorHandling.h b/llvm/include/llvm/Support/ErrorHandling.h -index 0ec0242d569d..dd85a5892e01 100644 +index f980510d3..6791df6be 100644 --- a/llvm/include/llvm/Support/ErrorHandling.h +++ b/llvm/include/llvm/Support/ErrorHandling.h -@@ -45,7 +45,7 @@ class StringRef; +@@ -44,7 +44,7 @@ namespace llvm { void install_fatal_error_handler(fatal_error_handler_t handler, void *user_data = nullptr); diff --git a/upstream_utils/llvm_patches/0002-Remove-StringRef-ArrayRef-and-Optional.patch b/upstream_utils/llvm_patches/0002-Remove-StringRef-ArrayRef-and-Optional.patch index cbeea9971d..eb5b759120 100644 --- a/upstream_utils/llvm_patches/0002-Remove-StringRef-ArrayRef-and-Optional.patch +++ b/upstream_utils/llvm_patches/0002-Remove-StringRef-ArrayRef-and-Optional.patch @@ -1,48 +1,64 @@ -From 8799ad77758b93e742394699451009a8d3fc7bb7 Mon Sep 17 00:00:00 2001 +From afca62cd2f1616bcf2e648dc121a057d59168424 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:09:18 -0400 -Subject: [PATCH 02/27] Remove StringRef, ArrayRef, and Optional +Subject: [PATCH 02/28] Remove StringRef, ArrayRef, and Optional --- - llvm/include/llvm/ADT/SmallSet.h | 12 +-- - llvm/include/llvm/ADT/SmallString.h | 76 +++++++++---------- - llvm/include/llvm/ADT/StringMap.h | 34 ++++----- - llvm/include/llvm/ADT/StringMapEntry.h | 23 +++--- + llvm/include/llvm/ADT/PointerUnion.h | 1 - + llvm/include/llvm/ADT/SmallSet.h | 13 ++-- + llvm/include/llvm/ADT/SmallString.h | 77 ++++++++++--------- + llvm/include/llvm/ADT/StringMap.h | 34 ++++---- + llvm/include/llvm/ADT/StringMapEntry.h | 25 +++--- llvm/include/llvm/Support/Chrono.h | 10 +-- llvm/include/llvm/Support/Compiler.h | 2 +- - llvm/include/llvm/Support/ConvertUTF.h | 25 +++--- + llvm/include/llvm/Support/ConvertUTF.h | 28 ++++--- llvm/include/llvm/Support/DJB.h | 6 +- - llvm/include/llvm/Support/ErrorHandling.h | 7 +- + llvm/include/llvm/Support/ErrorHandling.h | 9 +-- .../llvm/Support/SmallVectorMemoryBuffer.h | 6 +- llvm/include/llvm/Support/VersionTuple.h | 20 ++--- - .../llvm/Support/Windows/WindowsSupport.h | 2 - - llvm/include/llvm/Support/raw_ostream.h | 48 +++++++----- + .../llvm/Support/Windows/WindowsSupport.h | 4 +- + llvm/include/llvm/Support/raw_ostream.h | 51 ++++++------ llvm/lib/Support/ConvertUTFWrapper.cpp | 32 ++++---- - llvm/lib/Support/ErrorHandling.cpp | 15 ++-- + llvm/lib/Support/ErrorHandling.cpp | 13 ++-- + llvm/lib/Support/SmallVector.cpp | 5 +- llvm/lib/Support/StringMap.cpp | 12 +-- - llvm/lib/Support/raw_ostream.cpp | 22 +++--- + llvm/lib/Support/raw_ostream.cpp | 25 +++--- llvm/unittests/ADT/DenseMapTest.cpp | 25 ------ 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 | 20 +---- - llvm/unittests/ADT/StringMapTest.cpp | 27 ++++--- + llvm/unittests/ADT/StringMapTest.cpp | 32 ++++---- llvm/unittests/Support/ConvertUTFTest.cpp | 37 +++++---- - 24 files changed, 237 insertions(+), 288 deletions(-) + 27 files changed, 248 insertions(+), 304 deletions(-) +diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h +index 04d566bbc..1d4cc747c 100644 +--- a/llvm/include/llvm/ADT/PointerUnion.h ++++ b/llvm/include/llvm/ADT/PointerUnion.h +@@ -17,7 +17,6 @@ + + #include "llvm/ADT/DenseMapInfo.h" + #include "llvm/ADT/PointerIntPair.h" +-#include "llvm/ADT/STLExtras.h" + #include "llvm/Support/PointerLikeTypeTraits.h" + #include + #include diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h -index 0600e528ee69..e4c209c5f2a9 100644 +index 0eed85449..bfe93e997 100644 --- a/llvm/include/llvm/ADT/SmallSet.h +++ b/llvm/include/llvm/ADT/SmallSet.h -@@ -13,7 +13,6 @@ +@@ -14,15 +14,14 @@ #ifndef LLVM_ADT_SMALLSET_H #define LLVM_ADT_SMALLSET_H -#include "llvm/ADT/None.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" +-#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/iterator.h" -@@ -21,6 +20,7 @@ + #include "llvm/Support/Compiler.h" #include "llvm/Support/type_traits.h" #include #include @@ -50,7 +66,7 @@ index 0600e528ee69..e4c209c5f2a9 100644 #include #include #include -@@ -177,16 +177,16 @@ public: +@@ -179,16 +178,16 @@ public: /// concept. // FIXME: Add iterators that abstract over the small and large form, and then // return those here. @@ -71,7 +87,7 @@ index 0600e528ee69..e4c209c5f2a9 100644 } // Otherwise, grow from vector to set. -@@ -195,7 +195,7 @@ public: +@@ -197,7 +196,7 @@ public: Vector.pop_back(); } Set.insert(V); @@ -81,20 +97,21 @@ index 0600e528ee69..e4c209c5f2a9 100644 template diff --git a/llvm/include/llvm/ADT/SmallString.h b/llvm/include/llvm/ADT/SmallString.h -index 56b0639b98cc..8112741dd01d 100644 +index 874968f0a..50cbdade4 100644 --- a/llvm/include/llvm/ADT/SmallString.h +++ b/llvm/include/llvm/ADT/SmallString.h -@@ -14,8 +14,8 @@ +@@ -15,8 +15,9 @@ #define LLVM_ADT_SMALLSTRING_H #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" #include ++#include +#include namespace llvm { -@@ -27,11 +27,11 @@ public: +@@ -28,11 +29,11 @@ public: /// Default ctor - Initialize to empty. SmallString() = default; @@ -110,7 +127,7 @@ index 56b0639b98cc..8112741dd01d 100644 : SmallVector() { this->append(Refs); } -@@ -46,13 +46,13 @@ public: +@@ -47,13 +48,13 @@ public: using SmallVector::assign; @@ -128,7 +145,7 @@ index 56b0639b98cc..8112741dd01d 100644 this->clear(); append(Refs); } -@@ -63,19 +63,19 @@ public: +@@ -64,19 +65,19 @@ public: using SmallVector::append; @@ -143,18 +160,18 @@ index 56b0639b98cc..8112741dd01d 100644 - void append(std::initializer_list Refs) { + /// Append from a list of std::string_views. + void append(std::initializer_list Refs) { - size_t SizeNeeded = this->size(); + size_t CurrentSize = this->size(); + size_t SizeNeeded = CurrentSize; - for (const StringRef &Ref : Refs) + for (const std::string_view &Ref : Refs) SizeNeeded += Ref.size(); - this->reserve(SizeNeeded); - auto CurEnd = this->end(); + this->resize_for_overwrite(SizeNeeded); - for (const StringRef &Ref : Refs) { + for (const std::string_view &Ref : Refs) { - this->uninitialized_copy(Ref.begin(), Ref.end(), CurEnd); - CurEnd += Ref.size(); + std::copy(Ref.begin(), Ref.end(), this->begin() + CurrentSize); + CurrentSize += Ref.size(); } -@@ -88,29 +88,29 @@ public: +@@ -89,29 +90,29 @@ public: /// Check for string equality. This is more efficient than compare() when /// the relative ordering of inequal strings isn't needed. @@ -189,7 +206,7 @@ index 56b0639b98cc..8112741dd01d 100644 return str().compare_numeric(RHS); } -@@ -119,12 +119,12 @@ public: +@@ -120,12 +121,12 @@ public: /// @{ /// startswith - Check if this string starts with the given \p Prefix. @@ -204,7 +221,7 @@ index 56b0639b98cc..8112741dd01d 100644 return str().endswith(Suffix); } -@@ -144,7 +144,7 @@ public: +@@ -145,7 +146,7 @@ public: /// /// \returns The index of the first occurrence of \p Str, or npos if not /// found. @@ -213,7 +230,7 @@ index 56b0639b98cc..8112741dd01d 100644 return str().find(Str, From); } -@@ -152,7 +152,7 @@ public: +@@ -153,7 +154,7 @@ public: /// /// \returns The index of the last occurrence of \p C, or npos if not /// found. @@ -222,7 +239,7 @@ index 56b0639b98cc..8112741dd01d 100644 return str().rfind(C, From); } -@@ -160,7 +160,7 @@ public: +@@ -161,7 +162,7 @@ public: /// /// \returns The index of the last occurrence of \p Str, or npos if not /// found. @@ -231,7 +248,7 @@ index 56b0639b98cc..8112741dd01d 100644 return str().rfind(Str); } -@@ -174,7 +174,7 @@ public: +@@ -175,7 +176,7 @@ public: /// not found. /// /// Complexity: O(size() + Chars.size()) @@ -240,7 +257,7 @@ index 56b0639b98cc..8112741dd01d 100644 return str().find_first_of(Chars, From); } -@@ -188,13 +188,13 @@ public: +@@ -189,13 +190,13 @@ public: /// \p Chars, or npos if not found. /// /// Complexity: O(size() + Chars.size()) @@ -256,7 +273,7 @@ index 56b0639b98cc..8112741dd01d 100644 return str().find_last_of(C, From); } -@@ -203,7 +203,7 @@ public: +@@ -204,7 +205,7 @@ public: /// /// Complexity: O(size() + Chars.size()) size_t find_last_of( @@ -265,7 +282,7 @@ index 56b0639b98cc..8112741dd01d 100644 return str().find_last_of(Chars, From); } -@@ -218,7 +218,7 @@ public: +@@ -219,7 +220,7 @@ public: /// Return the number of non-overlapped occurrences of \p Str in the /// string. @@ -274,7 +291,7 @@ index 56b0639b98cc..8112741dd01d 100644 return str().count(Str); } -@@ -235,7 +235,7 @@ public: +@@ -236,7 +237,7 @@ 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. @@ -283,7 +300,7 @@ index 56b0639b98cc..8112741dd01d 100644 return str().substr(Start, N); } -@@ -249,14 +249,14 @@ public: +@@ -250,14 +251,14 @@ 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. @@ -301,7 +318,7 @@ index 56b0639b98cc..8112741dd01d 100644 // TODO: Make this const, if it's safe... const char* c_str() { -@@ -265,20 +265,20 @@ public: +@@ -266,20 +267,20 @@ public: return this->data(); } @@ -327,10 +344,10 @@ index 56b0639b98cc..8112741dd01d 100644 return *this; } diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h -index a82afc9a817c..5f463cfef943 100644 +index 23248093c..8747cdb35 100644 --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h -@@ -58,12 +58,12 @@ protected: +@@ -60,12 +60,12 @@ protected: /// specified bucket will be non-null. Otherwise, it will be null. In either /// case, the FullHashValue field of the bucket will be set to the hash value /// of the string. @@ -345,7 +362,7 @@ index a82afc9a817c..5f463cfef943 100644 /// RemoveKey - Remove the specified StringMapEntry from the table, but do not /// delete it. This aborts if the value isn't in the table. -@@ -71,7 +71,7 @@ protected: +@@ -73,7 +73,7 @@ protected: /// RemoveKey - Remove the StringMapEntry for the specified key from the /// table, returning it. If the key is not in the table, this returns null. @@ -354,15 +371,15 @@ index a82afc9a817c..5f463cfef943 100644 /// Allocate the table with the specified number of buckets and otherwise /// setup the map as empty. -@@ -124,7 +124,7 @@ public: +@@ -126,7 +126,7 @@ public: : StringMapImpl(InitialSize, static_cast(sizeof(MapEntryTy))), Allocator(A) {} - StringMap(std::initializer_list> List) + StringMap(std::initializer_list> List) : StringMapImpl(List.size(), static_cast(sizeof(MapEntryTy))) { - for (const auto &P : List) { - insert(P); + insert(List); + } @@ -215,14 +215,14 @@ public: StringMapKeyIterator(end())); } @@ -402,7 +419,7 @@ index a82afc9a817c..5f463cfef943 100644 template size_type count(const StringMapEntry &MapEntry) const { -@@ -293,14 +293,14 @@ public: +@@ -293,7 +293,7 @@ public: /// isn't already in the map. The bool component of the returned pair is true /// if and only if the insertion takes place, and the iterator component of /// the pair points to the element with key equivalent to the key of the pair. @@ -411,6 +428,15 @@ index a82afc9a817c..5f463cfef943 100644 return try_emplace(KV.first, std::move(KV.second)); } +@@ -308,14 +308,14 @@ public: + /// Inserts elements from initializer list ilist. If multiple elements in + /// the range have keys that compare equivalent, it is unspecified which + /// element is inserted +- void insert(std::initializer_list> List) { ++ void insert(std::initializer_list> List) { + insert(List.begin(), List.end()); + } + /// Inserts an element or assigns to the current element if the key already /// exists. The return type is the same as try_emplace. template @@ -419,7 +445,7 @@ index a82afc9a817c..5f463cfef943 100644 auto Ret = try_emplace(Key, std::forward(Val)); if (!Ret.second) Ret.first->second = std::forward(Val); -@@ -312,7 +312,7 @@ public: +@@ -327,7 +327,7 @@ public: /// if and only if the insertion takes place, and the iterator component of /// the pair points to the element with key equivalent to the key of the pair. template @@ -428,7 +454,7 @@ index a82afc9a817c..5f463cfef943 100644 unsigned BucketNo = LookupBucketFor(Key); StringMapEntryBase *&Bucket = TheTable[BucketNo]; if (Bucket && Bucket != getTombstoneVal()) -@@ -358,7 +358,7 @@ public: +@@ -373,7 +373,7 @@ public: V.Destroy(Allocator); } @@ -437,7 +463,7 @@ index a82afc9a817c..5f463cfef943 100644 iterator I = find(Key); if (I == end()) return false; -@@ -455,23 +455,23 @@ template +@@ -470,17 +470,17 @@ template class StringMapKeyIterator : public iterator_adaptor_base, StringMapConstIterator, @@ -453,33 +479,28 @@ index a82afc9a817c..5f463cfef943 100644 explicit StringMapKeyIterator(StringMapConstIterator Iter) : base(std::move(Iter)) {} -- StringRef &operator*() { -+ std::string_view &operator*() { - Key = this->wrapped()->getKey(); - return Key; - } - - private: -- StringRef Key; -+ std::string_view Key; +- StringRef operator*() const { return this->wrapped()->getKey(); } ++ std::string_view operator*() const { return this->wrapped()->getKey(); } }; } // end namespace llvm diff --git a/llvm/include/llvm/ADT/StringMapEntry.h b/llvm/include/llvm/ADT/StringMapEntry.h -index 8bfad5540230..93e13b5bb16c 100644 +index 6e13c8618..39976a02b 100644 --- a/llvm/include/llvm/ADT/StringMapEntry.h +++ b/llvm/include/llvm/ADT/StringMapEntry.h -@@ -15,7 +15,8 @@ +@@ -16,9 +16,8 @@ #ifndef LLVM_ADT_STRINGMAPENTRY_H #define LLVM_ADT_STRINGMAPENTRY_H +-#include "llvm/ADT/None.h" -#include "llvm/ADT/StringRef.h" +-#include "llvm/ADT/STLFunctionalExtras.h" +#include +#include namespace llvm { -@@ -34,13 +35,13 @@ protected: +@@ -37,13 +36,13 @@ protected: /// type-erase the allocator and put it in a source file. template static void *allocateWithKey(size_t EntrySize, size_t EntryAlign, @@ -495,7 +516,7 @@ index 8bfad5540230..93e13b5bb16c 100644 AllocatorTy &Allocator) { size_t KeyLength = Key.size(); -@@ -82,13 +83,13 @@ public: +@@ -85,13 +84,13 @@ public: void setValue(const ValueTy &V) { second = V; } }; @@ -512,7 +533,7 @@ index 8bfad5540230..93e13b5bb16c 100644 }; /// StringMapEntry - This is used to represent one value that is inserted into -@@ -99,8 +100,8 @@ class StringMapEntry final : public StringMapEntryStorage { +@@ -102,8 +101,8 @@ class StringMapEntry final : public StringMapEntryStorage { public: using StringMapEntryStorage::StringMapEntryStorage; @@ -523,7 +544,7 @@ index 8bfad5540230..93e13b5bb16c 100644 } /// getKeyData - Return the start of the string data that is the key for this -@@ -110,14 +111,14 @@ public: +@@ -113,14 +112,14 @@ public: return reinterpret_cast(this + 1); } @@ -542,10 +563,10 @@ index 8bfad5540230..93e13b5bb16c 100644 return new (StringMapEntryBase::allocateWithKey( sizeof(StringMapEntry), alignof(StringMapEntry), key, allocator)) diff --git a/llvm/include/llvm/Support/Chrono.h b/llvm/include/llvm/Support/Chrono.h -index 004519a883fd..2c2869de49b6 100644 +index 9c2bd45d2..a7dea19d9 100644 --- a/llvm/include/llvm/Support/Chrono.h +++ b/llvm/include/llvm/Support/Chrono.h -@@ -69,7 +69,7 @@ raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP); +@@ -70,7 +70,7 @@ raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP); template <> struct format_provider> { static void format(const sys::TimePoint<> &TP, llvm::raw_ostream &OS, @@ -554,7 +575,7 @@ index 004519a883fd..2c2869de49b6 100644 }; namespace detail { -@@ -121,7 +121,7 @@ private: +@@ -122,7 +122,7 @@ private: return duration_cast>(D).count(); } @@ -563,7 +584,7 @@ index 004519a883fd..2c2869de49b6 100644 const Dur &D) { using namespace std::chrono; if (Style.consume_front("ns")) -@@ -139,7 +139,7 @@ private: +@@ -140,7 +140,7 @@ private: return {D.count(), detail::unit::value}; } @@ -572,7 +593,7 @@ index 004519a883fd..2c2869de49b6 100644 if (Style.empty()) return true; if (Style.consume_front("-")) -@@ -151,9 +151,9 @@ private: +@@ -152,9 +152,9 @@ private: } public: @@ -585,10 +606,10 @@ index 004519a883fd..2c2869de49b6 100644 bool show_unit = consumeShowUnit(Style); diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h -index 57052b596edb..f4d6612fe074 100644 +index 80b2dfaec..f5d726ec8 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h -@@ -299,7 +299,7 @@ +@@ -312,7 +312,7 @@ #endif /// LLVM_GSL_POINTER - Apply this to non-owning classes like @@ -598,10 +619,10 @@ index 57052b596edb..f4d6612fe074 100644 #define LLVM_GSL_POINTER [[gsl::Pointer]] #else diff --git a/llvm/include/llvm/Support/ConvertUTF.h b/llvm/include/llvm/Support/ConvertUTF.h -index 1add185330fa..7f1527f51cdf 100644 +index 374cdb907..7f1527f51 100644 --- a/llvm/include/llvm/Support/ConvertUTF.h +++ b/llvm/include/llvm/Support/ConvertUTF.h -@@ -89,8 +89,11 @@ +@@ -89,12 +89,12 @@ #ifndef LLVM_SUPPORT_CONVERTUTF_H #define LLVM_SUPPORT_CONVERTUTF_H @@ -609,11 +630,15 @@ index 1add185330fa..7f1527f51cdf 100644 + #include #include +- +-#if defined(_WIN32) +#include #include +-#endif // Wrap everything in namespace llvm so that programs can link with llvm and -@@ -180,12 +183,10 @@ unsigned getNumBytesForUTF8(UTF8 firstByte); + // their own version of the unicode libraries. +@@ -183,12 +183,10 @@ unsigned getNumBytesForUTF8(UTF8 firstByte); /*************************************************************************/ /* Below are LLVM-specific wrappers of the functions above. */ @@ -627,7 +652,7 @@ index 1add185330fa..7f1527f51cdf 100644 * WideCharWidth. The converted data is written to ResultPtr, which needs to * point to at least WideCharWidth * (Source.Size() + 1) bytes. On success, * ResultPtr will point one after the end of the copied string. On failure, -@@ -193,14 +194,14 @@ class StringRef; +@@ -196,14 +194,14 @@ class StringRef; * the first character which could not be converted. * \return true on success. */ @@ -645,7 +670,7 @@ index 1add185330fa..7f1527f51cdf 100644 /** * Converts a UTF-8 C-string to a std::wstring. -@@ -258,7 +259,7 @@ inline ConversionResult convertUTF8Sequence(const UTF8 **source, +@@ -261,7 +259,7 @@ inline ConversionResult convertUTF8Sequence(const UTF8 **source, * Returns true if a blob of text starts with a UTF-16 big or little endian byte * order mark. */ @@ -654,7 +679,7 @@ index 1add185330fa..7f1527f51cdf 100644 /** * Converts a stream of raw bytes assumed to be UTF16 into a UTF8 std::string. -@@ -267,7 +268,7 @@ bool hasUTF16ByteOrderMark(ArrayRef SrcBytes); +@@ -270,7 +268,7 @@ bool hasUTF16ByteOrderMark(ArrayRef SrcBytes); * \param [out] Out Converted UTF-8 is stored here on success. * \returns true on success */ @@ -663,7 +688,7 @@ index 1add185330fa..7f1527f51cdf 100644 /** * Converts a UTF16 string into a UTF8 std::string. -@@ -276,22 +277,22 @@ bool convertUTF16ToUTF8String(ArrayRef SrcBytes, std::string &Out); +@@ -279,22 +277,22 @@ bool convertUTF16ToUTF8String(ArrayRef SrcBytes, std::string &Out); * \param [out] Out Converted UTF-8 is stored here on success. * \returns true on success */ @@ -691,7 +716,7 @@ index 1add185330fa..7f1527f51cdf 100644 SmallVectorImpl &utf8); /// Convert from UTF16 to the current code page used in the system diff --git a/llvm/include/llvm/Support/DJB.h b/llvm/include/llvm/Support/DJB.h -index 8a04a324a5dc..8737cd144c37 100644 +index 8a04a324a..8737cd144 100644 --- a/llvm/include/llvm/Support/DJB.h +++ b/llvm/include/llvm/Support/DJB.h @@ -13,13 +13,13 @@ @@ -712,48 +737,53 @@ index 8a04a324a5dc..8737cd144c37 100644 return H; } diff --git a/llvm/include/llvm/Support/ErrorHandling.h b/llvm/include/llvm/Support/ErrorHandling.h -index dd85a5892e01..411c78a81b24 100644 +index 6791df6be..3f726d40b 100644 --- a/llvm/include/llvm/Support/ErrorHandling.h +++ b/llvm/include/llvm/Support/ErrorHandling.h -@@ -16,10 +16,9 @@ +@@ -15,10 +15,10 @@ + #define LLVM_SUPPORT_ERRORHANDLING_H #include "llvm/Support/Compiler.h" - #include ++#include +#include namespace llvm { --class StringRef; +- class StringRef; - class Twine; /// An error handler callback. typedef void (*fatal_error_handler_t)(void *user_data, -@@ -72,9 +71,7 @@ LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, - bool gen_crash_diag = true); - LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const std::string &reason, - bool gen_crash_diag = true); --LLVM_ATTRIBUTE_NORETURN void report_fatal_error(StringRef reason, -- bool gen_crash_diag = true); --LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const Twine &reason, -+LLVM_ATTRIBUTE_NORETURN void report_fatal_error(std::string_view reason, - bool gen_crash_diag = true); +@@ -67,12 +67,11 @@ namespace llvm { + /// standard error, followed by a newline. + /// After the error handler is called this function will call abort(), it + /// does not return. +-/// NOTE: The std::string variant was removed to avoid a dependency. + [[noreturn]] void report_fatal_error(const char *reason, + bool gen_crash_diag = true); +-[[noreturn]] void report_fatal_error(StringRef reason, ++[[noreturn]] void report_fatal_error(const std::string &reason, + bool gen_crash_diag = true); +-[[noreturn]] void report_fatal_error(const Twine &reason, ++[[noreturn]] void report_fatal_error(std::string_view reason, + bool gen_crash_diag = true); /// Installs a new bad alloc error handler that should be used whenever a diff --git a/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h b/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h -index 9aa4e9aec266..924ed77510fe 100644 +index f7f2d4e54..b5e321b5f 100644 --- a/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h +++ b/llvm/include/llvm/Support/SmallVectorMemoryBuffer.h -@@ -42,8 +42,8 @@ public: - } +@@ -35,8 +35,8 @@ public: + RequiresNullTerminator) {} - /// Construct a named SmallVectorMemoryBuffer from the given -- /// SmallVector r-value and StringRef. -- SmallVectorMemoryBuffer(SmallVectorImpl &&SV, StringRef Name) -+ /// SmallVector r-value and std::string_view. -+ SmallVectorMemoryBuffer(SmallVectorImpl &&SV, std::string_view Name) + /// Construct a named SmallVectorMemoryBuffer from the given SmallVector +- /// r-value and StringRef. +- SmallVectorMemoryBuffer(SmallVectorImpl &&SV, StringRef Name, ++ /// r-value and std::string_view. ++ SmallVectorMemoryBuffer(SmallVectorImpl &&SV, std::string_view Name, + bool RequiresNullTerminator = true) : SV(std::move(SV)), BufferName(std::string(Name)) { - init(this->SV.begin(), this->SV.end(), false); - } -@@ -51,7 +51,7 @@ public: + if (RequiresNullTerminator) { +@@ -49,7 +49,7 @@ public: // Key function. ~SmallVectorMemoryBuffer() override; @@ -763,14 +793,15 @@ index 9aa4e9aec266..924ed77510fe 100644 BufferKind getBufferKind() const override { return MemoryBuffer_Malloc; } diff --git a/llvm/include/llvm/Support/VersionTuple.h b/llvm/include/llvm/Support/VersionTuple.h -index a48ae0bf52bd..85f4f1a707c7 100644 +index 1a1072d22..3d6573bf5 100644 --- a/llvm/include/llvm/Support/VersionTuple.h +++ b/llvm/include/llvm/Support/VersionTuple.h -@@ -16,13 +16,12 @@ +@@ -16,14 +16,13 @@ #include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/Hashing.h" -#include "llvm/ADT/Optional.h" + #include "llvm/Support/HashBuilder.h" +#include #include #include @@ -781,7 +812,7 @@ index a48ae0bf52bd..85f4f1a707c7 100644 /// Represents a version number in the form major[.minor[.subminor[.build]]]. class VersionTuple { -@@ -69,23 +68,23 @@ public: +@@ -70,23 +69,23 @@ public: unsigned getMajor() const { return Major; } /// Retrieve the minor version number, if provided. @@ -811,7 +842,7 @@ index a48ae0bf52bd..85f4f1a707c7 100644 return Build; } -@@ -166,11 +165,6 @@ public: +@@ -173,11 +172,6 @@ public: /// Retrieve a string representation of the version number. std::string getAsString() const; @@ -824,7 +855,7 @@ index a48ae0bf52bd..85f4f1a707c7 100644 /// Print a version number. diff --git a/llvm/include/llvm/Support/Windows/WindowsSupport.h b/llvm/include/llvm/Support/Windows/WindowsSupport.h -index a45eeaba4ad5..551bd199551e 100644 +index 917822678..180803fbd 100644 --- a/llvm/include/llvm/Support/Windows/WindowsSupport.h +++ b/llvm/include/llvm/Support/Windows/WindowsSupport.h @@ -35,8 +35,6 @@ @@ -836,21 +867,31 @@ index a45eeaba4ad5..551bd199551e 100644 #include "llvm/Config/llvm-config.h" // Get build system configuration settings #include "llvm/Support/Allocator.h" #include "llvm/Support/Chrono.h" +@@ -71,7 +69,7 @@ bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix); + [[noreturn]] inline void ReportLastErrorFatal(const char *Msg) { + std::string ErrMsg; + MakeErrMsg(&ErrMsg, Msg); +- llvm::report_fatal_error(Twine(ErrMsg)); ++ llvm::report_fatal_error(ErrMsg); + } + + template diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index c669c2babad9..4f6ea873304f 100644 +index 58adb41cb..9a1dd7a60 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h -@@ -14,8 +14,7 @@ +@@ -14,9 +14,7 @@ #define LLVM_SUPPORT_RAW_OSTREAM_H #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" +-#include "llvm/ADT/Optional.h" -#include "llvm/Support/DataTypes.h" +#include "llvm/ADT/span.h" #include - #include #include -@@ -209,7 +208,22 @@ public: + #include +@@ -210,7 +208,22 @@ public: return *this; } @@ -874,7 +915,7 @@ index c669c2babad9..4f6ea873304f 100644 // Inline fast path, particularly for strings with a known length. size_t Size = Str.size(); -@@ -228,7 +242,7 @@ public: +@@ -229,7 +242,7 @@ public: // Inline fast path, particularly for constant strings where a sufficiently // smart compiler will simplify strlen. @@ -883,7 +924,7 @@ index c669c2babad9..4f6ea873304f 100644 } raw_ostream &operator<<(const std::string &Str) { -@@ -236,12 +250,6 @@ public: +@@ -237,12 +250,6 @@ public: return write(Str.data(), Str.length()); } @@ -896,7 +937,7 @@ index c669c2babad9..4f6ea873304f 100644 raw_ostream &operator<<(const SmallVectorImpl &Str) { return write(Str.data(), Str.size()); } -@@ -274,7 +282,7 @@ public: +@@ -275,7 +282,7 @@ public: /// Output \p Str, turning '\\', '\t', '\n', '"', and anything that doesn't /// satisfy llvm::isPrint into an escape sequence. @@ -905,7 +946,16 @@ index c669c2babad9..4f6ea873304f 100644 raw_ostream &write(unsigned char C); raw_ostream &write(const char *Ptr, size_t Size); -@@ -487,14 +495,14 @@ public: +@@ -446,7 +453,7 @@ class raw_fd_ostream : public raw_pwrite_stream { + bool ShouldClose; + bool SupportsSeeking = false; + bool IsRegularFile = false; +- mutable Optional HasColors; ++ mutable std::optional HasColors; + + #ifdef _WIN32 + /// True if this fd refers to a Windows console device. Mintty and other +@@ -491,14 +498,14 @@ public: /// As a special case, if Filename is "-", then the stream will use /// STDOUT_FILENO instead of opening a file. This will not close the stdout /// descriptor. @@ -925,7 +975,7 @@ index c669c2babad9..4f6ea873304f 100644 sys::fs::CreationDisposition Disp, sys::fs::FileAccess Access, sys::fs::OpenFlags Flags); -@@ -597,7 +605,7 @@ public: +@@ -603,7 +610,7 @@ public: /// Open the specified file for reading/writing/seeking. If an error occurs, /// information about the error is put into EC, and the stream should be /// immediately destroyed. @@ -934,7 +984,7 @@ index c669c2babad9..4f6ea873304f 100644 /// This reads the \p Size bytes into a buffer pointed by \p Ptr. /// -@@ -677,8 +685,8 @@ public: +@@ -683,8 +690,8 @@ public: void flush() = delete; @@ -945,7 +995,7 @@ index c669c2babad9..4f6ea873304f 100644 void reserveExtraSpace(uint64_t ExtraSize) override { OS.reserve(tell() + ExtraSize); -@@ -731,7 +739,7 @@ class Error; +@@ -741,7 +748,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. @@ -955,7 +1005,7 @@ index c669c2babad9..4f6ea873304f 100644 } // end namespace llvm diff --git a/llvm/lib/Support/ConvertUTFWrapper.cpp b/llvm/lib/Support/ConvertUTFWrapper.cpp -index d8d46712a593..090ebb0f5af8 100644 +index 392c4c489..396ab0c65 100644 --- a/llvm/lib/Support/ConvertUTFWrapper.cpp +++ b/llvm/lib/Support/ConvertUTFWrapper.cpp @@ -6,24 +6,24 @@ @@ -1070,7 +1120,7 @@ index d8d46712a593..090ebb0f5af8 100644 Result); } else if (sizeof(wchar_t) == 4) { diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp -index ce6344284f06..19d1fd77af12 100644 +index 80c0e0043..8ae8fb8b4 100644 --- a/llvm/lib/Support/ErrorHandling.cpp +++ b/llvm/lib/Support/ErrorHandling.cpp @@ -14,7 +14,6 @@ @@ -1081,7 +1131,7 @@ index ce6344284f06..19d1fd77af12 100644 #include "llvm/Config/config.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Errc.h" -@@ -80,18 +79,14 @@ void llvm::remove_fatal_error_handler() { +@@ -80,14 +79,14 @@ void llvm::remove_fatal_error_handler() { } void llvm::report_fatal_error(const char *Reason, bool GenCrashDiag) { @@ -1089,30 +1139,27 @@ index ce6344284f06..19d1fd77af12 100644 + report_fatal_error(std::string_view(Reason), GenCrashDiag); } - void llvm::report_fatal_error(const std::string &Reason, bool GenCrashDiag) { +-void llvm::report_fatal_error(StringRef Reason, bool GenCrashDiag) { - report_fatal_error(Twine(Reason), GenCrashDiag); ++void llvm::report_fatal_error(const std::string &Reason, bool GenCrashDiag) { + report_fatal_error(std::string_view(Reason), GenCrashDiag); } --void llvm::report_fatal_error(StringRef Reason, bool GenCrashDiag) { -- report_fatal_error(Twine(Reason), GenCrashDiag); --} -- -void llvm::report_fatal_error(const Twine &Reason, bool GenCrashDiag) { +void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) { llvm::fatal_error_handler_t handler = nullptr; void* handlerData = nullptr; { -@@ -105,7 +100,7 @@ void llvm::report_fatal_error(const Twine &Reason, bool GenCrashDiag) { +@@ -101,7 +100,7 @@ void llvm::report_fatal_error(const Twine &Reason, bool GenCrashDiag) { } if (handler) { -- handler(handlerData, Reason.str(), GenCrashDiag); -+ handler(handlerData, std::string{Reason}, GenCrashDiag); +- handler(handlerData, Reason.str().c_str(), GenCrashDiag); ++ handler(handlerData, std::string{Reason}.c_str(), GenCrashDiag); } else { // Blast the result out to stderr. We don't try hard to make sure this // succeeds (e.g. handling EINTR) and we can't use errs() here because -@@ -113,7 +108,7 @@ void llvm::report_fatal_error(const Twine &Reason, bool GenCrashDiag) { +@@ -109,7 +108,7 @@ void llvm::report_fatal_error(const Twine &Reason, bool GenCrashDiag) { SmallVector Buffer; raw_svector_ostream OS(Buffer); OS << "LLVM ERROR: " << Reason << "\n"; @@ -1121,11 +1168,41 @@ index ce6344284f06..19d1fd77af12 100644 ssize_t written = ::write(2, MessageStr.data(), MessageStr.size()); (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 8cafbc7fa..8bad715e4 100644 +--- a/llvm/lib/Support/SmallVector.cpp ++++ b/llvm/lib/Support/SmallVector.cpp +@@ -11,7 +11,6 @@ + //===----------------------------------------------------------------------===// + + #include "llvm/ADT/SmallVector.h" +-#include "llvm/ADT/Twine.h" + #include "llvm/Support/MemAlloc.h" + #include + #ifdef LLVM_ENABLE_EXCEPTIONS +@@ -67,7 +66,7 @@ static void report_size_overflow(size_t MinSize, size_t MaxSize) { + #ifdef LLVM_ENABLE_EXCEPTIONS + throw std::length_error(Reason); + #else +- report_fatal_error(Twine(Reason)); ++ report_fatal_error(Reason); + #endif + } + +@@ -81,7 +80,7 @@ static void report_at_maximum_capacity(size_t MaxSize) { + #ifdef LLVM_ENABLE_EXCEPTIONS + throw std::length_error(Reason); + #else +- report_fatal_error(Twine(Reason)); ++ report_fatal_error(Reason); + #endif + } + diff --git a/llvm/lib/Support/StringMap.cpp b/llvm/lib/Support/StringMap.cpp -index f65d3846623c..d9eeba619428 100644 +index 012c785b4..317f4ee43 100644 --- a/llvm/lib/Support/StringMap.cpp +++ b/llvm/lib/Support/StringMap.cpp -@@ -71,7 +71,7 @@ void StringMapImpl::init(unsigned InitSize) { +@@ -70,7 +70,7 @@ void StringMapImpl::init(unsigned InitSize) { /// specified bucket will be non-null. Otherwise, it will be null. In either /// case, the FullHashValue field of the bucket will be set to the hash value /// of the string. @@ -1134,7 +1211,7 @@ index f65d3846623c..d9eeba619428 100644 unsigned HTSize = NumBuckets; if (HTSize == 0) { // Hash table unallocated so far? init(16); -@@ -111,7 +111,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) { +@@ -110,7 +110,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) { // Do the comparison like this because Name isn't necessarily // null-terminated! char *ItemStr = (char *)BucketItem + ItemSize; @@ -1143,7 +1220,7 @@ index f65d3846623c..d9eeba619428 100644 // We found a match! return BucketNo; } -@@ -129,7 +129,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) { +@@ -128,7 +128,7 @@ unsigned StringMapImpl::LookupBucketFor(StringRef Name) { /// FindKey - Look up the bucket that contains the specified key. If it exists /// in the map, return the bucket number of the key. Otherwise return -1. /// This does not modify the map. @@ -1152,7 +1229,7 @@ index f65d3846623c..d9eeba619428 100644 unsigned HTSize = NumBuckets; if (HTSize == 0) return -1; // Really empty table? -@@ -155,7 +155,7 @@ int StringMapImpl::FindKey(StringRef Key) const { +@@ -154,7 +154,7 @@ int StringMapImpl::FindKey(StringRef Key) const { // Do the comparison like this because NameStart isn't necessarily // null-terminated! char *ItemStr = (char *)BucketItem + ItemSize; @@ -1161,7 +1238,7 @@ index f65d3846623c..d9eeba619428 100644 // We found a match! return BucketNo; } -@@ -174,14 +174,14 @@ int StringMapImpl::FindKey(StringRef Key) const { +@@ -173,14 +173,14 @@ int StringMapImpl::FindKey(StringRef Key) const { /// delete it. This aborts if the value isn't in the table. void StringMapImpl::RemoveKey(StringMapEntryBase *V) { const char *VStr = (char *)V + ItemSize; @@ -1179,10 +1256,10 @@ index f65d3846623c..d9eeba619428 100644 if (Bucket == -1) return nullptr; diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index d4e1c884d125..306cc981ed8f 100644 +index 69d4fe96b..e4c318eb8 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp -@@ -160,7 +160,7 @@ raw_ostream &raw_ostream::write_uuid(const uuid_t UUID) { +@@ -159,7 +159,7 @@ raw_ostream &raw_ostream::write_uuid(const uuid_t UUID) { } @@ -1191,7 +1268,7 @@ index d4e1c884d125..306cc981ed8f 100644 bool UseHexEscapes) { for (unsigned char c : Str) { switch (c) { -@@ -564,7 +564,7 @@ void format_object_base::home() { +@@ -563,7 +563,7 @@ void format_object_base::home() { // raw_fd_ostream //===----------------------------------------------------------------------===// @@ -1200,7 +1277,7 @@ index d4e1c884d125..306cc981ed8f 100644 sys::fs::CreationDisposition Disp, sys::fs::FileAccess Access, sys::fs::OpenFlags Flags) { assert((Access & sys::fs::FA_Write) && -@@ -590,25 +590,25 @@ static int getFD(StringRef Filename, std::error_code &EC, +@@ -589,25 +589,25 @@ static int getFD(StringRef Filename, std::error_code &EC, return FD; } @@ -1231,7 +1308,17 @@ index d4e1c884d125..306cc981ed8f 100644 sys::fs::CreationDisposition Disp, sys::fs::FileAccess Access, sys::fs::OpenFlags Flags) -@@ -698,7 +698,7 @@ raw_fd_ostream::~raw_fd_ostream() { +@@ -679,8 +679,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()) +- report_fatal_error(Twine("IO failure on output stream: ") + +- error().message(), ++ report_fatal_error("IO failure on output stream: " + error().message(), + /*gen_crash_diag=*/false); + } + +@@ -699,7 +698,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. @@ -1240,7 +1327,7 @@ index d4e1c884d125..306cc981ed8f 100644 SmallVector WideText; // Fall back to ::write if it wasn't valid UTF-8. -@@ -741,7 +741,7 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) { +@@ -742,7 +741,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) @@ -1249,7 +1336,7 @@ index d4e1c884d125..306cc981ed8f 100644 return; #endif -@@ -905,7 +905,7 @@ raw_ostream &llvm::nulls() { +@@ -906,7 +905,7 @@ raw_ostream &llvm::nulls() { // File Streams //===----------------------------------------------------------------------===// @@ -1258,7 +1345,7 @@ index d4e1c884d125..306cc981ed8f 100644 : raw_fd_ostream(getFD(Filename, EC, sys::fs::CD_CreateAlways, sys::fs::FA_Write | sys::fs::FA_Read, sys::fs::OF_None), -@@ -988,7 +988,7 @@ void buffer_ostream::anchor() {} +@@ -984,7 +983,7 @@ void buffer_ostream::anchor() {} void buffer_unique_ostream::anchor() {} @@ -1268,7 +1355,7 @@ index d4e1c884d125..306cc981ed8f 100644 if (OutputFileName == "-") return Write(outs()); diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp -index 352270adec0f..a122f1fe3bdf 100644 +index 4dd314c5c..e505b1907 100644 --- a/llvm/unittests/ADT/DenseMapTest.cpp +++ b/llvm/unittests/ADT/DenseMapTest.cpp @@ -481,31 +481,6 @@ TEST(DenseMapCustomTest, ReserveTest) { @@ -1304,7 +1391,7 @@ index 352270adec0f..a122f1fe3bdf 100644 // In the latter case, "a" == 0, "b" == 1 and so on. struct TestDenseMapInfo { diff --git a/llvm/unittests/ADT/FunctionExtrasTest.cpp b/llvm/unittests/ADT/FunctionExtrasTest.cpp -index 3c6f179c190f..899690b8aae8 100644 +index fc856a976..aff9d61c7 100644 --- a/llvm/unittests/ADT/FunctionExtrasTest.cpp +++ b/llvm/unittests/ADT/FunctionExtrasTest.cpp @@ -249,23 +249,23 @@ TEST(UniqueFunctionTest, Const) { @@ -1338,10 +1425,10 @@ index 3c6f179c190f..899690b8aae8 100644 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 d2cda3afdda0..3605bbdcdfe3 100644 +index bb19a5699..0634767a4 100644 --- a/llvm/unittests/ADT/HashingTest.cpp +++ b/llvm/unittests/ADT/HashingTest.cpp -@@ -276,7 +276,7 @@ TEST(HashingTest, HashCombineRangeGoldenTest) { +@@ -277,7 +277,7 @@ TEST(HashingTest, HashCombineRangeGoldenTest) { #endif }; for (unsigned i = 0; i < sizeof(golden_data)/sizeof(*golden_data); ++i) { @@ -1350,8 +1437,20 @@ index d2cda3afdda0..3605bbdcdfe3 100644 hash_code hash = hash_combine_range(str.begin(), str.end()); #if 0 // Enable this to generate paste-able text for the above structure. std::string member_str = "\"" + str.str() + "\","; +diff --git a/llvm/unittests/ADT/SmallPtrSetTest.cpp b/llvm/unittests/ADT/SmallPtrSetTest.cpp +index 414298c4e..6f3c94eed 100644 +--- a/llvm/unittests/ADT/SmallPtrSetTest.cpp ++++ b/llvm/unittests/ADT/SmallPtrSetTest.cpp +@@ -12,7 +12,6 @@ + + #include "llvm/ADT/SmallPtrSet.h" + #include "llvm/ADT/PointerIntPair.h" +-#include "llvm/ADT/STLExtras.h" + #include "llvm/Support/PointerLikeTypeTraits.h" + #include "gtest/gtest.h" + diff --git a/llvm/unittests/ADT/SmallStringTest.cpp b/llvm/unittests/ADT/SmallStringTest.cpp -index b207f582e919..bee3875d11c9 100644 +index b207f582e..bee3875d1 100644 --- a/llvm/unittests/ADT/SmallStringTest.cpp +++ b/llvm/unittests/ADT/SmallStringTest.cpp @@ -50,43 +50,43 @@ TEST_F(SmallStringTest, AssignRepeated) { @@ -1490,7 +1589,7 @@ index b207f582e919..bee3875d11c9 100644 theString = "hellx xello hell ello world foo bar hello"; EXPECT_EQ(36U, theString.find("hello")); diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp -index 06b98efe66ef..1914f38fac6c 100644 +index 3fbea5299..fe827546a 100644 --- a/llvm/unittests/ADT/SmallVectorTest.cpp +++ b/llvm/unittests/ADT/SmallVectorTest.cpp @@ -11,7 +11,7 @@ @@ -1502,7 +1601,7 @@ index 06b98efe66ef..1914f38fac6c 100644 #include "llvm/Support/Compiler.h" #include "gtest/gtest.h" #include -@@ -1044,24 +1044,6 @@ TEST(SmallVectorTest, DefaultInlinedElements) { +@@ -1070,24 +1070,6 @@ TEST(SmallVectorTest, DefaultInlinedElements) { EXPECT_EQ(NestedV[0][0][0], 42); } @@ -1528,18 +1627,19 @@ index 06b98efe66ef..1914f38fac6c 100644 class SmallVectorReferenceInvalidationTest : public SmallVectorTestBase { protected: diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp -index 98fbd6e1df5a..18beb3878067 100644 +index 817fec6c3..86907ab61 100644 --- a/llvm/unittests/ADT/StringMapTest.cpp +++ b/llvm/unittests/ADT/StringMapTest.cpp -@@ -7,7 +7,6 @@ +@@ -7,8 +7,6 @@ //===----------------------------------------------------------------------===// #include "llvm/ADT/StringMap.h" +-#include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/Twine.h" #include "llvm/Support/DataTypes.h" #include "gtest/gtest.h" #include -@@ -37,10 +36,10 @@ protected: +@@ -38,10 +36,10 @@ protected: // Lookup tests EXPECT_EQ(0u, testMap.count(testKey)); @@ -1552,7 +1652,7 @@ index 98fbd6e1df5a..18beb3878067 100644 testMap.end()); EXPECT_TRUE(testMap.find(testKeyStr) == testMap.end()); } -@@ -60,10 +59,10 @@ protected: +@@ -61,10 +59,10 @@ protected: // Lookup tests EXPECT_EQ(1u, testMap.count(testKey)); @@ -1565,7 +1665,7 @@ index 98fbd6e1df5a..18beb3878067 100644 testMap.begin()); EXPECT_TRUE(testMap.find(testKeyStr) == testMap.begin()); } -@@ -103,10 +102,10 @@ TEST_F(StringMapTest, ConstEmptyMapTest) { +@@ -104,10 +102,10 @@ TEST_F(StringMapTest, ConstEmptyMapTest) { // Lookup tests EXPECT_EQ(0u, constTestMap.count(testKey)); @@ -1578,7 +1678,7 @@ index 98fbd6e1df5a..18beb3878067 100644 constTestMap.end()); EXPECT_TRUE(constTestMap.find(testKeyStr) == constTestMap.end()); } -@@ -227,7 +226,7 @@ TEST_F(StringMapTest, StringMapEntryTest) { +@@ -235,7 +233,7 @@ TEST_F(StringMapTest, StringMapEntryTest) { MallocAllocator Allocator; StringMap::value_type *entry = StringMap::value_type::Create( @@ -1587,7 +1687,7 @@ index 98fbd6e1df5a..18beb3878067 100644 EXPECT_STREQ(testKey, entry->first().data()); EXPECT_EQ(1u, entry->second); entry->Destroy(Allocator); -@@ -238,7 +237,7 @@ TEST_F(StringMapTest, InsertTest) { +@@ -246,7 +244,7 @@ TEST_F(StringMapTest, InsertTest) { SCOPED_TRACE("InsertTest"); testMap.insert( StringMap::value_type::Create( @@ -1596,7 +1696,20 @@ index 98fbd6e1df5a..18beb3878067 100644 testMap.getAllocator(), 1u)); assertSingleItemMap(); } -@@ -311,7 +310,7 @@ TEST_F(StringMapTest, IterMapKeys) { +@@ -316,10 +314,10 @@ TEST_F(StringMapTest, IterMapKeysVector) { + Map["C"] = 3; + Map["D"] = 3; + +- std::vector Keys{Map.keys().begin(), Map.keys().end()}; ++ std::vector Keys{Map.keys().begin(), Map.keys().end()}; + llvm::sort(Keys); + +- std::vector Expected{{"A", "B", "C", "D"}}; ++ std::vector Expected{{"A", "B", "C", "D"}}; + EXPECT_EQ(Expected, Keys); + } + +@@ -333,7 +331,7 @@ TEST_F(StringMapTest, IterMapKeysSmallVector) { auto Keys = to_vector<4>(Map.keys()); llvm::sort(Keys); @@ -1605,7 +1718,7 @@ index 98fbd6e1df5a..18beb3878067 100644 EXPECT_EQ(Expected, Keys); } -@@ -353,13 +352,13 @@ private: +@@ -375,13 +373,13 @@ private: TEST_F(StringMapTest, MoveOnly) { StringMap t; t.insert(std::make_pair("Test", MoveOnly(42))); @@ -1621,7 +1734,7 @@ index 98fbd6e1df5a..18beb3878067 100644 MallocAllocator Allocator; StringMapEntry::Create(Key, Allocator, Immovable()) ->Destroy(Allocator); -@@ -534,7 +533,7 @@ TEST(StringMapCustomTest, InitialSizeTest) { +@@ -556,7 +554,7 @@ TEST(StringMapCustomTest, InitialSizeTest) { CountCtorCopyAndMove::Copy = 0; for (int i = 0; i < Size; ++i) Map.insert(std::pair( @@ -1630,7 +1743,7 @@ index 98fbd6e1df5a..18beb3878067 100644 std::forward_as_tuple(i))); // After the initial move, the map will move the Elts in the Entry. EXPECT_EQ((unsigned)Size * 2, CountCtorCopyAndMove::Move); -@@ -603,7 +602,7 @@ TEST(StringMapCustomTest, StringMapEntrySize) { +@@ -625,7 +623,7 @@ TEST(StringMapCustomTest, StringMapEntrySize) { else LargeValue = std::numeric_limits::max() + 1ULL; StringMapEntry LargeEntry(LargeValue); @@ -1640,7 +1753,7 @@ index 98fbd6e1df5a..18beb3878067 100644 // Test that the entry can hold at least max size_t. diff --git a/llvm/unittests/Support/ConvertUTFTest.cpp b/llvm/unittests/Support/ConvertUTFTest.cpp -index 7bda6ea28ad6..9c798437a12d 100644 +index 7bda6ea28..9c798437a 100644 --- a/llvm/unittests/Support/ConvertUTFTest.cpp +++ b/llvm/unittests/Support/ConvertUTFTest.cpp @@ -7,7 +7,6 @@ diff --git a/upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-windows-warning.patch b/upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch similarity index 84% rename from upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-windows-warning.patch rename to upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch index c16c047a7f..a67e326650 100644 --- a/upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-windows-warning.patch +++ b/upstream_utils/llvm_patches/0003-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch @@ -1,22 +1,21 @@ -From 48f55e6aa592d66f46f392330317e4efe0502faf Mon Sep 17 00:00:00 2001 +From 5fccde024bea117d90d215390f09c7d779195ea5 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:12:41 -0400 -Subject: [PATCH 03/27] Wrap std::min/max calls in parens, for windows warnings +Subject: [PATCH 03/28] Wrap std::min/max calls in parens, for Windows warnings --- llvm/include/llvm/ADT/DenseMap.h | 4 ++-- - llvm/include/llvm/ADT/DenseMapInfo.h | 2 +- llvm/include/llvm/ADT/SmallVector.h | 12 ++++++------ llvm/include/llvm/Support/ConvertUTF.h | 2 +- llvm/include/llvm/Support/MathExtras.h | 22 +++++++++++----------- llvm/lib/Support/SmallVector.cpp | 2 +- - 6 files changed, 22 insertions(+), 22 deletions(-) + 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h -index 595eabd0ffb4..588c39faea2f 100644 +index 7673b66ca..975c3b97e 100644 --- a/llvm/include/llvm/ADT/DenseMap.h +++ b/llvm/include/llvm/ADT/DenseMap.h -@@ -389,7 +389,7 @@ protected: +@@ -390,7 +390,7 @@ protected: return 0; // +1 is required because of the strict equality. // For example if NumEntries is 48, we need to return 401. @@ -25,7 +24,7 @@ index 595eabd0ffb4..588c39faea2f 100644 } void moveFromOldBuckets(BucketT *OldBucketsBegin, BucketT *OldBucketsEnd) { -@@ -825,7 +825,7 @@ public: +@@ -826,7 +826,7 @@ public: // Reduce the number of buckets. unsigned NewNumBuckets = 0; if (OldNumEntries) @@ -34,21 +33,8 @@ index 595eabd0ffb4..588c39faea2f 100644 if (NewNumBuckets == NumBuckets) { this->BaseT::initEmpty(); return; -diff --git a/llvm/include/llvm/ADT/DenseMapInfo.h b/llvm/include/llvm/ADT/DenseMapInfo.h -index d276acbfa6a6..0040ac36217e 100644 ---- a/llvm/include/llvm/ADT/DenseMapInfo.h -+++ b/llvm/include/llvm/ADT/DenseMapInfo.h -@@ -285,7 +285,7 @@ template struct DenseMapInfo> { - 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(val); } - static bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; } - }; - diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h -index b8a11030fc33..602fcc5b7a98 100644 +index a4a790323..8686f7bb5 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -49,12 +49,12 @@ protected: @@ -66,8 +52,8 @@ index b8a11030fc33..602fcc5b7a98 100644 /// 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 -@@ -83,7 +83,7 @@ public: - /// which will only be overwritten. +@@ -79,7 +79,7 @@ protected: + /// This does not construct or destroy any elements in the vector. void set_size(size_t N) { assert(N <= capacity()); - Size = N; @@ -75,7 +61,7 @@ index b8a11030fc33..602fcc5b7a98 100644 } }; -@@ -263,7 +263,7 @@ public: +@@ -259,7 +259,7 @@ public: size_type size_in_bytes() const { return size() * sizeof(T); } size_type max_size() const { @@ -84,7 +70,7 @@ index b8a11030fc33..602fcc5b7a98 100644 } size_t capacity_in_bytes() const { return capacity() * sizeof(T); } -@@ -448,7 +448,7 @@ void SmallVectorTemplateBase::takeAllocationForGrow( +@@ -444,7 +444,7 @@ void SmallVectorTemplateBase::takeAllocationForGrow( free(this->begin()); this->BeginX = NewElts; @@ -93,7 +79,7 @@ index b8a11030fc33..602fcc5b7a98 100644 } /// SmallVectorTemplateBase - This is where we put -@@ -674,7 +674,7 @@ public: +@@ -693,7 +693,7 @@ public: } // Assign over existing elements. @@ -103,7 +89,7 @@ index b8a11030fc33..602fcc5b7a98 100644 std::uninitialized_fill_n(this->end(), NumElts - this->size(), Elt); else if (NumElts < this->size()) diff --git a/llvm/include/llvm/Support/ConvertUTF.h b/llvm/include/llvm/Support/ConvertUTF.h -index 7f1527f51cdf..b085c8a179e8 100644 +index 7f1527f51..b085c8a17 100644 --- a/llvm/include/llvm/Support/ConvertUTF.h +++ b/llvm/include/llvm/Support/ConvertUTF.h @@ -112,7 +112,7 @@ namespace llvm { @@ -116,7 +102,7 @@ index 7f1527f51cdf..b085c8a179e8 100644 /* 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 753b1998c40c..db9fbc148ae3 100644 +index 753b1998c..db9fbc148 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -97,7 +97,7 @@ template struct TrailingZerosCounter { @@ -208,10 +194,10 @@ index 753b1998c40c..db9fbc148ae3 100644 } // End llvm namespace diff --git a/llvm/lib/Support/SmallVector.cpp b/llvm/lib/Support/SmallVector.cpp -index 0005f7840912..26901fe97d20 100644 +index 8bad715e4..a2b4899e1 100644 --- a/llvm/lib/Support/SmallVector.cpp +++ b/llvm/lib/Support/SmallVector.cpp -@@ -95,7 +95,7 @@ static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) { +@@ -104,7 +104,7 @@ static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) { // In theory 2*capacity can overflow if the capacity is 64 bit, but the // original capacity would never be large enough for this to be a problem. size_t NewCapacity = 2 * OldCapacity + 1; // Always grow. diff --git a/upstream_utils/llvm_patches/0004-Change-uniqe_function-storage-size.patch b/upstream_utils/llvm_patches/0004-Change-unique_function-storage-size.patch similarity index 80% rename from upstream_utils/llvm_patches/0004-Change-uniqe_function-storage-size.patch rename to upstream_utils/llvm_patches/0004-Change-unique_function-storage-size.patch index 79a405e45f..6e57262686 100644 --- a/upstream_utils/llvm_patches/0004-Change-uniqe_function-storage-size.patch +++ b/upstream_utils/llvm_patches/0004-Change-unique_function-storage-size.patch @@ -1,17 +1,17 @@ -From 1c61002f2933aedbcc64ff52de7f69666479e55a Mon Sep 17 00:00:00 2001 +From 376285281b6173ee3d6650d71148bc173e4a9f7a Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:13:55 -0400 -Subject: [PATCH 04/27] Change uniqe_function storage size +Subject: [PATCH 04/28] Change unique_function storage size --- llvm/include/llvm/ADT/FunctionExtras.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h -index e67ef7377c88..1a26cb702cae 100644 +index 5a37417dd..8a9d78f41 100644 --- a/llvm/include/llvm/ADT/FunctionExtras.h +++ b/llvm/include/llvm/ADT/FunctionExtras.h -@@ -72,7 +72,7 @@ using EnableIfCallable = +@@ -78,7 +78,7 @@ using EnableIfCallable = std::enable_if_t class UniqueFunctionBase { protected: @@ -20,7 +20,7 @@ index e67ef7377c88..1a26cb702cae 100644 template struct IsSizeLessThanThresholdT : std::false_type {}; -@@ -151,7 +151,7 @@ protected: +@@ -157,7 +157,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/0005-Threading-updates.patch b/upstream_utils/llvm_patches/0005-Threading-updates.patch index 808350f18d..1ccd217f99 100644 --- a/upstream_utils/llvm_patches/0005-Threading-updates.patch +++ b/upstream_utils/llvm_patches/0005-Threading-updates.patch @@ -1,7 +1,7 @@ -From 5ca3ff668002f9bf89c134aec9976526c61929da Mon Sep 17 00:00:00 2001 +From bc86b62f72cbb76a0911996f4b1c6ce476cd1fac Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:17:19 -0400 -Subject: [PATCH 05/27] Threading updates +Subject: [PATCH 05/28] Threading updates - Remove guards for threads and exception - Prefer scope gaurd over lock gaurd @@ -12,10 +12,10 @@ Subject: [PATCH 05/27] 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 f4d6612fe074..989d25bb03b9 100644 +index f5d726ec8..ede1cb172 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h -@@ -525,7 +525,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -540,7 +540,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 f4d6612fe074..989d25bb03b9 100644 #if __has_feature(cxx_thread_local) || defined(_MSC_VER) #define LLVM_THREAD_LOCAL thread_local #else -@@ -533,11 +532,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -548,11 +547,6 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); // we only need the restricted functionality that provides. #define LLVM_THREAD_LOCAL __thread #endif @@ -36,7 +36,7 @@ index f4d6612fe074..989d25bb03b9 100644 /// \macro LLVM_ENABLE_EXCEPTIONS /// Whether LLVM is built with exception support. diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp -index 19d1fd77af12..2403db9c80f1 100644 +index 8ae8fb8b4..89440b5ab 100644 --- a/llvm/lib/Support/ErrorHandling.cpp +++ b/llvm/lib/Support/ErrorHandling.cpp @@ -44,7 +44,6 @@ static void *ErrorHandlerUserData = nullptr; @@ -151,7 +151,7 @@ index 19d1fd77af12..2403db9c80f1 100644 void llvm::llvm_unreachable_internal(const char *msg, const char *file, unsigned line) { diff --git a/llvm/lib/Support/ManagedStatic.cpp b/llvm/lib/Support/ManagedStatic.cpp -index a6ae67066ea0..fc798b7ec1b7 100644 +index a6ae67066..fc798b7ec 100644 --- a/llvm/lib/Support/ManagedStatic.cpp +++ b/llvm/lib/Support/ManagedStatic.cpp @@ -12,23 +12,23 @@ diff --git a/upstream_utils/llvm_patches/0006-ifdef-guard-safety.patch b/upstream_utils/llvm_patches/0006-ifdef-guard-safety.patch index bdb74a5b0f..bcb4950d45 100644 --- a/upstream_utils/llvm_patches/0006-ifdef-guard-safety.patch +++ b/upstream_utils/llvm_patches/0006-ifdef-guard-safety.patch @@ -1,26 +1,26 @@ -From 20727a44aa8138cbda12065a6087390b4632b958 Mon Sep 17 00:00:00 2001 +From 008e921f77933f475174d74a6b70309c6fbe0771 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:28:13 -0400 -Subject: [PATCH 06/27] #ifdef guard safety +Subject: [PATCH 06/28] \#ifdef guard safety Prevents redefinition if someone is pulling in real LLVM, since the macros are in global namespace --- - llvm/include/llvm/Support/Compiler.h | 54 ++++++++++++++++++++++++++++ - 1 file changed, 54 insertions(+) + llvm/include/llvm/Support/Compiler.h | 50 ++++++++++++++++++++++++++++ + 1 file changed, 50 insertions(+) diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h -index 989d25bb03b9..14f95ae8cc52 100644 +index ede1cb172..8b8260b50 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h -@@ -80,6 +80,7 @@ - /// * 1916: VS2017, version 15.9 - /// * 1920: VS2019, version 16.0 - /// * 1921: VS2019, version 16.1 +@@ -86,6 +86,7 @@ + /// * 1928: VS2019, version 16.8 + 16.9 + /// * 1929: VS2019, version 16.10 + 16.11 + /// * 1930: VS2022, version 17.0 +#ifndef LLVM_MSC_PREREQ #ifdef _MSC_VER #define LLVM_MSC_PREREQ(version) (_MSC_VER >= (version)) -@@ -91,28 +92,33 @@ +@@ -99,6 +100,7 @@ #else #define LLVM_MSC_PREREQ(version) 0 #endif @@ -28,19 +28,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 /// Does the compiler support ref-qualifiers for *this? /// - /// Sadly, this is separate from just rvalue reference support because GCC - /// and MSVC implemented this later than everything else. This appears to be - /// corrected in MSVC 2019 but not MSVC 2017. -+#ifndef LLVM_HAS_RVALUE_REFERENCE_THIS - #if __has_feature(cxx_rvalue_references) || LLVM_GNUC_PREREQ(4, 8, 1) || \ - LLVM_MSC_PREREQ(1920) - #define LLVM_HAS_RVALUE_REFERENCE_THIS 1 - #else - #define LLVM_HAS_RVALUE_REFERENCE_THIS 0 - #endif -+#endif - - /// Expands to '&' if ref-qualifiers for *this are supported. +@@ -112,11 +114,13 @@ /// /// This can be used to provide lvalue/rvalue overrides of member functions. /// The rvalue override should be guarded by LLVM_HAS_RVALUE_REFERENCE_THIS @@ -54,7 +42,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 /// LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked /// into a shared library, then the class should be private to the library and -@@ -132,21 +138,26 @@ +@@ -140,21 +144,26 @@ #define LLVM_EXTERNAL_VISIBILITY #endif @@ -67,7 +55,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 +#endif +#ifndef LLVM_ATTRIBUTE_USED - #if __has_attribute(used) || LLVM_GNUC_PREREQ(3, 1, 0) + #if __has_attribute(used) #define LLVM_ATTRIBUTE_USED __attribute__((__used__)) #else #define LLVM_ATTRIBUTE_USED @@ -81,7 +69,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 #if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(nodiscard) #define LLVM_NODISCARD [[nodiscard]] #elif LLVM_HAS_CPP_ATTRIBUTE(clang::warn_unused_result) -@@ -160,6 +171,7 @@ +@@ -168,6 +177,7 @@ #else #define LLVM_NODISCARD #endif @@ -89,12 +77,12 @@ index 989d25bb03b9..14f95ae8cc52 100644 // Indicate that a non-static, non-const C++ member function reinitializes // the entire object to a known state, independent of the previous state of -@@ -182,11 +194,13 @@ +@@ -190,11 +200,13 @@ // more portable solution: // (void)unused_var_name; // Prefer cast-to-void wherever it is sufficient. +#ifndef LLVM_ATTRIBUTE_UNUSED - #if __has_attribute(unused) || LLVM_GNUC_PREREQ(3, 1, 0) + #if __has_attribute(unused) #define LLVM_ATTRIBUTE_UNUSED __attribute__((__unused__)) #else #define LLVM_ATTRIBUTE_UNUSED @@ -102,8 +90,8 @@ index 989d25bb03b9..14f95ae8cc52 100644 +#endif // FIXME: Provide this for PE/COFF targets. - #if (__has_attribute(weak) || LLVM_GNUC_PREREQ(4, 0, 0)) && \ -@@ -196,6 +210,7 @@ + #if __has_attribute(weak) && !defined(__MINGW32__) && !defined(__CYGWIN__) && \ +@@ -204,6 +216,7 @@ #define LLVM_ATTRIBUTE_WEAK #endif @@ -111,7 +99,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 // 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__) -@@ -204,14 +219,18 @@ +@@ -212,13 +225,16 @@ #else #define LLVM_READNONE #endif @@ -126,11 +114,17 @@ index 989d25bb03b9..14f95ae8cc52 100644 #endif +#endif + #if __has_attribute(minsize) + #define LLVM_ATTRIBUTE_MINSIZE __attribute__((minsize)) +@@ -226,6 +242,7 @@ + #define LLVM_ATTRIBUTE_MINSIZE + #endif + +#ifndef LLVM_LIKELY - #if __has_builtin(__builtin_expect) || LLVM_GNUC_PREREQ(4, 0, 0) + #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) -@@ -219,9 +238,11 @@ +@@ -233,9 +250,11 @@ #define LLVM_LIKELY(EXPR) (EXPR) #define LLVM_UNLIKELY(EXPR) (EXPR) #endif @@ -139,44 +133,38 @@ index 989d25bb03b9..14f95ae8cc52 100644 /// LLVM_ATTRIBUTE_NOINLINE - On compilers where we have a directive to do so, /// mark a method "not for inlining". +#ifndef LLVM_ATTRIBUTE_NOINLINE - #if __has_attribute(noinline) || LLVM_GNUC_PREREQ(3, 4, 0) + #if __has_attribute(noinline) #define LLVM_ATTRIBUTE_NOINLINE __attribute__((noinline)) #elif defined(_MSC_VER) -@@ -229,11 +250,13 @@ +@@ -243,9 +262,11 @@ #else #define LLVM_ATTRIBUTE_NOINLINE #endif +#endif /// LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do - /// so, mark a method "always inline" because it is performance sensitive. GCC - /// 3.4 supported this but is buggy in various cases and produces unimplemented - /// errors, just use it in GCC 4.0 and later. + /// so, mark a method "always inline" because it is performance sensitive. +#ifndef LLVM_ATTRIBUTE_ALWAYS_INLINE - #if __has_attribute(always_inline) || LLVM_GNUC_PREREQ(4, 0, 0) + #if __has_attribute(always_inline) #define LLVM_ATTRIBUTE_ALWAYS_INLINE inline __attribute__((always_inline)) #elif defined(_MSC_VER) -@@ -241,7 +264,9 @@ +@@ -253,6 +274,7 @@ #else #define LLVM_ATTRIBUTE_ALWAYS_INLINE inline #endif +#endif -+#ifndef LLVM_ATTRIBUTE_NORETURN - #ifdef __GNUC__ - #define LLVM_ATTRIBUTE_NORETURN __attribute__((noreturn)) - #elif defined(_MSC_VER) -@@ -249,7 +274,9 @@ - #else - #define LLVM_ATTRIBUTE_NORETURN + /// 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 +@@ -263,6 +285,7 @@ + #define LLVM_ATTRIBUTE_NODEBUG #endif -+#endif +#ifndef LLVM_ATTRIBUTE_RETURNS_NONNULL - #if __has_attribute(returns_nonnull) || LLVM_GNUC_PREREQ(4, 9, 0) + #if __has_attribute(returns_nonnull) #define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) #elif defined(_MSC_VER) -@@ -257,9 +284,11 @@ +@@ -270,9 +293,11 @@ #else #define LLVM_ATTRIBUTE_RETURNS_NONNULL #endif @@ -188,7 +176,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 #ifdef __GNUC__ #define LLVM_ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__)) #elif defined(_MSC_VER) -@@ -267,8 +296,10 @@ +@@ -280,8 +305,10 @@ #else #define LLVM_ATTRIBUTE_RETURNS_NOALIAS #endif @@ -199,7 +187,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 #if defined(__cplusplus) && __cplusplus > 201402L && LLVM_HAS_CPP_ATTRIBUTE(fallthrough) #define LLVM_FALLTHROUGH [[fallthrough]] #elif LLVM_HAS_CPP_ATTRIBUTE(gnu::fallthrough) -@@ -280,6 +311,7 @@ +@@ -293,6 +320,7 @@ #else #define LLVM_FALLTHROUGH #endif @@ -207,7 +195,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 /// LLVM_REQUIRE_CONSTANT_INITIALIZATION - Apply this to globals to ensure that /// they are constant initialized. -@@ -308,28 +340,35 @@ +@@ -321,20 +349,25 @@ /// LLVM_EXTENSION - Support compilers where we have a keyword to suppress /// pedantic diagnostics. @@ -230,20 +218,22 @@ index 989d25bb03b9..14f95ae8cc52 100644 /// to an expression which states that it is undefined behavior for the /// compiler to reach this point. Otherwise is not defined. +#ifndef LLVM_BUILTIN_UNREACHABLE - #if __has_builtin(__builtin_unreachable) || LLVM_GNUC_PREREQ(4, 5, 0) + #if __has_builtin(__builtin_unreachable) || defined(__GNUC__) # define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable() #elif defined(_MSC_VER) - # define LLVM_BUILTIN_UNREACHABLE __assume(false) +@@ -342,9 +375,11 @@ + #else + # define LLVM_BUILTIN_UNREACHABLE #endif +#endif /// LLVM_BUILTIN_TRAP - On compilers which support it, expands to an expression /// which causes the program to exit abnormally. +#ifndef LLVM_BUILTIN_TRAP - #if __has_builtin(__builtin_trap) || LLVM_GNUC_PREREQ(4, 3, 0) + #if __has_builtin(__builtin_trap) || defined(__GNUC__) # define LLVM_BUILTIN_TRAP __builtin_trap() #elif defined(_MSC_VER) -@@ -341,10 +380,12 @@ +@@ -356,10 +391,12 @@ #else # define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0 #endif @@ -256,7 +246,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 #if __has_builtin(__builtin_debugtrap) # define LLVM_BUILTIN_DEBUGTRAP __builtin_debugtrap() #elif defined(_MSC_VER) -@@ -358,9 +399,11 @@ +@@ -373,9 +410,11 @@ // program to abort if encountered. # define LLVM_BUILTIN_DEBUGTRAP #endif @@ -265,10 +255,10 @@ index 989d25bb03b9..14f95ae8cc52 100644 /// \macro LLVM_ASSUME_ALIGNED /// Returns a pointer with an assumed alignment. +#ifndef LLVM_ASSUME_ALIGNED - #if __has_builtin(__builtin_assume_aligned) || LLVM_GNUC_PREREQ(4, 7, 0) + #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 +412,7 @@ +@@ -384,6 +423,7 @@ #else # define LLVM_ASSUME_ALIGNED(p, a) (p) #endif @@ -276,7 +266,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 /// \macro LLVM_PACKED /// Used to specify a packed structure. -@@ -388,6 +432,7 @@ +@@ -403,6 +443,7 @@ /// long long l; /// }; /// LLVM_PACKED_END @@ -284,7 +274,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 #ifdef _MSC_VER # define LLVM_PACKED(d) __pragma(pack(push, 1)) d __pragma(pack(pop)) # define LLVM_PACKED_START __pragma(pack(push, 1)) -@@ -397,11 +442,13 @@ +@@ -412,11 +453,13 @@ # define LLVM_PACKED_START _Pragma("pack(push, 1)") # define LLVM_PACKED_END _Pragma("pack(pop)") #endif @@ -298,7 +288,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 #ifdef __SIZEOF_POINTER__ # define LLVM_PTR_SIZE __SIZEOF_POINTER__ #elif defined(_WIN64) -@@ -413,6 +460,7 @@ +@@ -428,6 +471,7 @@ #else # define LLVM_PTR_SIZE sizeof(void *) #endif @@ -306,7 +296,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 /// \macro LLVM_MEMORY_SANITIZER_BUILD /// Whether LLVM itself is built with MemorySanitizer instrumentation. -@@ -483,11 +531,13 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -498,11 +542,13 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); /// \macro LLVM_NO_SANITIZE /// Disable a particular sanitizer for a function. @@ -320,7 +310,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 /// Mark debug helper function definitions like dump() that should not be /// stripped from debug builds. -@@ -495,17 +545,20 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -510,17 +556,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. @@ -341,7 +331,7 @@ index 989d25bb03b9..14f95ae8cc52 100644 #if defined(_MSC_VER) #define LLVM_PRETTY_FUNCTION __FUNCSIG__ #elif defined(__GNUC__) || defined(__clang__) -@@ -513,6 +566,7 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); +@@ -528,6 +577,7 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); #else #define LLVM_PRETTY_FUNCTION __func__ #endif diff --git a/upstream_utils/llvm_patches/0007-Explicitly-use-std.patch b/upstream_utils/llvm_patches/0007-Explicitly-use-std.patch index 2c324a111e..cfbe9a15d0 100644 --- a/upstream_utils/llvm_patches/0007-Explicitly-use-std.patch +++ b/upstream_utils/llvm_patches/0007-Explicitly-use-std.patch @@ -1,7 +1,7 @@ -From 6098845aed7416fde8a9c1f276571c8a1bc27799 Mon Sep 17 00:00:00 2001 +From c26562caae6a685716a8785ad8689833c9996549 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:37:34 -0400 -Subject: [PATCH 07/27] Explicitly use std:: +Subject: [PATCH 07/28] Explicitly use std:: --- llvm/include/llvm/ADT/SmallSet.h | 2 +- @@ -12,10 +12,10 @@ Subject: [PATCH 07/27] Explicitly use std:: 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/ADT/SmallSet.h b/llvm/include/llvm/ADT/SmallSet.h -index e4c209c5f2a9..f2b402ccf9a0 100644 +index bfe93e997..403e108fd 100644 --- a/llvm/include/llvm/ADT/SmallSet.h +++ b/llvm/include/llvm/ADT/SmallSet.h -@@ -269,7 +269,7 @@ bool operator==(const SmallSet &LHS, const SmallSet &RHS) { +@@ -270,7 +270,7 @@ bool operator==(const SmallSet &LHS, const SmallSet &RHS) { return false; // All elements in LHS must also be in RHS @@ -25,7 +25,7 @@ index e4c209c5f2a9..f2b402ccf9a0 100644 /// Inequality comparison for SmallSet. diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index db9fbc148ae3..da843ef79ff9 100644 +index db9fbc148..da843ef79 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -586,7 +586,7 @@ inline double Log2(double Value) { @@ -38,7 +38,7 @@ index db9fbc148ae3..da843ef79ff9 100644 } diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp -index 2403db9c80f1..9c0c6fb868f2 100644 +index 89440b5ab..f80e28e87 100644 --- a/llvm/lib/Support/ErrorHandling.cpp +++ b/llvm/lib/Support/ErrorHandling.cpp @@ -210,7 +210,7 @@ void LLVMResetFatalErrorHandler() { @@ -51,7 +51,7 @@ index 2403db9c80f1..9c0c6fb868f2 100644 std::error_code llvm::mapWindowsError(unsigned EV) { switch (EV) { diff --git a/llvm/unittests/ADT/SmallPtrSetTest.cpp b/llvm/unittests/ADT/SmallPtrSetTest.cpp -index 6f3c94eed273..531f81ab5b3f 100644 +index 6f3c94eed..531f81ab5 100644 --- a/llvm/unittests/ADT/SmallPtrSetTest.cpp +++ b/llvm/unittests/ADT/SmallPtrSetTest.cpp @@ -298,7 +298,7 @@ TEST(SmallPtrSetTest, dereferenceAndIterate) { @@ -64,10 +64,10 @@ index 6f3c94eed273..531f81ab5b3f 100644 EXPECT_EQ(F - Found + 1, *F); } diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp -index 18beb3878067..081b699adee3 100644 +index 86907ab61..6d0c0942c 100644 --- a/llvm/unittests/ADT/StringMapTest.cpp +++ b/llvm/unittests/ADT/StringMapTest.cpp -@@ -308,7 +308,7 @@ TEST_F(StringMapTest, IterMapKeys) { +@@ -329,7 +329,7 @@ TEST_F(StringMapTest, IterMapKeysSmallVector) { Map["D"] = 3; auto Keys = to_vector<4>(Map.keys()); diff --git a/upstream_utils/llvm_patches/0008-Remove-format_provider.patch b/upstream_utils/llvm_patches/0008-Remove-format_provider.patch index a23af048c5..1e43a8b25b 100644 --- a/upstream_utils/llvm_patches/0008-Remove-format_provider.patch +++ b/upstream_utils/llvm_patches/0008-Remove-format_provider.patch @@ -1,16 +1,16 @@ -From c7d5902712292ad85b8580437c1f09a16d79def9 Mon Sep 17 00:00:00 2001 +From f35fcb2c40caceed14437e65131e9fe1cf94deac Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sat, 7 May 2022 22:53:50 -0400 -Subject: [PATCH 08/27] Remove format_provider +Subject: [PATCH 08/28] Remove format_provider --- llvm/include/llvm/Support/Chrono.h | 109 ------------------------ - llvm/include/llvm/Support/raw_ostream.h | 5 -- + llvm/include/llvm/Support/raw_ostream.h | 6 -- llvm/unittests/Support/Chrono.cpp | 61 ------------- - 3 files changed, 175 deletions(-) + 3 files changed, 176 deletions(-) diff --git a/llvm/include/llvm/Support/Chrono.h b/llvm/include/llvm/Support/Chrono.h -index 2c2869de49b6..06829d1fbe14 100644 +index a7dea19d9..9f9a2b5ca 100644 --- a/llvm/include/llvm/Support/Chrono.h +++ b/llvm/include/llvm/Support/Chrono.h @@ -10,7 +10,6 @@ @@ -21,7 +21,7 @@ index 2c2869de49b6..06829d1fbe14 100644 #include #include -@@ -58,114 +57,6 @@ toTimePoint(std::time_t T, uint32_t nsec) { +@@ -59,114 +58,6 @@ toTimePoint(std::time_t T, uint32_t nsec) { raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP); @@ -137,13 +137,14 @@ index 2c2869de49b6..06829d1fbe14 100644 #endif // LLVM_SUPPORT_CHRONO_H diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index 4f6ea873304f..94d0ed66eced 100644 +index 9a1dd7a60..a25ca5b7b 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h -@@ -29,11 +29,6 @@ +@@ -28,12 +28,6 @@ namespace llvm { +-class Duration; -class formatv_object_base; -class format_object_base; -class FormattedString; @@ -153,7 +154,7 @@ index 4f6ea873304f..94d0ed66eced 100644 namespace sys { diff --git a/llvm/unittests/Support/Chrono.cpp b/llvm/unittests/Support/Chrono.cpp -index 9a08a5c1bfdf..3c049de18c0a 100644 +index 9a08a5c1b..3c049de18 100644 --- a/llvm/unittests/Support/Chrono.cpp +++ b/llvm/unittests/Support/Chrono.cpp @@ -30,37 +30,6 @@ TEST(Chrono, TimeTConversion) { diff --git a/upstream_utils/llvm_patches/0009-Add-compiler-warning-pragrams.patch b/upstream_utils/llvm_patches/0009-Add-compiler-warning-pragmas.patch similarity index 87% rename from upstream_utils/llvm_patches/0009-Add-compiler-warning-pragrams.patch rename to upstream_utils/llvm_patches/0009-Add-compiler-warning-pragmas.patch index f02c0cf7d7..2255dd1e29 100644 --- a/upstream_utils/llvm_patches/0009-Add-compiler-warning-pragrams.patch +++ b/upstream_utils/llvm_patches/0009-Add-compiler-warning-pragmas.patch @@ -1,10 +1,10 @@ -From a55cc2394a9fca533d8d07e3b61e47fedb99cd1b Mon Sep 17 00:00:00 2001 +From 2c53d8ac36f378fda347f36ef2bc7fbc2038cb93 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 13:34:07 -0400 -Subject: [PATCH 09/27] Add compiler warning pragrams +Subject: [PATCH 09/28] Add compiler warning pragmas --- - llvm/include/llvm/ADT/FunctionExtras.h | 10 ++++++++++ + llvm/include/llvm/ADT/FunctionExtras.h | 11 +++++++++++ llvm/include/llvm/ADT/Hashing.h | 9 +++++++++ llvm/include/llvm/ADT/SmallVector.h | 8 ++++++++ llvm/include/llvm/Support/MathExtras.h | 9 +++++++++ @@ -14,26 +14,27 @@ Subject: [PATCH 09/27] Add compiler warning pragrams llvm/unittests/ADT/MapVectorTest.cpp | 7 +++++++ llvm/unittests/ADT/SmallVectorTest.cpp | 4 ++++ llvm/unittests/Support/AlignOfTest.cpp | 7 +++---- - 10 files changed, 71 insertions(+), 4 deletions(-) + 10 files changed, 72 insertions(+), 4 deletions(-) diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h -index 1a26cb702cae..3b834236b8fa 100644 +index 8a9d78f41..3efa73587 100644 --- a/llvm/include/llvm/ADT/FunctionExtras.h +++ b/llvm/include/llvm/ADT/FunctionExtras.h -@@ -54,6 +54,12 @@ namespace llvm { +@@ -55,6 +55,13 @@ namespace llvm { /// It can hold functions with a non-const operator(), like mutable lambdas. template class unique_function; +// GCC warns on OutOfLineStorage +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push ++#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif + namespace detail { template -@@ -405,6 +411,10 @@ public: +@@ -411,6 +418,10 @@ public: } }; @@ -45,7 +46,7 @@ index 1a26cb702cae..3b834236b8fa 100644 #endif // LLVM_ADT_FUNCTIONEXTRAS_H diff --git a/llvm/include/llvm/ADT/Hashing.h b/llvm/include/llvm/ADT/Hashing.h -index e296c1c53ebd..8f90b4214b92 100644 +index 74a87a3d8..47ff1b2bc 100644 --- a/llvm/include/llvm/ADT/Hashing.h +++ b/llvm/include/llvm/ADT/Hashing.h @@ -55,6 +55,11 @@ @@ -58,9 +59,9 @@ index e296c1c53ebd..8f90b4214b92 100644 +#endif + namespace llvm { + template struct DenseMapInfo; - /// An opaque object representing a hash code. -@@ -679,4 +684,8 @@ hash_code hash_value(const std::basic_string &arg) { +@@ -687,4 +692,8 @@ template <> struct DenseMapInfo { } // namespace llvm @@ -70,10 +71,10 @@ index e296c1c53ebd..8f90b4214b92 100644 + #endif diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h -index 602fcc5b7a98..690d512a43c8 100644 +index 8686f7bb5..1e311ea56 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h -@@ -13,6 +13,14 @@ +@@ -14,6 +14,14 @@ #ifndef LLVM_ADT_SMALLVECTOR_H #define LLVM_ADT_SMALLVECTOR_H @@ -85,11 +86,11 @@ index 602fcc5b7a98..690d512a43c8 100644 +#pragma GCC diagnostic warning "-Wclass-memaccess" +#endif + - #include "llvm/ADT/iterator_range.h" #include "llvm/Support/Compiler.h" - #include "llvm/Support/ErrorHandling.h" + #include "llvm/Support/type_traits.h" + #include diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index da843ef79ff9..fac12dd0e4c6 100644 +index da843ef79..fac12dd0e 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -435,6 +435,11 @@ inline uint64_t maxUIntN(uint64_t N) { @@ -116,7 +117,7 @@ index da843ef79ff9..fac12dd0e4c6 100644 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 d6012bd5a698..01007deb89bb 100644 +index d6012bd5a..01007deb8 100644 --- a/llvm/include/llvm/Support/MemAlloc.h +++ b/llvm/include/llvm/Support/MemAlloc.h @@ -22,6 +22,14 @@ @@ -145,7 +146,7 @@ index d6012bd5a698..01007deb89bb 100644 + #endif diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index 306cc981ed8f..bff7b6c9a77b 100644 +index e4c318eb8..ee01a9522 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -10,6 +10,10 @@ @@ -157,10 +158,10 @@ index 306cc981ed8f..bff7b6c9a77b 100644 +#endif + #include "llvm/Support/raw_ostream.h" - #include "llvm/ADT/STLExtras.h" + #include "llvm/ADT/STLArrayExtras.h" #include "llvm/ADT/StringExtras.h" diff --git a/llvm/unittests/ADT/DenseMapTest.cpp b/llvm/unittests/ADT/DenseMapTest.cpp -index a122f1fe3bdf..123012a3118d 100644 +index e505b1907..9fe83a45d 100644 --- a/llvm/unittests/ADT/DenseMapTest.cpp +++ b/llvm/unittests/ADT/DenseMapTest.cpp @@ -6,6 +6,10 @@ @@ -175,7 +176,7 @@ index a122f1fe3bdf..123012a3118d 100644 #include "gtest/gtest.h" #include diff --git a/llvm/unittests/ADT/MapVectorTest.cpp b/llvm/unittests/ADT/MapVectorTest.cpp -index 552f9956bdc2..20ebcd753bcc 100644 +index 552f9956b..20ebcd753 100644 --- a/llvm/unittests/ADT/MapVectorTest.cpp +++ b/llvm/unittests/ADT/MapVectorTest.cpp @@ -6,6 +6,13 @@ @@ -193,7 +194,7 @@ index 552f9956bdc2..20ebcd753bcc 100644 #include "llvm/ADT/iterator_range.h" #include "gtest/gtest.h" diff --git a/llvm/unittests/ADT/SmallVectorTest.cpp b/llvm/unittests/ADT/SmallVectorTest.cpp -index 1914f38fac6c..387229c32d5a 100644 +index fe827546a..0e68bad6c 100644 --- a/llvm/unittests/ADT/SmallVectorTest.cpp +++ b/llvm/unittests/ADT/SmallVectorTest.cpp @@ -17,6 +17,10 @@ @@ -208,7 +209,7 @@ index 1914f38fac6c..387229c32d5a 100644 namespace { diff --git a/llvm/unittests/Support/AlignOfTest.cpp b/llvm/unittests/Support/AlignOfTest.cpp -index f84895c18602..6a50205b143b 100644 +index f84895c18..6a50205b1 100644 --- a/llvm/unittests/Support/AlignOfTest.cpp +++ b/llvm/unittests/Support/AlignOfTest.cpp @@ -31,10 +31,9 @@ namespace { diff --git a/upstream_utils/llvm_patches/0010-Remove-unused-functions.patch b/upstream_utils/llvm_patches/0010-Remove-unused-functions.patch index 9af35ec87a..50f5300cd2 100644 --- a/upstream_utils/llvm_patches/0010-Remove-unused-functions.patch +++ b/upstream_utils/llvm_patches/0010-Remove-unused-functions.patch @@ -1,21 +1,21 @@ -From 1354697da0c8661ef6030eb6355a680bbed7b752 Mon Sep 17 00:00:00 2001 +From df2dc9fdb3d57e01423104a71a6a1d1d6382644a Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 13:43:50 -0400 -Subject: [PATCH 10/27] Remove unused functions +Subject: [PATCH 10/28] Remove unused functions --- llvm/include/llvm/ADT/SmallString.h | 80 ------ llvm/include/llvm/Support/Errno.h | 9 - - llvm/include/llvm/Support/VersionTuple.h | 33 --- + llvm/include/llvm/Support/VersionTuple.h | 40 --- llvm/include/llvm/Support/raw_ostream.h | 115 +------- - llvm/lib/Support/raw_ostream.cpp | 327 ----------------------- - 5 files changed, 8 insertions(+), 556 deletions(-) + llvm/lib/Support/raw_ostream.cpp | 328 ----------------------- + 5 files changed, 8 insertions(+), 564 deletions(-) diff --git a/llvm/include/llvm/ADT/SmallString.h b/llvm/include/llvm/ADT/SmallString.h -index 8112741dd01d..85987811f3c4 100644 +index 50cbdade4..bfa965fd6 100644 --- a/llvm/include/llvm/ADT/SmallString.h +++ b/llvm/include/llvm/ADT/SmallString.h -@@ -86,48 +86,12 @@ public: +@@ -88,48 +88,12 @@ public: /// @name String Comparison /// @{ @@ -64,7 +64,7 @@ index 8112741dd01d..85987811f3c4 100644 /// @} /// @name String Searching /// @{ -@@ -208,50 +172,6 @@ public: +@@ -210,50 +174,6 @@ public: } /// @} @@ -116,7 +116,7 @@ index 8112741dd01d..85987811f3c4 100644 // Extra methods. diff --git a/llvm/include/llvm/Support/Errno.h b/llvm/include/llvm/Support/Errno.h -index 07df6765d9db..d9bf68bb369e 100644 +index 07df6765d..d9bf68bb3 100644 --- a/llvm/include/llvm/Support/Errno.h +++ b/llvm/include/llvm/Support/Errno.h @@ -20,15 +20,6 @@ @@ -136,10 +136,18 @@ index 07df6765d9db..d9bf68bb369e 100644 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 85f4f1a707c7..a28e12adcc25 100644 +index 3d6573bf5..a28e12adc 100644 --- a/llvm/include/llvm/Support/VersionTuple.h +++ b/llvm/include/llvm/Support/VersionTuple.h -@@ -158,39 +158,6 @@ public: +@@ -16,7 +16,6 @@ + + #include "llvm/ADT/DenseMapInfo.h" + #include "llvm/ADT/Hashing.h" +-#include "llvm/Support/HashBuilder.h" + #include + #include + #include +@@ -159,45 +158,6 @@ public: friend bool operator>=(const VersionTuple &X, const VersionTuple &Y) { return !(X < Y); } @@ -148,6 +156,12 @@ index 85f4f1a707c7..a28e12adcc25 100644 - return llvm::hash_combine(VT.Major, VT.Minor, VT.Subminor, VT.Build); - } - +- template +- friend void addHash(HashBuilderImpl &HBuilder, +- const VersionTuple &VT) { +- HBuilder.add(VT.Major, VT.Minor, VT.Subminor, VT.Build); +- } +- - /// Retrieve a string representation of the version number. - std::string getAsString() const; -}; @@ -180,10 +194,10 @@ index 85f4f1a707c7..a28e12adcc25 100644 } // end namespace llvm diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index 94d0ed66eced..50443e018aaf 100644 +index a25ca5b7b..d4521c8e2 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h -@@ -249,32 +249,6 @@ public: +@@ -248,32 +248,6 @@ public: return write(Str.data(), Str.size()); } @@ -216,7 +230,7 @@ index 94d0ed66eced..50443e018aaf 100644 /// Output \p Str, turning '\\', '\t', '\n', '"', and anything that doesn't /// satisfy llvm::isPrint into an escape sequence. raw_ostream &write_escaped(std::string_view Str, bool UseHexEscapes = false); -@@ -282,21 +256,6 @@ public: +@@ -281,21 +255,6 @@ public: raw_ostream &write(unsigned char C); raw_ostream &write(const char *Ptr, size_t Size); @@ -238,7 +252,7 @@ index 94d0ed66eced..50443e018aaf 100644 /// indent - Insert 'NumSpaces' spaces. raw_ostream &indent(unsigned NumSpaces); -@@ -311,14 +270,19 @@ public: +@@ -310,14 +269,19 @@ public: /// @param BG if true change the background, default: change foreground /// @returns itself so it can be used within << invocations virtual raw_ostream &changeColor(enum Colors Color, bool Bold = false, @@ -261,7 +275,7 @@ index 94d0ed66eced..50443e018aaf 100644 /// This function determines if this stream is connected to a "tty" or /// "console" window. That is, the output would be displayed to the user -@@ -391,10 +355,6 @@ private: +@@ -392,10 +356,6 @@ private: /// unused bytes in the buffer. void copy_to_buffer(const char *Ptr, size_t Size); @@ -272,15 +286,15 @@ index 94d0ed66eced..50443e018aaf 100644 /// Flush the tied-to stream (if present) and then write the required data. void flush_tied_then_write(const char *Ptr, size_t Size); -@@ -445,7 +405,6 @@ class raw_fd_ostream : public raw_pwrite_stream { - int FD; +@@ -447,7 +407,6 @@ class raw_fd_ostream : public raw_pwrite_stream { bool ShouldClose; bool SupportsSeeking = false; -- mutable Optional HasColors; + bool IsRegularFile = false; +- mutable std::optional HasColors; #ifdef _WIN32 /// True if this fd refers to a Windows console device. Mintty and other -@@ -519,10 +478,6 @@ public: +@@ -523,10 +482,6 @@ public: /// to the offset specified from the beginning of the file. uint64_t seek(uint64_t off); @@ -291,7 +305,7 @@ index 94d0ed66eced..50443e018aaf 100644 std::error_code error() const { return EC; } /// Return the value of the flag in this raw_fd_ostream indicating whether an -@@ -541,38 +496,6 @@ public: +@@ -545,38 +500,6 @@ public: /// - from The Zen of Python, by Tim Peters /// void clear_error() { EC = std::error_code(); } @@ -326,11 +340,11 @@ index 94d0ed66eced..50443e018aaf 100644 - /// - /// It is used as @ref lock. - LLVM_NODISCARD -- Expected tryLockFor(std::chrono::milliseconds Timeout); +- Expected tryLockFor(Duration const& Timeout); }; /// This returns a reference to a raw_fd_ostream for standard output. Use it -@@ -602,17 +525,6 @@ public: +@@ -606,17 +529,6 @@ public: /// immediately destroyed. raw_fd_stream(std::string_view Filename, std::error_code &EC); @@ -348,7 +362,7 @@ index 94d0ed66eced..50443e018aaf 100644 /// Check if \p OS is a pointer of type raw_fd_stream*. static bool classof(const raw_ostream *OS); }; -@@ -726,17 +638,6 @@ public: +@@ -734,17 +646,6 @@ public: ~buffer_unique_ostream() override { *OS << str(); } }; @@ -367,10 +381,18 @@ index 94d0ed66eced..50443e018aaf 100644 #endif // LLVM_SUPPORT_RAW_OSTREAM_H diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index bff7b6c9a77b..611043dc5925 100644 +index ee01a9522..875eda7ba 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp -@@ -121,49 +121,6 @@ void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size, +@@ -19,7 +19,6 @@ + #include "llvm/ADT/StringExtras.h" + #include "llvm/Config/config.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" +@@ -120,49 +119,6 @@ void raw_ostream::SetBufferAndMode(char *BufferStart, size_t Size, assert(OutBufStart <= OutBufEnd && "Invalid size!"); } @@ -420,7 +442,7 @@ index bff7b6c9a77b..611043dc5925 100644 raw_ostream &raw_ostream::write_escaped(std::string_view Str, bool UseHexEscapes) { for (unsigned char c : Str) { -@@ -309,172 +266,6 @@ void raw_ostream::flush_tied_then_write(const char *Ptr, size_t Size) { +@@ -308,172 +264,6 @@ void raw_ostream::flush_tied_then_write(const char *Ptr, size_t Size) { write_impl(Ptr, Size); } @@ -593,7 +615,7 @@ index bff7b6c9a77b..611043dc5925 100644 template static raw_ostream &write_padding(raw_ostream &OS, unsigned NumChars) { -@@ -507,63 +298,8 @@ raw_ostream &raw_ostream::write_zeros(unsigned NumZeros) { +@@ -506,63 +296,8 @@ raw_ostream &raw_ostream::write_zeros(unsigned NumZeros) { return write_padding<'\0'>(*this, NumZeros); } @@ -657,7 +679,7 @@ index bff7b6c9a77b..611043dc5925 100644 //===----------------------------------------------------------------------===// // raw_fd_ostream //===----------------------------------------------------------------------===// -@@ -854,31 +590,6 @@ size_t raw_fd_ostream::preferred_buffer_size() const { +@@ -854,31 +589,6 @@ size_t raw_fd_ostream::preferred_buffer_size() const { #endif } @@ -679,8 +701,8 @@ index bff7b6c9a77b..611043dc5925 100644 -} - -Expected --raw_fd_ostream::tryLockFor(std::chrono::milliseconds Timeout) { -- std::error_code EC = sys::fs::tryLockFile(FD, Timeout); +-raw_fd_ostream::tryLockFor(Duration const& Timeout) { +- std::error_code EC = sys::fs::tryLockFile(FD, Timeout.getDuration()); - if (!EC) - return sys::fs::FileLocker(FD); - return errorCodeToError(EC); @@ -689,7 +711,7 @@ index bff7b6c9a77b..611043dc5925 100644 void raw_fd_ostream::anchor() {} //===----------------------------------------------------------------------===// -@@ -922,16 +633,6 @@ raw_fd_stream::raw_fd_stream(std::string_view Filename, std::error_code &EC) +@@ -921,16 +631,6 @@ raw_fd_stream::raw_fd_stream(std::string_view Filename, std::error_code &EC) EC = std::make_error_code(std::errc::invalid_argument); } @@ -706,7 +728,7 @@ index bff7b6c9a77b..611043dc5925 100644 bool raw_fd_stream::classof(const raw_ostream *OS) { return OS->get_kind() == OStreamKind::OK_FDStream; } -@@ -991,31 +692,3 @@ void raw_pwrite_stream::anchor() {} +@@ -986,31 +686,3 @@ void raw_pwrite_stream::anchor() {} void buffer_ostream::anchor() {} void buffer_unique_ostream::anchor() {} diff --git a/upstream_utils/llvm_patches/0011-Detemplatize-small-vector-base.patch b/upstream_utils/llvm_patches/0011-Detemplatize-SmallVectorBase.patch similarity index 87% rename from upstream_utils/llvm_patches/0011-Detemplatize-small-vector-base.patch rename to upstream_utils/llvm_patches/0011-Detemplatize-SmallVectorBase.patch index 55b57009eb..320e5006e5 100644 --- a/upstream_utils/llvm_patches/0011-Detemplatize-small-vector-base.patch +++ b/upstream_utils/llvm_patches/0011-Detemplatize-SmallVectorBase.patch @@ -1,7 +1,7 @@ -From 0afb3b1de99d7f85899d3907e5e9a503a6ac599a Mon Sep 17 00:00:00 2001 +From ef26f059859d3a0d08b06a70519928bcd5f9bb79 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 5 May 2022 23:18:34 -0400 -Subject: [PATCH 11/27] Detemplatize small vector base +Subject: [PATCH 11/28] Detemplatize SmallVectorBase --- llvm/include/llvm/ADT/SmallVector.h | 21 +++++++----------- @@ -9,10 +9,10 @@ Subject: [PATCH 11/27] Detemplatize small vector base 2 files changed, 13 insertions(+), 42 deletions(-) diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h -index 690d512a43c8..695015ae3248 100644 +index 1e311ea56..4b6bbdeb2 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h -@@ -50,14 +50,14 @@ namespace llvm { +@@ -50,14 +50,14 @@ template class iterator_range; /// Using 64 bit size is desirable for cases like SmallVector, where a /// 32 bit size would limit the vector to ~4GB. SmallVectors are used for /// buffering bitcode output - which can exceed 4GB. @@ -30,7 +30,7 @@ index 690d512a43c8..695015ae3248 100644 } SmallVectorBase() = delete; -@@ -95,15 +95,10 @@ public: +@@ -91,15 +91,10 @@ protected: } }; @@ -48,7 +48,7 @@ index 690d512a43c8..695015ae3248 100644 alignas(T) char FirstEl[sizeof(T)]; }; -@@ -112,8 +107,8 @@ template struct SmallVectorAlignmentAndSize { +@@ -108,8 +103,8 @@ template struct SmallVectorAlignmentAndSize { /// to avoid unnecessarily requiring T to be complete. template class SmallVectorTemplateCommon @@ -59,7 +59,7 @@ index 690d512a43c8..695015ae3248 100644 /// Find the address of the first element. For this pointer math to be valid /// with small-size of 0 for T with lots of alignment, it's important that -@@ -360,7 +355,7 @@ protected: +@@ -356,7 +351,7 @@ protected: /// in \p NewCapacity. This is the first section of \a grow(). T *mallocForGrow(size_t MinSize, size_t &NewCapacity) { return static_cast( @@ -69,10 +69,10 @@ index 690d512a43c8..695015ae3248 100644 } diff --git a/llvm/lib/Support/SmallVector.cpp b/llvm/lib/Support/SmallVector.cpp -index 26901fe97d20..3fc16097bd30 100644 +index a2b4899e1..bdfc963d7 100644 --- a/llvm/lib/Support/SmallVector.cpp +++ b/llvm/lib/Support/SmallVector.cpp -@@ -41,10 +41,6 @@ static_assert(sizeof(SmallVector) == +@@ -51,10 +51,6 @@ static_assert(sizeof(SmallVector) == sizeof(unsigned) * 2 + sizeof(void *) * 2, "wasted space in SmallVector size 1"); @@ -82,8 +82,8 @@ index 26901fe97d20..3fc16097bd30 100644 - /// Report that MinSize doesn't fit into this vector's size type. Throws /// std::length_error or calls report_fatal_error. - LLVM_ATTRIBUTE_NORETURN -@@ -76,9 +72,8 @@ static void report_at_maximum_capacity(size_t MaxSize) { + [[noreturn]] static void report_size_overflow(size_t MinSize, size_t MaxSize); +@@ -85,9 +81,8 @@ static void report_at_maximum_capacity(size_t MaxSize) { } // Note: Moving this function into the header may cause performance regression. @@ -94,7 +94,7 @@ index 26901fe97d20..3fc16097bd30 100644 // Ensure we can fit the new capacity. // This is only going to be applicable when the capacity is 32 bit. -@@ -99,18 +94,16 @@ static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) { +@@ -108,18 +103,16 @@ static size_t getNewCapacity(size_t MinSize, size_t TSize, size_t OldCapacity) { } // Note: Moving this function into the header may cause performance regression. @@ -117,7 +117,7 @@ index 26901fe97d20..3fc16097bd30 100644 void *NewElts; if (BeginX == FirstEl) { NewElts = safe_malloc(NewCapacity * TSize); -@@ -125,20 +118,3 @@ void SmallVectorBase::grow_pod(void *FirstEl, size_t MinSize, +@@ -134,20 +127,3 @@ void SmallVectorBase::grow_pod(void *FirstEl, size_t MinSize, this->BeginX = NewElts; this->Capacity = NewCapacity; } diff --git a/upstream_utils/llvm_patches/0012-Add-vectors-to-raw_ostream.patch b/upstream_utils/llvm_patches/0012-Add-vectors-to-raw_ostream.patch index 117cb6f5d6..cc0bd5d803 100644 --- a/upstream_utils/llvm_patches/0012-Add-vectors-to-raw_ostream.patch +++ b/upstream_utils/llvm_patches/0012-Add-vectors-to-raw_ostream.patch @@ -1,7 +1,7 @@ -From c01b703c5d54cb57f8a73215a4ca8aded32dd9ba Mon Sep 17 00:00:00 2001 +From 342ebd445bb3dae8b0c119a6126a318ad378a377 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 13:48:59 -0400 -Subject: [PATCH 12/27] Add vectors to raw_ostream +Subject: [PATCH 12/28] Add vectors to raw_ostream --- llvm/include/llvm/Support/raw_ostream.h | 115 ++++++++++++++++++++++++ @@ -9,10 +9,10 @@ Subject: [PATCH 12/27] Add vectors to raw_ostream 2 files changed, 162 insertions(+) diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index 50443e018aaf..8008170be3e5 100644 +index d4521c8e2..bf5630ab5 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h -@@ -26,6 +26,7 @@ +@@ -25,6 +25,7 @@ #endif #include #include @@ -20,7 +20,7 @@ index 50443e018aaf..8008170be3e5 100644 namespace llvm { -@@ -249,12 +250,24 @@ public: +@@ -248,12 +249,24 @@ public: return write(Str.data(), Str.size()); } @@ -45,7 +45,7 @@ index 50443e018aaf..8008170be3e5 100644 /// indent - Insert 'NumSpaces' spaces. raw_ostream &indent(unsigned NumSpaces); -@@ -600,6 +613,108 @@ public: +@@ -604,6 +617,108 @@ public: } }; @@ -155,10 +155,10 @@ index 50443e018aaf..8008170be3e5 100644 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 611043dc5925..3abeed3dac21 100644 +index 875eda7ba..36faf744c 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp -@@ -664,6 +664,53 @@ void raw_svector_ostream::pwrite_impl(const char *Ptr, size_t Size, +@@ -658,6 +658,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/0013-Extra-collections-features.patch b/upstream_utils/llvm_patches/0013-Extra-collections-features.patch index 6d1350c413..19aef1a45c 100644 --- a/upstream_utils/llvm_patches/0013-Extra-collections-features.patch +++ b/upstream_utils/llvm_patches/0013-Extra-collections-features.patch @@ -1,7 +1,7 @@ -From 1c2a3d6eb4737e5b822ca8729472ddcf5c4d78c2 Mon Sep 17 00:00:00 2001 +From 5db7e9f9370a5e04949846cc68eeb13e2c1db187 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 3 May 2022 22:16:10 -0400 -Subject: [PATCH 13/27] Extra collections features +Subject: [PATCH 13/28] Extra collections features --- llvm/include/llvm/ADT/StringMap.h | 103 +++++++++++++++++++++++++++++- @@ -9,10 +9,10 @@ Subject: [PATCH 13/27] Extra collections features 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h -index 5f463cfef943..ac0d4b363145 100644 +index 8747cdb35..16f13f048 100644 --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h -@@ -40,7 +40,7 @@ protected: +@@ -42,7 +42,7 @@ protected: protected: explicit StringMapImpl(unsigned itemSize) : ItemSize(itemSize) {} @@ -21,7 +21,7 @@ index 5f463cfef943..ac0d4b363145 100644 : TheTable(RHS.TheTable), NumBuckets(RHS.NumBuckets), NumItems(RHS.NumItems), NumTombstones(RHS.NumTombstones), ItemSize(RHS.ItemSize) { -@@ -405,11 +405,27 @@ public: +@@ -420,11 +420,27 @@ public: return Tmp; } @@ -49,8 +49,8 @@ index 5f463cfef943..ac0d4b363145 100644 }; template -@@ -474,6 +490,91 @@ private: - std::string_view Key; +@@ -483,6 +499,91 @@ public: + std::string_view operator*() const { return this->wrapped()->getKey(); } }; +template @@ -142,10 +142,10 @@ index 5f463cfef943..ac0d4b363145 100644 #endif // LLVM_ADT_STRINGMAP_H diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index 3abeed3dac21..27bba0ca2f06 100644 +index 36faf744c..95152849c 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp -@@ -78,6 +78,14 @@ constexpr raw_ostream::Colors raw_ostream::WHITE; +@@ -76,6 +76,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-EpochTracker-abi-macro.patch b/upstream_utils/llvm_patches/0014-EpochTracker-ABI-macro.patch similarity index 78% rename from upstream_utils/llvm_patches/0014-EpochTracker-abi-macro.patch rename to upstream_utils/llvm_patches/0014-EpochTracker-ABI-macro.patch index 5ece9e40a3..1049911de8 100644 --- a/upstream_utils/llvm_patches/0014-EpochTracker-abi-macro.patch +++ b/upstream_utils/llvm_patches/0014-EpochTracker-ABI-macro.patch @@ -1,17 +1,17 @@ -From 72ab19d035da6d31695f3622270978608d7ef0ef Mon Sep 17 00:00:00 2001 +From 9951c4b3fea6b2dbe7141070444de8df6ae4ce9b Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Wed, 4 May 2022 00:01:00 -0400 -Subject: [PATCH 14/27] EpochTracker abi macro +Subject: [PATCH 14/28] EpochTracker ABI macro --- llvm/include/llvm/ADT/EpochTracker.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/EpochTracker.h b/llvm/include/llvm/ADT/EpochTracker.h -index 7a2e4220afec..8f98f3d582c7 100644 +index b06888494..f35461d1c 100644 --- a/llvm/include/llvm/ADT/EpochTracker.h +++ b/llvm/include/llvm/ADT/EpochTracker.h -@@ -21,7 +21,7 @@ +@@ -22,7 +22,7 @@ namespace llvm { diff --git a/upstream_utils/llvm_patches/0015-Delete-numbers-from-mathextras.patch b/upstream_utils/llvm_patches/0015-Delete-numbers-from-MathExtras.patch similarity index 95% rename from upstream_utils/llvm_patches/0015-Delete-numbers-from-mathextras.patch rename to upstream_utils/llvm_patches/0015-Delete-numbers-from-MathExtras.patch index 0aa7a19507..5578739ebb 100644 --- a/upstream_utils/llvm_patches/0015-Delete-numbers-from-mathextras.patch +++ b/upstream_utils/llvm_patches/0015-Delete-numbers-from-MathExtras.patch @@ -1,14 +1,14 @@ -From bb8c33904fba6099ca17ddecd84fa20272c5a20c Mon Sep 17 00:00:00 2001 +From 907608f09061ab272b0a127330b1b24e28d50a9f Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 5 May 2022 18:09:45 -0400 -Subject: [PATCH 15/27] Delete numbers from mathextras +Subject: [PATCH 15/28] Delete numbers from MathExtras --- llvm/include/llvm/Support/MathExtras.h | 36 -------------------------- 1 file changed, 36 deletions(-) diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index fac12dd0e4c6..e8f1f2aca610 100644 +index fac12dd0e..e8f1f2aca 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -50,42 +50,6 @@ enum ZeroBehavior { diff --git a/upstream_utils/llvm_patches/0016-Add-lerp-and-sgn.patch b/upstream_utils/llvm_patches/0016-Add-lerp-and-sgn.patch index 195834a37c..8dcc9c72de 100644 --- a/upstream_utils/llvm_patches/0016-Add-lerp-and-sgn.patch +++ b/upstream_utils/llvm_patches/0016-Add-lerp-and-sgn.patch @@ -1,14 +1,14 @@ -From 08f507c2c558f3ae9fcd7a31c7ce33b0776bfe8a Mon Sep 17 00:00:00 2001 +From 9ef10e5b331d00d7d5822afdb70c1f2d9981d772 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 3 May 2022 22:50:24 -0400 -Subject: [PATCH 16/27] Add lerp and sgn +Subject: [PATCH 16/28] Add lerp and sgn --- llvm/include/llvm/Support/MathExtras.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/llvm/include/llvm/Support/MathExtras.h b/llvm/include/llvm/Support/MathExtras.h -index e8f1f2aca610..8116c58bd0d6 100644 +index e8f1f2aca..8116c58bd 100644 --- a/llvm/include/llvm/Support/MathExtras.h +++ b/llvm/include/llvm/Support/MathExtras.h @@ -930,6 +930,26 @@ std::enable_if_t::value, T> MulOverflow(T X, T Y, T &Result) { diff --git a/upstream_utils/llvm_patches/0017-Fixup-includes.patch b/upstream_utils/llvm_patches/0017-Fixup-includes.patch index dc58c7163c..f247db0fd9 100644 --- a/upstream_utils/llvm_patches/0017-Fixup-includes.patch +++ b/upstream_utils/llvm_patches/0017-Fixup-includes.patch @@ -1,7 +1,7 @@ -From 8e868fdb545f3facb646418b5e127e360fe88a99 Mon Sep 17 00:00:00 2001 +From aa30b80d86cb0774efc094646339b54694ab8398 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:38:11 -0400 -Subject: [PATCH 17/27] Fixup includes +Subject: [PATCH 17/28] Fixup includes --- llvm/include/llvm/ADT/StringMap.h | 4 ++++ @@ -16,12 +16,12 @@ Subject: [PATCH 17/27] Fixup includes 9 files changed, 24 insertions(+), 10 deletions(-) diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h -index ac0d4b363145..f7bf5ad9c063 100644 +index 16f13f048..6ae0e39a1 100644 --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h -@@ -15,6 +15,10 @@ - +@@ -17,6 +17,10 @@ #include "llvm/ADT/StringMapEntry.h" + #include "llvm/ADT/iterator.h" #include "llvm/Support/AllocatorBase.h" +#include "llvm/Support/MemAlloc.h" +#include "llvm/Support/SmallVector.h" @@ -31,10 +31,10 @@ index ac0d4b363145..f7bf5ad9c063 100644 #include #include diff --git a/llvm/include/llvm/ADT/StringMapEntry.h b/llvm/include/llvm/ADT/StringMapEntry.h -index 93e13b5bb16c..cdf11d627200 100644 +index 39976a02b..cdefc5449 100644 --- a/llvm/include/llvm/ADT/StringMapEntry.h +++ b/llvm/include/llvm/ADT/StringMapEntry.h -@@ -15,6 +15,10 @@ +@@ -16,6 +16,10 @@ #ifndef LLVM_ADT_STRINGMAPENTRY_H #define LLVM_ADT_STRINGMAPENTRY_H @@ -46,7 +46,7 @@ index 93e13b5bb16c..cdf11d627200 100644 #include diff --git a/llvm/include/llvm/Support/PointerLikeTypeTraits.h b/llvm/include/llvm/Support/PointerLikeTypeTraits.h -index 1b15f930bd87..acadd5e89a16 100644 +index 1b15f930b..acadd5e89 100644 --- a/llvm/include/llvm/Support/PointerLikeTypeTraits.h +++ b/llvm/include/llvm/Support/PointerLikeTypeTraits.h @@ -16,6 +16,7 @@ @@ -58,7 +58,7 @@ index 1b15f930bd87..acadd5e89a16 100644 namespace llvm { diff --git a/llvm/lib/Support/ConvertUTFWrapper.cpp b/llvm/lib/Support/ConvertUTFWrapper.cpp -index 090ebb0f5af8..87da616b75d4 100644 +index 396ab0c65..cff30f16c 100644 --- a/llvm/lib/Support/ConvertUTFWrapper.cpp +++ b/llvm/lib/Support/ConvertUTFWrapper.cpp @@ -8,6 +8,7 @@ @@ -70,7 +70,7 @@ index 090ebb0f5af8..87da616b75d4 100644 #include "llvm/Support/SwapByteOrder.h" #include diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp -index 9c0c6fb868f2..4b6ddd30c6e4 100644 +index f80e28e87..ec1a1633a 100644 --- a/llvm/lib/Support/ErrorHandling.cpp +++ b/llvm/lib/Support/ErrorHandling.cpp @@ -28,12 +28,11 @@ @@ -90,20 +90,20 @@ index 9c0c6fb868f2..4b6ddd30c6e4 100644 using namespace llvm; diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index 27bba0ca2f06..6b9e5f9e44bd 100644 +index 95152849c..878a3a5e9 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp @@ -15,7 +15,8 @@ #endif #include "llvm/Support/raw_ostream.h" --#include "llvm/ADT/STLExtras.h" +-#include "llvm/ADT/STLArrayExtras.h" +#include "wpi/SmallString.h" +#include "wpi/SmallVector.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Config/config.h" #include "llvm/Support/Compiler.h" -@@ -35,12 +36,11 @@ +@@ -33,12 +34,11 @@ #include // may provide O_BINARY. @@ -119,7 +119,7 @@ index 27bba0ca2f06..6b9e5f9e44bd 100644 #endif #if defined(__CYGWIN__) -@@ -62,7 +62,7 @@ +@@ -60,7 +60,7 @@ #ifdef _WIN32 #include "llvm/Support/ConvertUTF.h" @@ -129,7 +129,7 @@ index 27bba0ca2f06..6b9e5f9e44bd 100644 using namespace llvm; diff --git a/llvm/unittests/ADT/SmallPtrSetTest.cpp b/llvm/unittests/ADT/SmallPtrSetTest.cpp -index 531f81ab5b3f..3db8b6e37d31 100644 +index 531f81ab5..3db8b6e37 100644 --- a/llvm/unittests/ADT/SmallPtrSetTest.cpp +++ b/llvm/unittests/ADT/SmallPtrSetTest.cpp @@ -15,6 +15,8 @@ @@ -142,7 +142,7 @@ index 531f81ab5b3f..3db8b6e37d31 100644 TEST(SmallPtrSetTest, Assignment) { diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp -index 081b699adee3..64bb8f85c4b9 100644 +index 6d0c0942c..de6daf3da 100644 --- a/llvm/unittests/ADT/StringMapTest.cpp +++ b/llvm/unittests/ADT/StringMapTest.cpp @@ -9,6 +9,7 @@ @@ -154,7 +154,7 @@ index 081b699adee3..64bb8f85c4b9 100644 #include using namespace llvm; diff --git a/llvm/unittests/Support/ConvertUTFTest.cpp b/llvm/unittests/Support/ConvertUTFTest.cpp -index 9c798437a12d..2fee8ad5c012 100644 +index 9c798437a..2fee8ad5c 100644 --- a/llvm/unittests/Support/ConvertUTFTest.cpp +++ b/llvm/unittests/Support/ConvertUTFTest.cpp @@ -7,6 +7,8 @@ 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 similarity index 95% rename from upstream_utils/llvm_patches/0018-use-std-is_trivially_copy_constructible.patch rename to upstream_utils/llvm_patches/0018-Use-std-is_trivially_copy_constructible.patch index 5ecd40b068..4e2650ef6f 100644 --- 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 @@ -1,7 +1,7 @@ -From 024847ab39cbe06024da3f5c63d9a667aff4e500 Mon Sep 17 00:00:00 2001 +From 1c3e8a6ff8d8b6c054141503c7318d69319d8d41 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:42:09 -0400 -Subject: [PATCH 18/27] use std is_trivially_copy_constructible +Subject: [PATCH 18/28] Use std::is_trivially_copy_constructible --- llvm/include/llvm/ADT/PointerIntPair.h | 12 ---- @@ -9,10 +9,10 @@ Subject: [PATCH 18/27] use std is_trivially_copy_constructible 2 files changed, 2 insertions(+), 101 deletions(-) diff --git a/llvm/include/llvm/ADT/PointerIntPair.h b/llvm/include/llvm/ADT/PointerIntPair.h -index cb8b202c48b7..f9c4d2dd14c7 100644 +index b7ddf8855..a48fb904b 100644 --- a/llvm/include/llvm/ADT/PointerIntPair.h +++ b/llvm/include/llvm/ADT/PointerIntPair.h -@@ -127,18 +127,6 @@ public: +@@ -128,18 +128,6 @@ public: } }; @@ -32,7 +32,7 @@ index cb8b202c48b7..f9c4d2dd14c7 100644 template struct PointerIntPairInfo { diff --git a/llvm/include/llvm/Support/type_traits.h b/llvm/include/llvm/Support/type_traits.h -index 7b7d5d991f3f..72a2e84ad452 100644 +index 7b7d5d991..72a2e84ad 100644 --- a/llvm/include/llvm/Support/type_traits.h +++ b/llvm/include/llvm/Support/type_traits.h @@ -92,98 +92,11 @@ union trivial_helper { diff --git a/upstream_utils/llvm_patches/0019-Windows-Support.patch b/upstream_utils/llvm_patches/0019-Windows-support.patch similarity index 87% rename from upstream_utils/llvm_patches/0019-Windows-Support.patch rename to upstream_utils/llvm_patches/0019-Windows-support.patch index 80486b8dee..07d973b947 100644 --- a/upstream_utils/llvm_patches/0019-Windows-Support.patch +++ b/upstream_utils/llvm_patches/0019-Windows-support.patch @@ -1,16 +1,15 @@ -From 45d53c5dc0cc2924569a96c1ac1e4efcaaa60044 Mon Sep 17 00:00:00 2001 +From 36f7f08e257f2b58b2894f165a38ff2a831aed8f Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Tue, 3 May 2022 20:22:38 -0400 -Subject: [PATCH 19/27] Windows Support +Subject: [PATCH 19/28] Windows support --- .../llvm/Support/Windows/WindowsSupport.h | 45 +++++---- llvm/lib/Support/ConvertUTF.cpp | 95 +++++++++++++++++++ - llvm/lib/Support/MemoryBuffer.cpp | 4 +- - 3 files changed, 126 insertions(+), 18 deletions(-) + 2 files changed, 124 insertions(+), 16 deletions(-) diff --git a/llvm/include/llvm/Support/Windows/WindowsSupport.h b/llvm/include/llvm/Support/Windows/WindowsSupport.h -index 551bd199551e..50b0843beb29 100644 +index 180803fbd..31120cfa0 100644 --- a/llvm/include/llvm/Support/Windows/WindowsSupport.h +++ b/llvm/include/llvm/Support/Windows/WindowsSupport.h @@ -35,8 +35,6 @@ @@ -91,7 +90,7 @@ index 551bd199551e..50b0843beb29 100644 } // end namespace llvm. diff --git a/llvm/lib/Support/ConvertUTF.cpp b/llvm/lib/Support/ConvertUTF.cpp -index e24a918c5c89..b4c7fffee8f7 100644 +index e24a918c5..c906ded91 100644 --- a/llvm/lib/Support/ConvertUTF.cpp +++ b/llvm/lib/Support/ConvertUTF.cpp @@ -51,6 +51,11 @@ @@ -126,7 +125,7 @@ index e24a918c5c89..b4c7fffee8f7 100644 + } + + utf16.reserve(len + 1); -+ utf16.set_size(len); ++ utf16.resize_for_overwrite(len); + + len = ::MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, original.data(), + original.size(), utf16.begin(), utf16.size()); @@ -167,7 +166,7 @@ index e24a918c5c89..b4c7fffee8f7 100644 + } + + converted.reserve(len); -+ converted.set_size(len); ++ converted.resize_for_overwrite(len); + + // Now do the actual conversion. + len = ::WideCharToMultiByte(codepage, 0, utf16, utf16_len, converted.data(), @@ -203,18 +202,3 @@ index e24a918c5c89..b4c7fffee8f7 100644 } // namespace llvm ConvertUTF_RESTORE_WARNINGS -diff --git a/llvm/lib/Support/MemoryBuffer.cpp b/llvm/lib/Support/MemoryBuffer.cpp -index bcf13d828a5d..cddad9ca0660 100644 ---- a/llvm/lib/Support/MemoryBuffer.cpp -+++ b/llvm/lib/Support/MemoryBuffer.cpp -@@ -225,8 +225,8 @@ public: - - static ErrorOr> - getMemoryBufferForStream(sys::fs::file_t FD, const Twine &BufferName) { -- const ssize_t ChunkSize = 4096*4; -- SmallString Buffer; -+ constexpr size_t ChunkSize = 4096*4; -+ SmallVector Buffer; - // Read into Buffer until we hit EOF. - for (;;) { - Buffer.reserve(Buffer.size() + ChunkSize); diff --git a/upstream_utils/llvm_patches/0020-Prefer-fmtlib.patch b/upstream_utils/llvm_patches/0020-Prefer-fmtlib.patch index 6b598013c9..b7a8d8b225 100644 --- a/upstream_utils/llvm_patches/0020-Prefer-fmtlib.patch +++ b/upstream_utils/llvm_patches/0020-Prefer-fmtlib.patch @@ -1,14 +1,14 @@ -From 2a480ee8e89b322b91f596a5a9d63aa6b9a76af0 Mon Sep 17 00:00:00 2001 +From 8834260a9ee172311cc08d0b4e4e958bf36a260f Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:46:20 -0400 -Subject: [PATCH 20/27] Prefer fmtlib +Subject: [PATCH 20/28] Prefer fmtlib --- llvm/lib/Support/ErrorHandling.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp -index 4b6ddd30c6e4..9ee52a02c214 100644 +index ec1a1633a..8de7b726d 100644 --- a/llvm/lib/Support/ErrorHandling.cpp +++ b/llvm/lib/Support/ErrorHandling.cpp @@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@ index 4b6ddd30c6e4..9ee52a02c214 100644 #include @@ -93,15 +93,7 @@ void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) { if (handler) { - handler(handlerData, std::string{Reason}, GenCrashDiag); + handler(handlerData, std::string{Reason}.c_str(), GenCrashDiag); } else { - // Blast the result out to stderr. We don't try hard to make sure this - // succeeds (e.g. handling EINTR) and we can't use errs() here because diff --git a/upstream_utils/llvm_patches/0021-prefer-wpi-s-fs.h.patch b/upstream_utils/llvm_patches/0021-Prefer-wpi-s-fs.h.patch similarity index 84% rename from upstream_utils/llvm_patches/0021-prefer-wpi-s-fs.h.patch rename to upstream_utils/llvm_patches/0021-Prefer-wpi-s-fs.h.patch index a6c034f347..2f246a08e6 100644 --- a/upstream_utils/llvm_patches/0021-prefer-wpi-s-fs.h.patch +++ b/upstream_utils/llvm_patches/0021-Prefer-wpi-s-fs.h.patch @@ -1,17 +1,17 @@ -From c7a7fd016ae0636dcadc65705a9260f02c509495 Mon Sep 17 00:00:00 2001 +From 7943842aea1a05a1dd2c2c753378af569c24293b Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 16:49:36 -0400 -Subject: [PATCH 21/27] prefer wpi's fs.h +Subject: [PATCH 21/28] Prefer wpi's fs.h --- llvm/include/llvm/Support/raw_ostream.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index 8008170be3e5..27fb5c03e474 100644 +index bf5630ab5..256bcec25 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h -@@ -28,18 +28,15 @@ +@@ -27,18 +27,15 @@ #include #include diff --git a/upstream_utils/llvm_patches/0022-Remove-unused-functions.patch b/upstream_utils/llvm_patches/0022-Remove-unused-functions.patch index 65afc8bd86..244148e4c3 100644 --- a/upstream_utils/llvm_patches/0022-Remove-unused-functions.patch +++ b/upstream_utils/llvm_patches/0022-Remove-unused-functions.patch @@ -1,18 +1,18 @@ -From 8536e1f23d515eac3cbc0680f27aa6ab740b4796 Mon Sep 17 00:00:00 2001 +From a172c93df929ac6c9f783fd5af1e4df3604c4c66 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 19:16:51 -0400 -Subject: [PATCH 22/27] Remove unused functions +Subject: [PATCH 22/28] Remove unused functions --- llvm/include/llvm/Support/DJB.h | 3 - - llvm/include/llvm/Support/raw_ostream.h | 3 +- + llvm/include/llvm/Support/raw_ostream.h | 5 +- llvm/lib/Support/ErrorHandling.cpp | 16 ----- - llvm/lib/Support/raw_ostream.cpp | 48 +++++++-------- + llvm/lib/Support/raw_ostream.cpp | 49 +++++++-------- llvm/unittests/ADT/SmallStringTest.cpp | 81 ------------------------- - 5 files changed, 22 insertions(+), 129 deletions(-) + 5 files changed, 23 insertions(+), 131 deletions(-) diff --git a/llvm/include/llvm/Support/DJB.h b/llvm/include/llvm/Support/DJB.h -index 8737cd144c37..67b0ae91b4b1 100644 +index 8737cd144..67b0ae91b 100644 --- a/llvm/include/llvm/Support/DJB.h +++ b/llvm/include/llvm/Support/DJB.h @@ -24,9 +24,6 @@ inline uint32_t djbHash(std::string_view Buffer, uint32_t H = 5381) { @@ -26,10 +26,10 @@ index 8737cd144c37..67b0ae91b4b1 100644 #endif // LLVM_SUPPORT_DJB_H diff --git a/llvm/include/llvm/Support/raw_ostream.h b/llvm/include/llvm/Support/raw_ostream.h -index 27fb5c03e474..d228b05f4f9b 100644 +index 256bcec25..9b3a87e1b 100644 --- a/llvm/include/llvm/Support/raw_ostream.h +++ b/llvm/include/llvm/Support/raw_ostream.h -@@ -72,7 +72,6 @@ private: +@@ -71,7 +71,6 @@ private: /// for a \see write_impl() call to handle the data which has been put into /// this buffer. char *OutBufStart, *OutBufEnd, *OutBufCur; @@ -37,28 +37,31 @@ index 27fb5c03e474..d228b05f4f9b 100644 /// Optional stream this stream is tied to. If this stream is written to, the /// tied-to stream will be flushed first. -@@ -305,7 +304,7 @@ public: +@@ -304,9 +303,9 @@ public: // Enable or disable colors. Once enable_colors(false) is called, // changeColor() has no effect until enable_colors(true) is called. - virtual void enable_colors(bool enable) { ColorEnabled = enable; } + virtual void enable_colors(bool /*enable*/) {} +- bool colors_enabled() const { return ColorEnabled; } ++ bool colors_enabled() const { return false; } + /// Tie this stream to the specified stream. Replaces any existing tied-to /// stream. Specifying a nullptr unties the stream. diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp -index 9ee52a02c214..77c3a37475d0 100644 +index 8de7b726d..bc08199a1 100644 --- a/llvm/lib/Support/ErrorHandling.cpp +++ b/llvm/lib/Support/ErrorHandling.cpp @@ -178,22 +178,6 @@ void llvm::llvm_unreachable_internal(const char *msg, const char *file, #endif } --static void bindingsErrorHandler(void *user_data, const std::string& reason, +-static void bindingsErrorHandler(void *user_data, const char *reason, - bool gen_crash_diag) { - LLVMFatalErrorHandler handler = - LLVM_EXTENSION reinterpret_cast(user_data); -- handler(reason.c_str()); +- handler(reason); -} - -void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler) { @@ -74,10 +77,10 @@ index 9ee52a02c214..77c3a37475d0 100644 #include diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp -index 6b9e5f9e44bd..6fa250a68ed8 100644 +index 878a3a5e9..632b52235 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp -@@ -169,16 +169,6 @@ raw_ostream &raw_ostream::write_escaped(std::string_view Str, +@@ -167,16 +167,6 @@ raw_ostream &raw_ostream::write_escaped(std::string_view Str, return *this; } @@ -94,7 +97,7 @@ index 6b9e5f9e44bd..6fa250a68ed8 100644 void raw_ostream::flush_nonempty() { assert(OutBufCur > OutBufStart && "Invalid call to flush_nonempty."); size_t Length = OutBufCur - OutBufStart; -@@ -323,15 +313,22 @@ static int getFD(std::string_view Filename, std::error_code &EC, +@@ -321,15 +311,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. @@ -122,19 +125,21 @@ index 6b9e5f9e44bd..6fa250a68ed8 100644 if (EC) return -1; -@@ -392,10 +389,7 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered, +@@ -389,12 +386,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); - #ifdef _WIN32 -- // MSVCRT's _lseek(SEEK_CUR) doesn't return -1 for pipes. - sys::fs::file_status Status; - std::error_code EC = status(FD, Status); -- SupportsSeeking = !EC && Status.type() == sys::fs::file_type::regular_file; +- IsRegularFile = Status.type() == sys::fs::file_type::regular_file; + #ifdef _WIN32 +- // MSVCRT's _lseek(SEEK_CUR) doesn't return -1 for pipes. +- SupportsSeeking = !EC && IsRegularFile; + SupportsSeeking = loc != (off_t)-1 && ::GetFileType(reinterpret_cast(::_get_osfhandle(FD))) != FILE_TYPE_PIPE; #else - SupportsSeeking = loc != (off_t)-1; + SupportsSeeking = !EC && loc != (off_t)-1; #endif -@@ -408,10 +402,8 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered, +@@ -407,10 +400,8 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered, raw_fd_ostream::~raw_fd_ostream() { if (FD >= 0) { flush(); @@ -147,7 +152,7 @@ index 6b9e5f9e44bd..6fa250a68ed8 100644 } #ifdef __MINGW32__ -@@ -506,7 +498,11 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) { +@@ -505,7 +496,11 @@ void raw_fd_ostream::write_impl(const char *Ptr, size_t Size) { do { size_t ChunkSize = std::min(Size, MaxWriteSize); @@ -159,7 +164,7 @@ index 6b9e5f9e44bd..6fa250a68ed8 100644 if (ret < 0) { // If it's a recoverable error, swallow it and retry the write. -@@ -541,8 +537,8 @@ void raw_fd_ostream::close() { +@@ -540,8 +535,8 @@ void raw_fd_ostream::close() { assert(ShouldClose); ShouldClose = false; flush(); @@ -170,7 +175,7 @@ index 6b9e5f9e44bd..6fa250a68ed8 100644 FD = -1; } -@@ -551,8 +547,6 @@ uint64_t raw_fd_ostream::seek(uint64_t off) { +@@ -550,8 +545,6 @@ uint64_t raw_fd_ostream::seek(uint64_t off) { flush(); #ifdef _WIN32 pos = ::_lseeki64(FD, off, SEEK_SET); @@ -180,7 +185,7 @@ index 6b9e5f9e44bd..6fa250a68ed8 100644 pos = ::lseek(FD, off, SEEK_SET); #endif diff --git a/llvm/unittests/ADT/SmallStringTest.cpp b/llvm/unittests/ADT/SmallStringTest.cpp -index bee3875d11c9..87600ea4704b 100644 +index bee3875d1..87600ea47 100644 --- a/llvm/unittests/ADT/SmallStringTest.cpp +++ b/llvm/unittests/ADT/SmallStringTest.cpp @@ -129,23 +129,6 @@ TEST_F(SmallStringTest, StdStringConversion) { diff --git a/upstream_utils/llvm_patches/0023-Add-convienence-feature-to-SmallString.patch b/upstream_utils/llvm_patches/0023-Add-convienence-feature-to-SmallString.patch deleted file mode 100644 index efae39d36f..0000000000 --- a/upstream_utils/llvm_patches/0023-Add-convienence-feature-to-SmallString.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 333f987aa17d7138af8bf6e41d5749041793a721 Mon Sep 17 00:00:00 2001 -From: PJ Reiniger -Date: Mon, 9 May 2022 00:18:29 -0400 -Subject: [PATCH 23/27] Add convienence feature to SmallString - ---- - llvm/include/llvm/ADT/SmallString.h | 8 +++++--- - 1 file changed, 5 insertions(+), 3 deletions(-) - -diff --git a/llvm/include/llvm/ADT/SmallString.h b/llvm/include/llvm/ADT/SmallString.h -index 85987811f3c4..d3d469d45d15 100644 ---- a/llvm/include/llvm/ADT/SmallString.h -+++ b/llvm/include/llvm/ADT/SmallString.h -@@ -188,9 +188,11 @@ public: - /// Implicit conversion to std::string_view. - operator std::string_view() const { return str(); } - -- explicit operator std::string() const { -- return std::string(this->data(), this->size()); -- } -+ /// Explicit conversion to std::string. -+ std::string string() const { return {this->begin(), this->size()}; } -+ -+ /// Implicit conversion to std::string. -+ operator std::string() const { return string(); } - - // Extra operators. - SmallString &operator=(std::string_view RHS) { diff --git a/upstream_utils/llvm_patches/0024-OS-specific-changes.patch b/upstream_utils/llvm_patches/0023-OS-specific-changes.patch similarity index 90% rename from upstream_utils/llvm_patches/0024-OS-specific-changes.patch rename to upstream_utils/llvm_patches/0023-OS-specific-changes.patch index f433a27f92..ed58dacd75 100644 --- a/upstream_utils/llvm_patches/0024-OS-specific-changes.patch +++ b/upstream_utils/llvm_patches/0023-OS-specific-changes.patch @@ -1,14 +1,14 @@ -From 9d6e5efbd4b77747387b35a45d0c591126f7c08c Mon Sep 17 00:00:00 2001 +From ae08bb29b4d2a8ea15a4b82b909c0f4aee5e9060 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Sun, 8 May 2022 19:30:43 -0400 -Subject: [PATCH 24/27] OS specific changes +Subject: [PATCH 23/28] OS-specific changes --- llvm/lib/Support/ErrorHandling.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp -index 77c3a37475d0..f70f15f27da4 100644 +index bc08199a1..839819094 100644 --- a/llvm/lib/Support/ErrorHandling.cpp +++ b/llvm/lib/Support/ErrorHandling.cpp @@ -96,12 +96,7 @@ void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) { diff --git a/upstream_utils/llvm_patches/0025-Use-smallvector-for-UTF-conversion.patch b/upstream_utils/llvm_patches/0024-Use-SmallVector-for-UTF-conversion.patch similarity index 92% rename from upstream_utils/llvm_patches/0025-Use-smallvector-for-UTF-conversion.patch rename to upstream_utils/llvm_patches/0024-Use-SmallVector-for-UTF-conversion.patch index e26954a02a..96088d2b48 100644 --- a/upstream_utils/llvm_patches/0025-Use-smallvector-for-UTF-conversion.patch +++ b/upstream_utils/llvm_patches/0024-Use-SmallVector-for-UTF-conversion.patch @@ -1,7 +1,7 @@ -From fa16120af5f965c13bd7b75a2e591cd250fad5fa Mon Sep 17 00:00:00 2001 +From f58b9bad86f61c35cc530ff113ccbb13415261c8 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Mon, 9 May 2022 00:04:30 -0400 -Subject: [PATCH 25/27] Use smallvector for UTF conversion +Subject: [PATCH 24/28] Use SmallVector for UTF conversion --- llvm/include/llvm/Support/ConvertUTF.h | 6 +++--- @@ -10,7 +10,7 @@ Subject: [PATCH 25/27] Use smallvector for UTF conversion 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/llvm/include/llvm/Support/ConvertUTF.h b/llvm/include/llvm/Support/ConvertUTF.h -index b085c8a179e8..c82947006afb 100644 +index b085c8a17..c82947006 100644 --- a/llvm/include/llvm/Support/ConvertUTF.h +++ b/llvm/include/llvm/Support/ConvertUTF.h @@ -213,7 +213,7 @@ bool ConvertUTF8toWide(const char *Source, std::wstring &Result); @@ -41,7 +41,7 @@ index b085c8a179e8..c82947006afb 100644 /** * Converts a UTF-8 string into a UTF-16 string with native endianness. diff --git a/llvm/lib/Support/ConvertUTFWrapper.cpp b/llvm/lib/Support/ConvertUTFWrapper.cpp -index 87da616b75d4..c6c52d25adb1 100644 +index cff30f16c..d3689d92a 100644 --- a/llvm/lib/Support/ConvertUTFWrapper.cpp +++ b/llvm/lib/Support/ConvertUTFWrapper.cpp @@ -84,7 +84,7 @@ bool hasUTF16ByteOrderMark(span S) { @@ -72,7 +72,7 @@ index 87da616b75d4..c6c52d25adb1 100644 const UTF8 *Start = reinterpret_cast(Source.data()); const UTF8 *End = diff --git a/llvm/unittests/Support/ConvertUTFTest.cpp b/llvm/unittests/Support/ConvertUTFTest.cpp -index 2fee8ad5c012..bbdc041cf1d1 100644 +index 2fee8ad5c..7d7650b1c 100644 --- a/llvm/unittests/Support/ConvertUTFTest.cpp +++ b/llvm/unittests/Support/ConvertUTFTest.cpp @@ -19,22 +19,22 @@ TEST(ConvertUTFTest, ConvertUTF16LittleEndianToUTF8String) { @@ -85,7 +85,7 @@ index 2fee8ad5c012..bbdc041cf1d1 100644 EXPECT_TRUE(Success); std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0"); - EXPECT_EQ(Expected, Result); -+ EXPECT_EQ(Expected, Result.string()); ++ EXPECT_EQ(Expected, std::string{Result}); } TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) { @@ -98,7 +98,7 @@ index 2fee8ad5c012..bbdc041cf1d1 100644 EXPECT_TRUE(Success); std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0"); - EXPECT_EQ(Expected, Result); -+ EXPECT_EQ(Expected, Result.string()); ++ EXPECT_EQ(Expected, std::string{Result}); } TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) { @@ -118,7 +118,7 @@ index 2fee8ad5c012..bbdc041cf1d1 100644 bool Success = convertUTF16ToUTF8String(span(), Result); EXPECT_TRUE(Success); - EXPECT_TRUE(Result.empty()); -+ EXPECT_TRUE(Result.string().empty()); ++ EXPECT_TRUE(std::string{Result}.empty()); } TEST(ConvertUTFTest, HasUTF16BOM) { @@ -132,7 +132,7 @@ index 2fee8ad5c012..bbdc041cf1d1 100644 EXPECT_TRUE(Success); std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0"); - EXPECT_EQ(Expected, Result); -+ EXPECT_EQ(Expected, Result.string()); ++ EXPECT_EQ(Expected, std::string{Result}); } TEST(ConvertUTFTest, ConvertUTF8toWide) { @@ -146,7 +146,7 @@ index 2fee8ad5c012..bbdc041cf1d1 100644 EXPECT_TRUE(Success); std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0"); - EXPECT_EQ(Expected, Result); -+ EXPECT_EQ(Expected, Result.string()); ++ EXPECT_EQ(Expected, std::string{Result}); } struct ConvertUTFResultContainer { diff --git a/upstream_utils/llvm_patches/0026-Prefer-to-use-static-pointers-in-raw_ostream.patch b/upstream_utils/llvm_patches/0025-Prefer-to-use-static-pointers-in-raw_ostream.patch similarity index 81% rename from upstream_utils/llvm_patches/0026-Prefer-to-use-static-pointers-in-raw_ostream.patch rename to upstream_utils/llvm_patches/0025-Prefer-to-use-static-pointers-in-raw_ostream.patch index 97c3a94ca6..36a884c490 100644 --- a/upstream_utils/llvm_patches/0026-Prefer-to-use-static-pointers-in-raw_ostream.patch +++ b/upstream_utils/llvm_patches/0025-Prefer-to-use-static-pointers-in-raw_ostream.patch @@ -1,7 +1,7 @@ -From 7bdbcabd3271aebb692ef06a950d1ec59341ddf9 Mon Sep 17 00:00:00 2001 +From 35b1a8382240732065790c88a0c515701c1a2beb Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 19 May 2022 00:58:36 -0400 -Subject: [PATCH 26/27] Prefer to use static pointers in raw_ostream +Subject: [PATCH 25/28] Prefer to use static pointers in raw_ostream See #1401 --- @@ -9,10 +9,10 @@ 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 6fa250a68ed8..6be6809ad951 100644 +index 632b52235..a703a75ed 100644 --- a/llvm/lib/Support/raw_ostream.cpp +++ b/llvm/lib/Support/raw_ostream.cpp -@@ -601,15 +601,15 @@ void raw_fd_ostream::anchor() {} +@@ -599,15 +599,15 @@ void raw_fd_ostream::anchor() {} raw_fd_ostream &llvm::outs() { // Set buffer settings to model stdout behavior. std::error_code EC; diff --git a/upstream_utils/llvm_patches/0027-constexpr-endian-byte-swap.patch b/upstream_utils/llvm_patches/0026-constexpr-endian-byte-swap.patch similarity index 84% rename from upstream_utils/llvm_patches/0027-constexpr-endian-byte-swap.patch rename to upstream_utils/llvm_patches/0026-constexpr-endian-byte-swap.patch index fd06c3d548..79e0e7d43c 100644 --- a/upstream_utils/llvm_patches/0027-constexpr-endian-byte-swap.patch +++ b/upstream_utils/llvm_patches/0026-constexpr-endian-byte-swap.patch @@ -1,14 +1,14 @@ -From 34652f999acd319bb507ca4d504050ec90981e18 Mon Sep 17 00:00:00 2001 +From 34f44d312c918b3b5dd69fc689ec0b628dc712f9 Mon Sep 17 00:00:00 2001 From: PJ Reiniger Date: Thu, 19 May 2022 01:12:41 -0400 -Subject: [PATCH 27/27] constexpr endian byte swap +Subject: [PATCH 26/28] constexpr endian byte swap --- llvm/include/llvm/Support/Endian.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/Support/Endian.h b/llvm/include/llvm/Support/Endian.h -index 5e7c1e961b9d..2e883ff05b7e 100644 +index 5e7c1e961..2e883ff05 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) { diff --git a/upstream_utils/llvm_patches/0027-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch b/upstream_utils/llvm_patches/0027-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch new file mode 100644 index 0000000000..9f192a1db6 --- /dev/null +++ b/upstream_utils/llvm_patches/0027-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch @@ -0,0 +1,69 @@ +From 8f51777a3117a7b010a4cfb2ded1f5d226466f34 Mon Sep 17 00:00:00 2001 +From: Tyler Veness +Date: Wed, 10 Aug 2022 17:07:52 -0700 +Subject: [PATCH 27/28] Copy type traits from STLExtras.h into PointerUnion.h + +--- + llvm/include/llvm/ADT/PointerUnion.h | 46 ++++++++++++++++++++++++++++ + 1 file changed, 46 insertions(+) + +diff --git a/llvm/include/llvm/ADT/PointerUnion.h b/llvm/include/llvm/ADT/PointerUnion.h +index 1d4cc747c..7d090da59 100644 +--- a/llvm/include/llvm/ADT/PointerUnion.h ++++ b/llvm/include/llvm/ADT/PointerUnion.h +@@ -22,9 +22,55 @@ + #include + #include + #include ++#include + + namespace llvm { + ++namespace detail { ++template struct TypesAreDistinct; ++template ++struct TypesAreDistinct ++ : std::integral_constant...> && ++ TypesAreDistinct::value> {}; ++template struct TypesAreDistinct : std::true_type {}; ++} // namespace detail ++ ++/// Determine if all types in Ts are distinct. ++/// ++/// Useful to statically assert when Ts is intended to describe a non-multi set ++/// of types. ++/// ++/// Expensive (currently quadratic in sizeof(Ts...)), and so should only be ++/// asserted once per instantiation of a type which requires it. ++template struct TypesAreDistinct; ++template <> struct TypesAreDistinct<> : std::true_type {}; ++template ++struct TypesAreDistinct ++ : std::integral_constant::value> {}; ++ ++/// Find the first index where a type appears in a list of types. ++/// ++/// FirstIndexOfType::value is the first index of T in Us. ++/// ++/// Typically only meaningful when it is otherwise statically known that the ++/// type pack has no duplicate types. This should be guaranteed explicitly with ++/// static_assert(TypesAreDistinct::value). ++/// ++/// It is a compile-time error to instantiate when T is not present in Us, i.e. ++/// if is_one_of::value is false. ++template struct FirstIndexOfType; ++template ++struct FirstIndexOfType ++ : std::integral_constant::value> {}; ++template ++struct FirstIndexOfType : std::integral_constant {}; ++ ++/// Find the type at a given index in a list of types. ++/// ++/// TypeAtIndex is the type at index I in Ts. ++template ++using TypeAtIndex = std::tuple_element_t>; ++ + namespace pointer_union_detail { + /// Determine the number of bits required to store integers with values < n. + /// This is ceil(log2(n)). diff --git a/upstream_utils/llvm_patches/0028-Remove-StringMap-test-for-llvm-sort.patch b/upstream_utils/llvm_patches/0028-Remove-StringMap-test-for-llvm-sort.patch new file mode 100644 index 0000000000..5c847e1874 --- /dev/null +++ b/upstream_utils/llvm_patches/0028-Remove-StringMap-test-for-llvm-sort.patch @@ -0,0 +1,34 @@ +From 498e56e09e8f264978831519ff9c8afa701bf208 Mon Sep 17 00:00:00 2001 +From: Tyler Veness +Date: Wed, 10 Aug 2022 22:35:00 -0700 +Subject: [PATCH 28/28] Remove StringMap test for llvm::sort() + +--- + llvm/unittests/ADT/StringMapTest.cpp | 14 -------------- + 1 file changed, 14 deletions(-) + +diff --git a/llvm/unittests/ADT/StringMapTest.cpp b/llvm/unittests/ADT/StringMapTest.cpp +index de6daf3da..ca41631cc 100644 +--- a/llvm/unittests/ADT/StringMapTest.cpp ++++ b/llvm/unittests/ADT/StringMapTest.cpp +@@ -308,20 +308,6 @@ TEST_F(StringMapTest, InsertOrAssignTest) { + EXPECT_EQ(0, try1.first->second.copy); + } + +-TEST_F(StringMapTest, IterMapKeysVector) { +- StringMap Map; +- Map["A"] = 1; +- Map["B"] = 2; +- Map["C"] = 3; +- Map["D"] = 3; +- +- std::vector Keys{Map.keys().begin(), Map.keys().end()}; +- llvm::sort(Keys); +- +- std::vector Expected{{"A", "B", "C", "D"}}; +- EXPECT_EQ(Expected, Keys); +-} +- + TEST_F(StringMapTest, IterMapKeysSmallVector) { + StringMap Map; + Map["A"] = 1; diff --git a/upstream_utils/update_llvm.py b/upstream_utils/update_llvm.py index 675d3fe785..8d5346b26b 100755 --- a/upstream_utils/update_llvm.py +++ b/upstream_utils/update_llvm.py @@ -155,7 +155,7 @@ def overwrite_tests(wpiutil_root, llvm_root): def main(): root, repo = setup_upstream_repo( - "https://github.com/llvm/llvm-project", "llvmorg-13.0.0" + "https://github.com/llvm/llvm-project", "llvmorg-14.0.6" ) wpiutil = os.path.join(root, "wpiutil") @@ -164,31 +164,32 @@ def main(): frontend_patches = [ os.path.join(patch_root, "0001-Fix-spelling-language-errors.patch"), os.path.join(patch_root, "0002-Remove-StringRef-ArrayRef-and-Optional.patch"), - os.path.join(patch_root, "0003-Wrap-std-min-max-calls-in-parens-for-windows-warning.patch"), - os.path.join(patch_root, "0004-Change-uniqe_function-storage-size.patch"), + os.path.join(patch_root, "0003-Wrap-std-min-max-calls-in-parens-for-Windows-warning.patch"), + os.path.join(patch_root, "0004-Change-unique_function-storage-size.patch"), os.path.join(patch_root, "0005-Threading-updates.patch"), os.path.join(patch_root, "0006-ifdef-guard-safety.patch"), os.path.join(patch_root, "0007-Explicitly-use-std.patch"), os.path.join(patch_root, "0008-Remove-format_provider.patch"), - os.path.join(patch_root, "0009-Add-compiler-warning-pragrams.patch"), + os.path.join(patch_root, "0009-Add-compiler-warning-pragmas.patch"), os.path.join(patch_root, "0010-Remove-unused-functions.patch"), - os.path.join(patch_root, "0011-Detemplatize-small-vector-base.patch"), + os.path.join(patch_root, "0011-Detemplatize-SmallVectorBase.patch"), os.path.join(patch_root, "0012-Add-vectors-to-raw_ostream.patch"), os.path.join(patch_root, "0013-Extra-collections-features.patch"), - os.path.join(patch_root, "0014-EpochTracker-abi-macro.patch"), - os.path.join(patch_root, "0015-Delete-numbers-from-mathextras.patch"), + os.path.join(patch_root, "0014-EpochTracker-ABI-macro.patch"), + os.path.join(patch_root, "0015-Delete-numbers-from-MathExtras.patch"), os.path.join(patch_root, "0016-Add-lerp-and-sgn.patch"), os.path.join(patch_root, "0017-Fixup-includes.patch"), - os.path.join(patch_root, "0018-use-std-is_trivially_copy_constructible.patch"), - os.path.join(patch_root, "0019-Windows-Support.patch"), + os.path.join(patch_root, "0018-Use-std-is_trivially_copy_constructible.patch"), + os.path.join(patch_root, "0019-Windows-support.patch"), os.path.join(patch_root, "0020-Prefer-fmtlib.patch"), - os.path.join(patch_root, "0021-prefer-wpi-s-fs.h.patch"), + os.path.join(patch_root, "0021-Prefer-wpi-s-fs.h.patch"), os.path.join(patch_root, "0022-Remove-unused-functions.patch"), - os.path.join(patch_root, "0023-Add-convienence-feature-to-SmallString.patch"), - os.path.join(patch_root, "0024-OS-specific-changes.patch"), - os.path.join(patch_root, "0025-Use-smallvector-for-UTF-conversion.patch"), - os.path.join(patch_root, "0026-Prefer-to-use-static-pointers-in-raw_ostream.patch"), - os.path.join(patch_root, "0027-constexpr-endian-byte-swap.patch"), + os.path.join(patch_root, "0023-OS-specific-changes.patch"), + os.path.join(patch_root, "0024-Use-SmallVector-for-UTF-conversion.patch"), + os.path.join(patch_root, "0025-Prefer-to-use-static-pointers-in-raw_ostream.patch"), + os.path.join(patch_root, "0026-constexpr-endian-byte-swap.patch"), + os.path.join(patch_root, "0027-Copy-type-traits-from-STLExtras.h-into-PointerUnion..patch"), + os.path.join(patch_root, "0028-Remove-StringMap-test-for-llvm-sort.patch"), ] # yapf: enable diff --git a/wpinet/src/main/native/linux/MulticastServiceResolver.cpp b/wpinet/src/main/native/linux/MulticastServiceResolver.cpp index 4331ea46da..a408639138 100644 --- a/wpinet/src/main/native/linux/MulticastServiceResolver.cpp +++ b/wpinet/src/main/native/linux/MulticastServiceResolver.cpp @@ -82,7 +82,7 @@ static void ResolveCallback(AvahiServiceResolver* r, AvahiIfIndex interface, data.ipv4Address = address->data.ipv4.address; data.port = port; data.serviceName = name; - data.hostName = outputHostName.string(); + data.hostName = std::string{outputHostName}; impl->onFound(std::move(data)); } diff --git a/wpinet/src/main/native/windows/MulticastServiceResolver.cpp b/wpinet/src/main/native/windows/MulticastServiceResolver.cpp index 8bc7dbbeb5..a3d45c5332 100644 --- a/wpinet/src/main/native/windows/MulticastServiceResolver.cpp +++ b/wpinet/src/main/native/windows/MulticastServiceResolver.cpp @@ -132,15 +132,16 @@ static _Function_class_(DNS_QUERY_COMPLETION_ROUTINE) VOID WINAPI reinterpret_cast(wideView.data()), splitIndex}; wpi::convertUTF16ToUTF8String(wideStr, storage); - auto& pair = data.txt.emplace_back( - std::pair{storage.string(), {}}); + auto& pair = + data.txt.emplace_back(std::pair{ + std::string{storage}, {}}); storage.clear(); wideStr = wpi::span{ reinterpret_cast(wideView.data() + splitIndex + 1), wideView.size() - splitIndex - 1}; wpi::convertUTF16ToUTF8String(wideStr, storage); - pair.second = storage.string(); + pair.second = std::string{storage}; } } } @@ -151,7 +152,7 @@ static _Function_class_(DNS_QUERY_COMPLETION_ROUTINE) VOID WINAPI wpi::convertUTF16ToUTF8String(wideHostName, storage); storage.append("."); - data.hostName = storage.string(); + data.hostName = std::string{storage}; storage.clear(); int len = nameHost.find(impl->serviceType.c_str()); @@ -163,7 +164,7 @@ static _Function_class_(DNS_QUERY_COMPLETION_ROUTINE) VOID WINAPI } wpi::convertUTF16ToUTF8String(wideServiceName, storage); - data.serviceName = storage.string(); + data.serviceName = std::string{storage}; data.port = foundSrv->Data.Srv.wPort; data.ipv4Address = A->Data.A.IpAddress; diff --git a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ConvertUTF.cpp b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ConvertUTF.cpp index 81c0c04dd7..dbf41ab206 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ConvertUTF.cpp +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ConvertUTF.cpp @@ -754,7 +754,7 @@ std::error_code CodePageToUTF16(unsigned codepage, } utf16.reserve(len + 1); - utf16.set_size(len); + utf16.resize_for_overwrite(len); len = ::MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, original.data(), original.size(), utf16.begin(), utf16.size()); @@ -795,7 +795,7 @@ std::error_code UTF16ToCodePage(unsigned codepage, const wchar_t *utf16, } converted.reserve(len); - converted.set_size(len); + converted.resize_for_overwrite(len); // Now do the actual conversion. len = ::WideCharToMultiByte(codepage, 0, utf16, utf16_len, converted.data(), diff --git a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ConvertUTFWrapper.cpp b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ConvertUTFWrapper.cpp index 53cf117512..09a9826461 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ConvertUTFWrapper.cpp +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ConvertUTFWrapper.cpp @@ -104,8 +104,8 @@ bool convertUTF16ToUTF8String(span SrcBytes, SmallVectorImpl & std::vector ByteSwapped; if (Src[0] == UNI_UTF16_BYTE_ORDER_MARK_SWAPPED) { ByteSwapped.insert(ByteSwapped.end(), Src, SrcEnd); - for (unsigned I = 0, E = ByteSwapped.size(); I != E; ++I) - ByteSwapped[I] = wpi::ByteSwap_16(ByteSwapped[I]); + for (UTF16 &I : ByteSwapped) + I = wpi::ByteSwap_16(I); Src = &ByteSwapped[0]; SrcEnd = &ByteSwapped[ByteSwapped.size() - 1] + 1; } diff --git a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ErrorHandling.cpp b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ErrorHandling.cpp index 32926273dc..6dd72db80e 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ErrorHandling.cpp +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/ErrorHandling.cpp @@ -84,7 +84,7 @@ void wpi::report_fatal_error(std::string_view Reason, bool GenCrashDiag) { } if (handler) { - handler(handlerData, std::string{Reason}, GenCrashDiag); + handler(handlerData, std::string{Reason}.c_str(), GenCrashDiag); } else { fmt::print(stderr, "LLVM ERROR: {}\n", Reason); } @@ -185,7 +185,10 @@ std::error_code wpi::mapWindowsError(unsigned EV) { switch (EV) { MAP_ERR_TO_COND(ERROR_ACCESS_DENIED, permission_denied); MAP_ERR_TO_COND(ERROR_ALREADY_EXISTS, file_exists); + MAP_ERR_TO_COND(ERROR_BAD_NETPATH, no_such_file_or_directory); + MAP_ERR_TO_COND(ERROR_BAD_PATHNAME, no_such_file_or_directory); MAP_ERR_TO_COND(ERROR_BAD_UNIT, no_such_device); + MAP_ERR_TO_COND(ERROR_BROKEN_PIPE, broken_pipe); MAP_ERR_TO_COND(ERROR_BUFFER_OVERFLOW, filename_too_long); MAP_ERR_TO_COND(ERROR_BUSY, device_or_resource_busy); MAP_ERR_TO_COND(ERROR_BUSY_DRIVE, device_or_resource_busy); @@ -207,18 +210,20 @@ std::error_code wpi::mapWindowsError(unsigned EV) { MAP_ERR_TO_COND(ERROR_INVALID_FUNCTION, function_not_supported); MAP_ERR_TO_COND(ERROR_INVALID_HANDLE, invalid_argument); MAP_ERR_TO_COND(ERROR_INVALID_NAME, invalid_argument); + MAP_ERR_TO_COND(ERROR_INVALID_PARAMETER, invalid_argument); MAP_ERR_TO_COND(ERROR_LOCK_VIOLATION, no_lock_available); MAP_ERR_TO_COND(ERROR_LOCKED, no_lock_available); MAP_ERR_TO_COND(ERROR_NEGATIVE_SEEK, invalid_argument); MAP_ERR_TO_COND(ERROR_NOACCESS, permission_denied); MAP_ERR_TO_COND(ERROR_NOT_ENOUGH_MEMORY, not_enough_memory); MAP_ERR_TO_COND(ERROR_NOT_READY, resource_unavailable_try_again); + MAP_ERR_TO_COND(ERROR_NOT_SUPPORTED, not_supported); MAP_ERR_TO_COND(ERROR_OPEN_FAILED, io_error); MAP_ERR_TO_COND(ERROR_OPEN_FILES, device_or_resource_busy); MAP_ERR_TO_COND(ERROR_OUTOFMEMORY, not_enough_memory); MAP_ERR_TO_COND(ERROR_PATH_NOT_FOUND, no_such_file_or_directory); - MAP_ERR_TO_COND(ERROR_BAD_NETPATH, no_such_file_or_directory); MAP_ERR_TO_COND(ERROR_READ_FAULT, io_error); + MAP_ERR_TO_COND(ERROR_REPARSE_TAG_INVALID, invalid_argument); MAP_ERR_TO_COND(ERROR_RETRY, resource_unavailable_try_again); MAP_ERR_TO_COND(ERROR_SEEK, io_error); MAP_ERR_TO_COND(ERROR_SHARING_VIOLATION, permission_denied); diff --git a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/MemAlloc.cpp b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/MemAlloc.cpp index 9a36c23fd9..e2c662cf0e 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/MemAlloc.cpp +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/MemAlloc.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "wpi/MemAlloc.h" +#include // These are out of line to have __cpp_aligned_new not affect ABI. diff --git a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/MemoryBuffer.cpp b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/MemoryBuffer.cpp index 6b9e19bdd9..a1adadb200 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/MemoryBuffer.cpp +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/MemoryBuffer.cpp @@ -237,7 +237,7 @@ static std::unique_ptr GetMemoryBufferForStream( #endif // Read into Buffer until we hit EOF. do { - buffer.reserve(buffer.size() + ChunkSize); + buffer.resize_for_overwrite(buffer.size() + ChunkSize); #ifdef _WIN32 if (!ReadFile(f, buffer.end(), ChunkSize, &readBytes, nullptr)) { ec = mapWindowsError(GetLastError()); @@ -250,7 +250,6 @@ static std::unique_ptr GetMemoryBufferForStream( return nullptr; } #endif - buffer.set_size(buffer.size() + readBytes); } while (readBytes != 0); return GetMemBufferCopyImpl(buffer, bufferName, ec); diff --git a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/SmallPtrSet.cpp b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/SmallPtrSet.cpp index e25882621a..f3567280a7 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/SmallPtrSet.cpp +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/SmallPtrSet.cpp @@ -13,7 +13,6 @@ #include "wpi/SmallPtrSet.h" #include "wpi/DenseMapInfo.h" -#include "wpi/ErrorHandling.h" #include "wpi/MathExtras.h" #include "wpi/MemAlloc.h" #include 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 20528094b7..04f4e06b28 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/SmallVector.cpp +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/SmallVector.cpp @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "wpi/SmallVector.h" +#include "wpi/MemAlloc.h" #include #ifdef LLVM_ENABLE_EXCEPTIONS #include @@ -19,12 +20,21 @@ using namespace wpi; // Check that no bytes are wasted and everything is well-aligned. namespace { +// These structures may cause binary compat warnings on AIX. Suppress the +// warning since we are only using these types for the static assertions below. +#if defined(_AIX) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Waix-compat" +#endif struct Struct16B { alignas(16) void *X; }; struct Struct32B { alignas(32) void *X; }; +#if defined(_AIX) +#pragma GCC diagnostic pop +#endif } static_assert(sizeof(SmallVector) == sizeof(unsigned) * 2 + sizeof(void *), @@ -43,8 +53,7 @@ static_assert(sizeof(SmallVector) == /// Report that MinSize doesn't fit into this vector's size type. Throws /// std::length_error or calls report_fatal_error. -LLVM_ATTRIBUTE_NORETURN -static void report_size_overflow(size_t MinSize, size_t MaxSize); +[[noreturn]] static void report_size_overflow(size_t MinSize, size_t MaxSize); static void report_size_overflow(size_t MinSize, size_t MaxSize) { std::string Reason = "SmallVector unable to grow. Requested capacity (" + std::to_string(MinSize) + @@ -59,7 +68,7 @@ static void report_size_overflow(size_t MinSize, size_t MaxSize) { /// Report that this vector is already at maximum capacity. Throws /// std::length_error or calls report_fatal_error. -LLVM_ATTRIBUTE_NORETURN static void report_at_maximum_capacity(size_t MaxSize); +[[noreturn]] static void report_at_maximum_capacity(size_t MaxSize); static void report_at_maximum_capacity(size_t MaxSize) { std::string Reason = "SmallVector capacity unable to grow. Already at maximum size " + diff --git a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/StringMap.cpp b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/StringMap.cpp index 98a9309beb..2405f2f9ef 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/StringMap.cpp +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/StringMap.cpp @@ -11,7 +11,6 @@ //===----------------------------------------------------------------------===// #include "wpi/StringMap.h" -#include "wpi/StringExtras.h" #include "wpi/DJB.h" #include "wpi/MathExtras.h" diff --git a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/Windows/WindowsSupport.h b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/Windows/WindowsSupport.h index 167571210c..01200e22a0 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/Windows/WindowsSupport.h +++ b/wpiutil/src/main/native/thirdparty/llvm/cpp/llvm/Windows/WindowsSupport.h @@ -92,7 +92,7 @@ wpi::VersionTuple GetWindowsOSVersion(); bool MakeErrMsg(std::string *ErrMsg, const std::string &prefix); // Include GetLastError() in a fatal error message. -LLVM_ATTRIBUTE_NORETURN inline void ReportLastErrorFatal(const char *Msg) { +[[noreturn]] inline void ReportLastErrorFatal(const char *Msg) { std::string ErrMsg; MakeErrMsg(&ErrMsg, Msg); wpi::report_fatal_error(ErrMsg); 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 f6e0e8415d..a2d586bad6 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 @@ -23,10 +23,8 @@ #include "wpi/fs.h" #include "wpi/MathExtras.h" #include -#include #include #include -#include #include // may provide O_BINARY. @@ -148,7 +146,7 @@ raw_ostream &raw_ostream::write_escaped(std::string_view Str, // Write out the escaped representation. if (UseHexEscapes) { *this << '\\' << 'x'; - *this << hexdigit((c >> 4 & 0xF)); + *this << hexdigit((c >> 4) & 0xF); *this << hexdigit((c >> 0) & 0xF); } else { // Always use a full 3-character octal escape. @@ -385,7 +383,7 @@ raw_fd_ostream::raw_fd_ostream(int fd, bool shouldClose, bool unbuffered, #ifdef _WIN32 SupportsSeeking = loc != (off_t)-1 && ::GetFileType(reinterpret_cast(::_get_osfhandle(FD))) != FILE_TYPE_PIPE; #else - SupportsSeeking = loc != (off_t)-1; + SupportsSeeking = !EC && loc != (off_t)-1; #endif if (!SupportsSeeking) pos = 0; @@ -624,8 +622,7 @@ raw_fd_stream::raw_fd_stream(std::string_view Filename, std::error_code &EC) if (EC) return; - // Do not support non-seekable files. - if (!supportsSeeking()) + if (!isRegularFile()) EC = std::make_error_code(std::errc::invalid_argument); } @@ -637,10 +634,6 @@ bool raw_fd_stream::classof(const raw_ostream *OS) { // raw_string_ostream //===----------------------------------------------------------------------===// -raw_string_ostream::~raw_string_ostream() { - flush(); -} - void raw_string_ostream::write_impl(const char *Ptr, size_t Size) { OS.append(Ptr, Size); } diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AllocatorBase.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AllocatorBase.h index 10fef55743..29ba16f167 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AllocatorBase.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/AllocatorBase.h @@ -21,6 +21,7 @@ #include "wpi/Compiler.h" #include "wpi/MemAlloc.h" +#include namespace wpi { 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 5557809765..221f6dc19b 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Chrono.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Chrono.h @@ -13,6 +13,7 @@ #include #include +#include namespace wpi { @@ -22,12 +23,12 @@ namespace sys { /// A time point on the system clock. This is provided for two reasons: /// - to insulate us against subtle differences in behavior to differences in -/// system clock precision (which is implementation-defined and differs between -/// platforms). +/// system clock precision (which is implementation-defined and differs +/// between platforms). /// - to shorten the type name -/// The default precision is nanoseconds. If need a specific precision specify -/// it explicitly. If unsure, use the default. If you need a time point on a -/// clock other than the system_clock, use std::chrono directly. +/// The default precision is nanoseconds. If you need a specific precision +/// specify it explicitly. If unsure, use the default. If you need a time point +/// on a clock other than the system_clock, use std::chrono directly. template using TimePoint = std::chrono::time_point; 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 e393e61689..c98386e0f1 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Compiler.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Compiler.h @@ -16,9 +16,6 @@ #define WPIUTIL_WPI_COMPILER_H -#ifdef __cplusplus -#include -#endif #include #if defined(_MSC_VER) @@ -79,13 +76,24 @@ /// * 1916: VS2017, version 15.9 /// * 1920: VS2019, version 16.0 /// * 1921: VS2019, version 16.1 +/// * 1922: VS2019, version 16.2 +/// * 1923: VS2019, version 16.3 +/// * 1924: VS2019, version 16.4 +/// * 1925: VS2019, version 16.5 +/// * 1926: VS2019, version 16.6 +/// * 1927: VS2019, version 16.7 +/// * 1928: VS2019, version 16.8 + 16.9 +/// * 1929: VS2019, version 16.10 + 16.11 +/// * 1930: VS2022, version 17.0 #ifndef LLVM_MSC_PREREQ #ifdef _MSC_VER #define LLVM_MSC_PREREQ(version) (_MSC_VER >= (version)) -// We require at least MSVC 2017. -#if !LLVM_MSC_PREREQ(1910) -#error LLVM requires at least MSVC 2017. +// We require at least VS 2019. +#if !defined(LLVM_FORCE_USE_OLD_TOOLCHAIN) +#if !LLVM_MSC_PREREQ(1920) +#error LLVM requires at least VS 2019. +#endif #endif #else @@ -98,14 +106,8 @@ /// Sadly, this is separate from just rvalue reference support because GCC /// and MSVC implemented this later than everything else. This appears to be /// corrected in MSVC 2019 but not MSVC 2017. -#ifndef LLVM_HAS_RVALUE_REFERENCE_THIS -#if __has_feature(cxx_rvalue_references) || LLVM_GNUC_PREREQ(4, 8, 1) || \ - LLVM_MSC_PREREQ(1920) +/// FIXME: Remove LLVM_HAS_RVALUE_REFERENCE_THIS macro #define LLVM_HAS_RVALUE_REFERENCE_THIS 1 -#else -#define LLVM_HAS_RVALUE_REFERENCE_THIS 0 -#endif -#endif /// Expands to '&' if ref-qualifiers for *this are supported. /// @@ -128,10 +130,14 @@ /// LLVM_EXTERNAL_VISIBILITY - classes, functions, and variables marked with /// this attribute will be made public and visible outside of any shared library /// they are linked in to. -#if (__has_attribute(visibility) || LLVM_GNUC_PREREQ(4, 0, 0)) && \ - !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32) +#if __has_attribute(visibility) && !defined(__MINGW32__) && \ + !defined(__CYGWIN__) && !defined(_WIN32) #define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden"))) -#define LLVM_EXTERNAL_VISIBILITY __attribute__ ((visibility("default"))) +#if defined(LLVM_BUILD_LLVM_DYLIB) || defined(LLVM_BUILD_SHARED_LIBS) +#define LLVM_EXTERNAL_VISIBILITY __attribute__((visibility("default"))) +#else +#define LLVM_EXTERNAL_VISIBILITY +#endif #else #define LLVM_LIBRARY_VISIBILITY #define LLVM_EXTERNAL_VISIBILITY @@ -146,7 +152,7 @@ #endif #ifndef LLVM_ATTRIBUTE_USED -#if __has_attribute(used) || LLVM_GNUC_PREREQ(3, 1, 0) +#if __has_attribute(used) #define LLVM_ATTRIBUTE_USED __attribute__((__used__)) #else #define LLVM_ATTRIBUTE_USED @@ -194,7 +200,7 @@ // (void)unused_var_name; // Prefer cast-to-void wherever it is sufficient. #ifndef LLVM_ATTRIBUTE_UNUSED -#if __has_attribute(unused) || LLVM_GNUC_PREREQ(3, 1, 0) +#if __has_attribute(unused) #define LLVM_ATTRIBUTE_UNUSED __attribute__((__unused__)) #else #define LLVM_ATTRIBUTE_UNUSED @@ -202,8 +208,8 @@ #endif // FIXME: Provide this for PE/COFF targets. -#if (__has_attribute(weak) || LLVM_GNUC_PREREQ(4, 0, 0)) && \ - (!defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32)) +#if __has_attribute(weak) && !defined(__MINGW32__) && !defined(__CYGWIN__) && \ + !defined(_WIN32) #define LLVM_ATTRIBUTE_WEAK __attribute__((__weak__)) #else #define LLVM_ATTRIBUTE_WEAK @@ -229,8 +235,14 @@ #endif #endif +#if __has_attribute(minsize) +#define LLVM_ATTRIBUTE_MINSIZE __attribute__((minsize)) +#else +#define LLVM_ATTRIBUTE_MINSIZE +#endif + #ifndef LLVM_LIKELY -#if __has_builtin(__builtin_expect) || LLVM_GNUC_PREREQ(4, 0, 0) +#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) #else @@ -242,7 +254,7 @@ /// LLVM_ATTRIBUTE_NOINLINE - On compilers where we have a directive to do so, /// mark a method "not for inlining". #ifndef LLVM_ATTRIBUTE_NOINLINE -#if __has_attribute(noinline) || LLVM_GNUC_PREREQ(3, 4, 0) +#if __has_attribute(noinline) #define LLVM_ATTRIBUTE_NOINLINE __attribute__((noinline)) #elif defined(_MSC_VER) #define LLVM_ATTRIBUTE_NOINLINE __declspec(noinline) @@ -252,11 +264,9 @@ #endif /// LLVM_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do -/// so, mark a method "always inline" because it is performance sensitive. GCC -/// 3.4 supported this but is buggy in various cases and produces unimplemented -/// errors, just use it in GCC 4.0 and later. +/// so, mark a method "always inline" because it is performance sensitive. #ifndef LLVM_ATTRIBUTE_ALWAYS_INLINE -#if __has_attribute(always_inline) || LLVM_GNUC_PREREQ(4, 0, 0) +#if __has_attribute(always_inline) #define LLVM_ATTRIBUTE_ALWAYS_INLINE inline __attribute__((always_inline)) #elif defined(_MSC_VER) #define LLVM_ATTRIBUTE_ALWAYS_INLINE __forceinline @@ -265,18 +275,17 @@ #endif #endif -#ifndef LLVM_ATTRIBUTE_NORETURN -#ifdef __GNUC__ -#define LLVM_ATTRIBUTE_NORETURN __attribute__((noreturn)) -#elif defined(_MSC_VER) -#define LLVM_ATTRIBUTE_NORETURN __declspec(noreturn) +/// 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 +/// experience worse. +#if __has_attribute(nodebug) +#define LLVM_ATTRIBUTE_NODEBUG __attribute__((nodebug)) #else -#define LLVM_ATTRIBUTE_NORETURN -#endif +#define LLVM_ATTRIBUTE_NODEBUG #endif #ifndef LLVM_ATTRIBUTE_RETURNS_NONNULL -#if __has_attribute(returns_nonnull) || LLVM_GNUC_PREREQ(4, 9, 0) +#if __has_attribute(returns_nonnull) #define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) #elif defined(_MSC_VER) #define LLVM_ATTRIBUTE_RETURNS_NONNULL _Ret_notnull_ @@ -358,17 +367,19 @@ /// to an expression which states that it is undefined behavior for the /// compiler to reach this point. Otherwise is not defined. #ifndef LLVM_BUILTIN_UNREACHABLE -#if __has_builtin(__builtin_unreachable) || LLVM_GNUC_PREREQ(4, 5, 0) +#if __has_builtin(__builtin_unreachable) || defined(__GNUC__) # define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable() #elif defined(_MSC_VER) # define LLVM_BUILTIN_UNREACHABLE __assume(false) +#else +# define LLVM_BUILTIN_UNREACHABLE #endif #endif /// LLVM_BUILTIN_TRAP - On compilers which support it, expands to an expression /// which causes the program to exit abnormally. #ifndef LLVM_BUILTIN_TRAP -#if __has_builtin(__builtin_trap) || LLVM_GNUC_PREREQ(4, 3, 0) +#if __has_builtin(__builtin_trap) || defined(__GNUC__) # define LLVM_BUILTIN_TRAP __builtin_trap() #elif defined(_MSC_VER) // The __debugbreak intrinsic is supported by MSVC, does not require forward @@ -403,7 +414,7 @@ /// \macro LLVM_ASSUME_ALIGNED /// Returns a pointer with an assumed alignment. #ifndef LLVM_ASSUME_ALIGNED -#if __has_builtin(__builtin_assume_aligned) || LLVM_GNUC_PREREQ(4, 7, 0) +#if __has_builtin(__builtin_assume_aligned) || defined(__GNUC__) # define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a) #elif defined(LLVM_BUILTIN_UNREACHABLE) # define LLVM_ASSUME_ALIGNED(p, a) \ @@ -596,4 +607,13 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); #define LLVM_ENABLE_EXCEPTIONS 1 #endif +/// \macro LLVM_NO_PROFILE_INSTRUMENT_FUNCTION +/// Disable the profile instrument for a function. +#if __has_attribute(no_profile_instrument_function) +#define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION \ + __attribute__((no_profile_instrument_function)) +#else +#define LLVM_NO_PROFILE_INSTRUMENT_FUNCTION +#endif + #endif diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMap.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMap.h index 2158f8a8b7..b1ffd436cb 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMap.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMap.h @@ -5,9 +5,10 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file defines the DenseMap class. -// +/// +/// \file +/// This file defines the DenseMap class. +/// //===----------------------------------------------------------------------===// #ifndef WPIUTIL_WPI_DENSEMAP_H diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMapInfo.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMapInfo.h index 54b2c2cb3f..0ff8fc9e22 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMapInfo.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/DenseMapInfo.h @@ -5,18 +5,19 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file defines DenseMapInfo traits for DenseMap. -// +/// +/// \file +/// This file defines DenseMapInfo traits for DenseMap. +/// //===----------------------------------------------------------------------===// #ifndef WPIUTIL_WPI_DENSEMAPINFO_H #define WPIUTIL_WPI_DENSEMAPINFO_H -#include "wpi/Hashing.h" #include #include #include +#include #include namespace wpi { @@ -39,7 +40,12 @@ static inline unsigned combineHashValue(unsigned a, unsigned b) { } // end namespace detail -template +/// An information struct used to provide DenseMap with the various necessary +/// components for a given value type `T`. `Enable` is an optional additional +/// parameter that is used to support SFINAE (generally using std::enable_if_t) +/// in derived DenseMapInfo specializations; in non-SFINAE use cases this should +/// just be `void`. +template struct DenseMapInfo { //static inline T getEmptyKey(); //static inline T getTombstoneKey(); @@ -282,13 +288,6 @@ template struct DenseMapInfo> { } }; -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 static_cast(val); } - static bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; } -}; - } // end namespace wpi #endif // WPIUTIL_WPI_DENSEMAPINFO_H diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/EpochTracker.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/EpochTracker.h index 4a84822468..6417c05d71 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/EpochTracker.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/EpochTracker.h @@ -5,11 +5,12 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file defines the DebugEpochBase and DebugEpochBase::HandleBase classes. -// These can be used to write iterators that are fail-fast when LLVM is built -// with asserts enabled. -// +/// +/// \file +/// This file defines the DebugEpochBase and DebugEpochBase::HandleBase classes. +/// These can be used to write iterators that are fail-fast when LLVM is built +/// with asserts enabled. +/// //===----------------------------------------------------------------------===// #ifndef WPIUTIL_WPI_EPOCHTRACKER_H diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ErrorHandling.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ErrorHandling.h index 90d87d9472..7b4367103d 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ErrorHandling.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/ErrorHandling.h @@ -22,7 +22,7 @@ namespace wpi { /// An error handler callback. typedef void (*fatal_error_handler_t)(void *user_data, - const std::string& reason, + const char *reason, bool gen_crash_diag); /// install_fatal_error_handler - Installs a new error handler to be used @@ -67,12 +67,12 @@ namespace wpi { /// standard error, followed by a newline. /// After the error handler is called this function will call abort(), it /// does not return. -LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, - bool gen_crash_diag = true); -LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const std::string &reason, - bool gen_crash_diag = true); -LLVM_ATTRIBUTE_NORETURN void report_fatal_error(std::string_view reason, - bool gen_crash_diag = true); +[[noreturn]] void report_fatal_error(const char *reason, + bool gen_crash_diag = true); +[[noreturn]] void report_fatal_error(const std::string &reason, + bool gen_crash_diag = true); +[[noreturn]] void report_fatal_error(std::string_view reason, + bool gen_crash_diag = true); /// Installs a new bad alloc error handler that should be used whenever a /// bad alloc error, e.g. failing malloc/calloc, is encountered by LLVM. @@ -110,13 +110,13 @@ void install_out_of_memory_new_handler(); /// If no error handler is installed (default), throws a bad_alloc exception /// if LLVM is compiled with exception support. Otherwise prints the error /// to standard error and calls abort(). -LLVM_ATTRIBUTE_NORETURN void report_bad_alloc_error(const char *Reason, - bool GenCrashDiag = true); +[[noreturn]] void report_bad_alloc_error(const char *Reason, + bool GenCrashDiag = true); /// This function calls abort(), and prints the optional message to stderr. /// Use the wpi_unreachable macro (that adds location info), instead of /// calling this function directly. -LLVM_ATTRIBUTE_NORETURN void +[[noreturn]] void wpi_unreachable_internal(const char *msg = nullptr, const char *file = nullptr, unsigned line = 0); } 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 ce80ee2388..681b87e888 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/FunctionExtras.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/FunctionExtras.h @@ -37,6 +37,7 @@ #include "wpi/STLForwardCompat.h" #include "wpi/MemAlloc.h" #include "wpi/type_traits.h" +#include #include #include @@ -57,6 +58,7 @@ template class unique_function; // GCC warns on OutOfLineStorage #if defined(__GNUC__) && !defined(__clang__) #pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Warray-bounds" #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif @@ -70,11 +72,16 @@ template using EnableUnlessSameType = std::enable_if_t, ThisT>::value>; template -using EnableIfCallable = - std::enable_if_t::value || - std::is_convertible()( - std::declval()...)), - Ret>::value>; +using EnableIfCallable = std::enable_if_t, + std::is_same()(std::declval()...)), + Ret>, + std::is_same()( + std::declval()...)), + Ret>, + std::is_convertible()( + std::declval()...)), + Ret>>::value>; template class UniqueFunctionBase { protected: 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 c2c1cb17f9..0d4a4c6d93 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Hashing.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/Hashing.h @@ -60,6 +60,7 @@ #endif namespace wpi { +template struct DenseMapInfo; /// An opaque object representing a hash code. /// @@ -681,6 +682,13 @@ hash_code hash_value(const std::basic_string &arg) { return hash_combine_range(arg.begin(), arg.end()); } +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 bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; } +}; + } // namespace wpi #ifdef _WIN32 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 06b85a77f0..e4706c7997 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MapVector.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/MapVector.h @@ -5,12 +5,13 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file implements a map that provides insertion order iteration. The -// interface is purposefully minimal. The key is assumed to be cheap to copy -// and 2 copies are kept, one for indexing in a DenseMap, one for iteration in -// a std::vector. -// +/// +/// \file +/// This file implements a map that provides insertion order iteration. The +/// interface is purposefully minimal. The key is assumed to be cheap to copy +/// and 2 copies are kept, one for indexing in a DenseMap, one for iteration in +/// a std::vector. +/// //===----------------------------------------------------------------------===// #ifndef WPIUTIL_WPI_MAPVECTOR_H @@ -18,7 +19,6 @@ #include "wpi/DenseMap.h" #include "wpi/SmallVector.h" -#include #include #include #include @@ -43,6 +43,7 @@ class MapVector { "The mapped_type of the specified Map must be an integral type"); public: + using key_type = KeyT; using value_type = typename VectorType::value_type; using size_type = typename VectorType::size_type; diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerIntPair.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerIntPair.h index 6e6acf8957..34ff4e1387 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerIntPair.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerIntPair.h @@ -5,9 +5,10 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file defines the PointerIntPair class. -// +/// +/// \file +/// This file defines the PointerIntPair class. +/// //===----------------------------------------------------------------------===// #ifndef WPIUTIL_WPI_POINTERINTPAIR_H @@ -22,7 +23,7 @@ namespace wpi { -template struct DenseMapInfo; +template struct DenseMapInfo; template struct PointerIntPairInfo; @@ -180,7 +181,7 @@ struct PointerIntPairInfo { // Provide specialization of DenseMapInfo for PointerIntPair. template -struct DenseMapInfo> { +struct DenseMapInfo, void> { using Ty = PointerIntPair; static Ty getEmptyKey() { diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerUnion.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerUnion.h index 2f951dad15..cc12bbc3ac 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerUnion.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/PointerUnion.h @@ -5,10 +5,11 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file defines the PointerUnion class, which is a discriminated union of -// pointer types. -// +/// +/// \file +/// This file defines the PointerUnion class, which is a discriminated union of +/// pointer types. +/// //===----------------------------------------------------------------------===// #ifndef WPIUTIL_WPI_POINTERUNION_H @@ -17,41 +18,58 @@ #include "wpi/DenseMapInfo.h" #include "wpi/PointerIntPair.h" #include "wpi/PointerLikeTypeTraits.h" +#include #include #include #include +#include namespace wpi { -template struct PointerUnionTypeSelectorReturn { - using Return = T; -}; +namespace detail { +template struct TypesAreDistinct; +template +struct TypesAreDistinct + : std::integral_constant...> && + TypesAreDistinct::value> {}; +template struct TypesAreDistinct : std::true_type {}; +} // namespace detail -/// Get a type based on whether two types are the same or not. +/// Determine if all types in Ts are distinct. /// -/// For: +/// Useful to statically assert when Ts is intended to describe a non-multi set +/// of types. /// -/// \code -/// using Ret = typename PointerUnionTypeSelector::Return; -/// \endcode -/// -/// Ret will be EQ type if T1 is same as T2 or NE type otherwise. -template -struct PointerUnionTypeSelector { - using Return = typename PointerUnionTypeSelectorReturn::Return; -}; +/// Expensive (currently quadratic in sizeof(Ts...)), and so should only be +/// asserted once per instantiation of a type which requires it. +template struct TypesAreDistinct; +template <> struct TypesAreDistinct<> : std::true_type {}; +template +struct TypesAreDistinct + : std::integral_constant::value> {}; -template -struct PointerUnionTypeSelector { - using Return = typename PointerUnionTypeSelectorReturn::Return; -}; +/// Find the first index where a type appears in a list of types. +/// +/// FirstIndexOfType::value is the first index of T in Us. +/// +/// Typically only meaningful when it is otherwise statically known that the +/// type pack has no duplicate types. This should be guaranteed explicitly with +/// static_assert(TypesAreDistinct::value). +/// +/// It is a compile-time error to instantiate when T is not present in Us, i.e. +/// if is_one_of::value is false. +template struct FirstIndexOfType; +template +struct FirstIndexOfType + : std::integral_constant::value> {}; +template +struct FirstIndexOfType : std::integral_constant {}; -template -struct PointerUnionTypeSelectorReturn< - PointerUnionTypeSelector> { - using Return = - typename PointerUnionTypeSelector::Return; -}; +/// Find the type at a given index in a list of types. +/// +/// TypeAtIndex is the type at index I in Ts. +template +using TypeAtIndex = std::tuple_element_t>; namespace pointer_union_detail { /// Determine the number of bits required to store integers with values < n. @@ -64,21 +82,6 @@ namespace pointer_union_detail { return std::min({PointerLikeTypeTraits::NumLowBitsAvailable...}); } - /// Find the index of a type in a list of types. TypeIndex::Index - /// is the index of T in Us, or sizeof...(Us) if T does not appear in the - /// list. - template struct TypeIndex; - template struct TypeIndex { - static constexpr int Index = 0; - }; - template - struct TypeIndex { - static constexpr int Index = 1 + TypeIndex::Index; - }; - template struct TypeIndex { - static constexpr int Index = 0; - }; - /// Find the first type in a list of types. template struct GetFirstType { using type = T; @@ -145,6 +148,7 @@ namespace pointer_union_detail { /// P = (float*)0; /// Y = P.get(); // ok. /// X = P.get(); // runtime assertion failure. +/// PointerUnion Q; // compile time failure. template class PointerUnion : public pointer_union_detail::PointerUnionMembers< @@ -153,12 +157,14 @@ class PointerUnion void *, pointer_union_detail::bitsRequired(sizeof...(PTs)), int, pointer_union_detail::PointerUnionUIntTraits>, 0, PTs...> { + static_assert(TypesAreDistinct::value, + "PointerUnion alternative types cannot be repeated"); // The first type is special because we want to directly cast a pointer to a // default-initialized union to a pointer to the first type. But we don't // want PointerUnion to be a 'template ' // because it's much more convenient to have a name for the whole pack. So // split off the first type here. - using First = typename pointer_union_detail::GetFirstType::type; + using First = TypeAtIndex<0, PTs...>; using Base = typename PointerUnion::PointerUnionMembers; public: @@ -175,10 +181,7 @@ public: /// Test if the Union currently holds the type matching T. template bool is() const { - constexpr int Index = pointer_union_detail::TypeIndex::Index; - static_assert(Index < sizeof...(PTs), - "PointerUnion::is given type not in the union"); - return this->Val.getInt() == Index; + return this->Val.getInt() == FirstIndexOfType::value; } /// Returns the value of the specified pointer type. 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 38a92b10e9..7f8f068f44 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/STLForwardCompat.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/STLForwardCompat.h @@ -5,12 +5,13 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file contains library features backported from future STL versions. -// -// These should be replaced with their STL counterparts as the C++ version LLVM -// is compiled with is updated. -// +/// +/// \file +/// This file contains library features backported from future STL versions. +/// +/// These should be replaced with their STL counterparts as the C++ version LLVM +/// is compiled with is updated. +/// //===----------------------------------------------------------------------===// #ifndef WPIUTIL_WPI_STLFORWARDCOMPAT_H diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallPtrSet.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallPtrSet.h index 133b0e3255..1ada1e0f46 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallPtrSet.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallPtrSet.h @@ -5,9 +5,10 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file defines the SmallPtrSet class. See the doxygen comment for -// SmallPtrSetImplBase for more details on the algorithm used. +/// +/// \file +/// This file defines the SmallPtrSet class. See the doxygen comment for +/// SmallPtrSetImplBase for more details on the algorithm used. // //===----------------------------------------------------------------------===// diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallSet.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallSet.h index f914ec9e53..7b1b283048 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallSet.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallSet.h @@ -5,9 +5,10 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file defines the SmallSet class. -// +/// +/// \file +/// This file defines the SmallSet class. +/// //===----------------------------------------------------------------------===// #ifndef WPIUTIL_WPI_SMALLSET_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 3b51130d3c..4a53feee59 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallString.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallString.h @@ -5,9 +5,10 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file defines the SmallString class. -// +/// +/// \file +/// This file defines the SmallString class. +/// //===----------------------------------------------------------------------===// #ifndef WPIUTIL_WPI_SMALLSTRING_H @@ -15,6 +16,7 @@ #include "wpi/SmallVector.h" #include +#include #include namespace wpi { @@ -70,16 +72,16 @@ public: /// Append from a list of std::string_views. void append(std::initializer_list Refs) { - size_t SizeNeeded = this->size(); + size_t CurrentSize = this->size(); + size_t SizeNeeded = CurrentSize; for (std::string_view Ref : Refs) SizeNeeded += Ref.size(); - this->reserve(SizeNeeded); - auto CurEnd = this->end(); + this->resize_for_overwrite(SizeNeeded); for (std::string_view Ref : Refs) { - this->uninitialized_copy(Ref.begin(), Ref.end(), CurEnd); - CurEnd += Ref.size(); + std::copy(Ref.begin(), Ref.end(), this->begin() + CurrentSize); + CurrentSize += Ref.size(); } - this->set_size(SizeNeeded); + assert(CurrentSize == this->size()); } /// @} @@ -188,11 +190,9 @@ public: /// Implicit conversion to std::string_view. operator std::string_view() const { return str(); } - /// Explicit conversion to std::string. - std::string string() const { return {this->begin(), this->size()}; } - - /// Implicit conversion to std::string. - operator std::string() const { return string(); } + explicit operator std::string() const { + return std::string(this->data(), this->size()); + } // Extra operators. SmallString &operator=(std::string_view RHS) { 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 fb8d3d840d..134ce67a47 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallVector.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/SmallVector.h @@ -5,9 +5,10 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file defines the SmallVector class. -// +/// +/// /file +/// This file defines the SmallVector class. +/// //===----------------------------------------------------------------------===// #ifndef WPIUTIL_WPI_SMALLVECTOR_H @@ -21,10 +22,7 @@ #pragma GCC diagnostic warning "-Wclass-memaccess" #endif -#include "wpi/iterator_range.h" #include "wpi/Compiler.h" -#include "wpi/ErrorHandling.h" -#include "wpi/MemAlloc.h" #include "wpi/type_traits.h" #include #include @@ -42,6 +40,8 @@ namespace wpi { +template class iterator_range; + /// This is all the stuff common to all SmallVectors. /// /// The template parameter specifies the type which should be used to hold the @@ -80,15 +80,11 @@ public: LLVM_NODISCARD bool empty() const { return !Size; } +protected: /// Set the array size to \p N, which the current array must have enough /// capacity for. /// /// This does not construct or destroy any elements in the vector. - /// - /// Clients can use this in conjunction with capacity() to write past the end - /// of the buffer when they know that more elements are available, and only - /// update the size later. This avoids the cost of value initializing elements - /// which will only be overwritten. void set_size(size_t N) { assert(N <= capacity()); Size = static_cast(N); @@ -575,6 +571,16 @@ protected: explicit SmallVectorImpl(unsigned N) : SmallVectorTemplateBase(N) {} + void assignRemote(SmallVectorImpl &&RHS) { + this->destroy_range(this->begin(), this->end()); + if (!this->isSmall()) + free(this->begin()); + this->BeginX = RHS.BeginX; + this->Size = RHS.Size; + this->Capacity = RHS.Capacity; + RHS.resetToSmall(); + } + public: SmallVectorImpl(const SmallVectorImpl &) = delete; @@ -591,18 +597,25 @@ public: } private: + // Make set_size() private to avoid misuse in subclasses. + using SuperClass::set_size; + template void resizeImpl(size_type N) { + if (N == this->size()) + return; + if (N < this->size()) { - this->pop_back_n(this->size() - N); - } else if (N > this->size()) { - this->reserve(N); - for (auto I = this->end(), E = this->begin() + N; I != E; ++I) - if (ForOverwrite) - new (&*I) T; - else - new (&*I) T(); - this->set_size(N); + this->truncate(N); + return; } + + this->reserve(N); + for (auto I = this->end(), E = this->begin() + N; I != E; ++I) + if (ForOverwrite) + new (&*I) T; + else + new (&*I) T(); + this->set_size(N); } public: @@ -611,12 +624,19 @@ public: /// Like resize, but \ref T is POD, the new values won't be initialized. void resize_for_overwrite(size_type N) { resizeImpl(N); } + /// Like resize, but requires that \p N is less than \a size(). + void truncate(size_type N) { + assert(this->size() >= N && "Cannot increase size with truncate"); + this->destroy_range(this->begin() + N, this->end()); + this->set_size(N); + } + void resize(size_type N, ValueParamT NV) { if (N == this->size()) return; if (N < this->size()) { - this->pop_back_n(this->size() - N); + this->truncate(N); return; } @@ -631,8 +651,7 @@ public: void pop_back_n(size_type NumItems) { assert(this->size() >= NumItems); - this->destroy_range(this->end() - NumItems, this->end()); - this->set_size(this->size() - NumItems); + truncate(this->size() - NumItems); } LLVM_NODISCARD T pop_back_val() { @@ -1026,12 +1045,7 @@ SmallVectorImpl &SmallVectorImpl::operator=(SmallVectorImpl &&RHS) { // If the RHS isn't small, clear this vector and then steal its buffer. if (!RHS.isSmall()) { - this->destroy_range(this->begin(), this->end()); - if (!this->isSmall()) free(this->begin()); - this->BeginX = RHS.BeginX; - this->Size = RHS.Size; - this->Capacity = RHS.Capacity; - RHS.resetToSmall(); + this->assignRemote(std::move(RHS)); return *this; } @@ -1222,7 +1236,20 @@ public: } SmallVector &operator=(SmallVector &&RHS) { - SmallVectorImpl::operator=(::std::move(RHS)); + if (N) { + SmallVectorImpl::operator=(::std::move(RHS)); + return *this; + } + // SmallVectorImpl::operator= does not leverage N==0. Optimize the + // case. + if (this == &RHS) + return *this; + if (RHS.empty()) { + this->destroy_range(this->begin(), this->end()); + this->Size = 0; + } else { + this->assignRemote(std::move(RHS)); + } return *this; } @@ -1242,13 +1269,22 @@ inline size_t capacity_in_bytes(const SmallVector &X) { return X.capacity_in_bytes(); } +template +using ValueTypeFromRangeType = + typename std::remove_const()))>::type>::type; + /// Given a range of type R, iterate the entire range and return a /// SmallVector with elements of the vector. This is useful, for example, /// when you want to iterate a range and then sort the results. template -SmallVector()))>::type>::type, - Size> +SmallVector, Size> to_vector(R &&Range) { + return {std::begin(Range), std::end(Range)}; +} +template +SmallVector, + CalculateSmallVectorDefaultInlinedElements< + ValueTypeFromRangeType>::value> to_vector(R &&Range) { return {std::begin(Range), std::end(Range)}; } diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/StringMap.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/StringMap.h index c3fbb69f36..c7da670993 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/StringMap.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/StringMap.h @@ -5,15 +5,17 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file defines the StringMap class. -// +/// +/// \file +/// This file defines the StringMap class. +/// //===----------------------------------------------------------------------===// #ifndef WPIUTIL_WPI_STRINGMAP_H #define WPIUTIL_WPI_STRINGMAP_H #include "wpi/StringMapEntry.h" +#include "wpi/iterator.h" #include "wpi/AllocatorBase.h" #include "wpi/MemAlloc.h" #include "wpi/SmallVector.h" @@ -130,9 +132,7 @@ public: StringMap(std::initializer_list> List) : StringMapImpl(List.size(), static_cast(sizeof(MapEntryTy))) { - for (const auto &P : List) { - insert(P); - } + insert(List); } StringMap(StringMap &&RHS) @@ -301,6 +301,21 @@ public: return try_emplace(KV.first, std::move(KV.second)); } + /// Inserts elements from range [first, last). If multiple elements in the + /// range have keys that compare equivalent, it is unspecified which element + /// is inserted . + template void insert(InputIt First, InputIt Last) { + for (InputIt It = First; It != Last; ++It) + insert(*It); + } + + /// Inserts elements from initializer list ilist. If multiple elements in + /// the range have keys that compare equivalent, it is unspecified which + /// element is inserted + void insert(std::initializer_list> List) { + insert(List.begin(), List.end()); + } + /// Inserts an element or assigns to the current element if the key already /// exists. The return type is the same as try_emplace. template @@ -485,13 +500,7 @@ public: explicit StringMapKeyIterator(StringMapConstIterator Iter) : base(std::move(Iter)) {} - std::string_view &operator*() { - Key = this->wrapped()->getKey(); - return Key; - } - -private: - std::string_view Key; + std::string_view operator*() const { return this->wrapped()->getKey(); } }; template diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/StringMapEntry.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/StringMapEntry.h index a8491791cc..2b33aa6ad7 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/StringMapEntry.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/StringMapEntry.h @@ -5,11 +5,12 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -// -// This file defines the StringMapEntry class - it is intended to be a low -// dependency implementation detail of StringMap that is more suitable for -// inclusion in public headers than StringMap.h itself is. -// +/// +/// \file +/// This file defines the StringMapEntry class - it is intended to be a low +/// dependency implementation detail of StringMap that is more suitable for +/// inclusion in public headers than StringMap.h itself is. +/// //===----------------------------------------------------------------------===// #ifndef WPIUTIL_WPI_STRINGMAPENTRY_H diff --git a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/iterator.h b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/iterator.h index 1b954b395c..f959faca45 100644 --- a/wpiutil/src/main/native/thirdparty/llvm/include/wpi/iterator.h +++ b/wpiutil/src/main/native/thirdparty/llvm/include/wpi/iterator.h @@ -35,6 +35,21 @@ namespace wpi { /// terms of addition of one. These aren't equivalent for all iterator /// categories, and respecting that adds a lot of complexity for little gain. /// +/// Iterators are expected to have const rules analogous to pointers, with a +/// single, const-qualified operator*() that returns ReferenceT. This matches +/// the second and third pointers in the following example: +/// \code +/// int Value; +/// { int *I = &Value; } // ReferenceT 'int&' +/// { int *const I = &Value; } // ReferenceT 'int&'; const +/// { const int *I = &Value; } // ReferenceT 'const int&' +/// { const int *const I = &Value; } // ReferenceT 'const int&'; const +/// \endcode +/// If an iterator facade returns a handle to its own state, then T (and +/// PointerT and ReferenceT) should usually be const-qualified. Otherwise, if +/// clients are expected to modify the handle itself, the field can be declared +/// mutable or use const_cast. +/// /// Classes wishing to use `iterator_facade_base` should implement the following /// methods: /// @@ -42,8 +57,7 @@ namespace wpi { /// (All of the following methods) /// - DerivedT &operator=(const DerivedT &R); /// - bool operator==(const DerivedT &R) const; -/// - const T &operator*() const; -/// - T &operator*(); +/// - T &operator*() const; /// - DerivedT &operator++(); /// /// Bidirectional Iterators: @@ -95,6 +109,22 @@ protected: operator ReferenceT() const { return *I; } }; + /// A proxy object for computing a pointer via indirecting a copy of a + /// reference. This is used in APIs which need to produce a pointer but for + /// which the reference might be a temporary. The proxy preserves the + /// reference internally and exposes the pointer via a arrow operator. + class PointerProxy { + friend iterator_facade_base; + + ReferenceT R; + + template + PointerProxy(RefT &&R) : R(std::forward(R)) {} + + public: + PointerT operator->() const { return &R; } + }; + public: DerivedT operator+(DifferenceTypeT n) const { static_assert(std::is_base_of::value, @@ -172,19 +202,13 @@ public: return !(static_cast(*this) < RHS); } - PointerT operator->() { return &static_cast(this)->operator*(); } - PointerT operator->() const { - return &static_cast(this)->operator*(); - } - ReferenceProxy operator[](DifferenceTypeT n) { - static_assert(IsRandomAccess, - "Subscripting is only defined for random access iterators."); - return ReferenceProxy(static_cast(this)->operator+(n)); + PointerProxy operator->() const { + return static_cast(this)->operator*(); } ReferenceProxy operator[](DifferenceTypeT n) const { static_assert(IsRandomAccess, "Subscripting is only defined for random access iterators."); - return ReferenceProxy(static_cast(this)->operator+(n)); + return static_cast(this)->operator+(n); } }; @@ -330,8 +354,7 @@ public: explicit pointer_iterator(WrappedIteratorT u) : pointer_iterator::iterator_adaptor_base(std::move(u)) {} - T &operator*() { return Ptr = &*this->I; } - const T &operator*() const { return Ptr = &*this->I; } + T &operator*() const { return Ptr = &*this->I; } }; template -#include #include #include #include @@ -306,6 +305,8 @@ public: // changeColor() has no effect until enable_colors(true) is called. virtual void enable_colors(bool /*enable*/) {} + bool colors_enabled() const { return false; } + /// Tie this stream to the specified stream. Replaces any existing tied-to /// stream. Specifying a nullptr unties the stream. void tie(raw_ostream *TieTo) { TiedStream = TieTo; } @@ -414,6 +415,7 @@ class raw_fd_ostream : public raw_pwrite_stream { int FD; bool ShouldClose; bool SupportsSeeking = false; + bool IsRegularFile = false; #ifdef _WIN32 /// True if this fd refers to a Windows console device. Mintty and other @@ -483,6 +485,8 @@ public: bool supportsSeeking() const { return SupportsSeeking; } + bool isRegularFile() const { return IsRegularFile; } + /// Flushes the stream and repositions the underlying file descriptor position /// to the offset specified from the beginning of the file. uint64_t seek(uint64_t off); @@ -544,6 +548,9 @@ public: /// A raw_ostream that writes to an std::string. This is a simple adaptor /// class. This class does not encounter output errors. +/// raw_string_ostream operates without a buffer, delegating all memory +/// management to the std::string. Thus the std::string is always up-to-date, +/// may be used directly and there is no need to call flush(). class raw_string_ostream : public raw_ostream { std::string &OS; @@ -558,14 +565,11 @@ public: explicit raw_string_ostream(std::string &O) : OS(O) { SetUnbuffered(); } - ~raw_string_ostream() override; - /// Flushes the stream contents to the target string and returns the string's - /// reference. - std::string& str() { - flush(); - return OS; - } + /// Returns the string's reference. In most cases it is better to simply use + /// the underlying std::string directly. + /// TODO: Consider removing this API. + std::string &str() { return OS; } void reserveExtraSpace(uint64_t ExtraSize) override { OS.reserve(tell() + ExtraSize); @@ -745,7 +749,11 @@ class buffer_unique_ostream : public raw_svector_ostream { public: buffer_unique_ostream(std::unique_ptr OS) - : raw_svector_ostream(Buffer), OS(std::move(OS)) {} + : raw_svector_ostream(Buffer), OS(std::move(OS)) { + // Turn off buffering on OS, which we now own, to avoid allocating a buffer + // when the destructor writes only to be immediately flushed again. + this->OS->SetUnbuffered(); + } ~buffer_unique_ostream() override { *OS << str(); } }; diff --git a/wpiutil/src/test/native/cpp/llvm/ConvertUTFTest.cpp b/wpiutil/src/test/native/cpp/llvm/ConvertUTFTest.cpp index e3cf2663a4..8e0837c9af 100644 --- a/wpiutil/src/test/native/cpp/llvm/ConvertUTFTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/ConvertUTFTest.cpp @@ -23,7 +23,7 @@ TEST(ConvertUTFTest, ConvertUTF16LittleEndianToUTF8String) { bool Success = convertUTF16ToUTF8String(Ref, Result); EXPECT_TRUE(Success); std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0"); - EXPECT_EQ(Expected, Result.string()); + EXPECT_EQ(Expected, std::string{Result}); } TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) { @@ -34,7 +34,7 @@ TEST(ConvertUTFTest, ConvertUTF16BigEndianToUTF8String) { bool Success = convertUTF16ToUTF8String(Ref, Result); EXPECT_TRUE(Success); std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0"); - EXPECT_EQ(Expected, Result.string()); + EXPECT_EQ(Expected, std::string{Result}); } TEST(ConvertUTFTest, ConvertUTF8ToUTF16String) { @@ -60,7 +60,7 @@ TEST(ConvertUTFTest, Empty) { SmallString<20> Result; bool Success = convertUTF16ToUTF8String(span(), Result); EXPECT_TRUE(Success); - EXPECT_TRUE(Result.string().empty()); + EXPECT_TRUE(std::string{Result}.empty()); } TEST(ConvertUTFTest, HasUTF16BOM) { @@ -87,7 +87,7 @@ TEST(ConvertUTFTest, UTF16WrappersForConvertUTF16ToUTF8String) { bool Success = convertUTF16ToUTF8String(SrcRef, Result); EXPECT_TRUE(Success); std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0"); - EXPECT_EQ(Expected, Result.string()); + EXPECT_EQ(Expected, std::string{Result}); } TEST(ConvertUTFTest, ConvertUTF8toWide) { @@ -111,7 +111,7 @@ TEST(ConvertUTFTest, convertWideToUTF8) { bool Success = convertWideToUTF8(Src, Result); EXPECT_TRUE(Success); std::string Expected("\xe0\xb2\xa0_\xe0\xb2\xa0"); - EXPECT_EQ(Expected, Result.string()); + EXPECT_EQ(Expected, std::string{Result}); } struct ConvertUTFResultContainer { diff --git a/wpiutil/src/test/native/cpp/llvm/DenseMapTest.cpp b/wpiutil/src/test/native/cpp/llvm/DenseMapTest.cpp index 6e08de430d..68c37c0f04 100644 --- a/wpiutil/src/test/native/cpp/llvm/DenseMapTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/DenseMapTest.cpp @@ -634,4 +634,47 @@ TEST(DenseMapCustomTest, OpaquePointerKey) { EXPECT_EQ(Map.find(K2), Map.end()); EXPECT_EQ(Map.find(K3), Map.end()); } +} // namespace + +namespace { +struct A { + A(int value) : value(value) {} + int value; +}; +struct B : public A { + using A::A; +}; +} // namespace + +namespace wpi { +template +struct DenseMapInfo::value>> { + static inline T getEmptyKey() { return {static_cast(~0)}; } + static inline T getTombstoneKey() { return {static_cast(~0U - 1)}; } + static unsigned getHashValue(const T &Val) { return Val.value; } + static bool isEqual(const T &LHS, const T &RHS) { + return LHS.value == RHS.value; + } +}; +} // namespace wpi + +namespace { +TEST(DenseMapCustomTest, SFINAEMapInfo) { + // Test that we can use a pointer to an incomplete type as a DenseMap key. + // This is an important build time optimization, since many classes have + // DenseMap members. + DenseMap Map; + B Keys[3] = {{0}, {1}, {2}}; + Map.insert({Keys[0], 1}); + Map.insert({Keys[1], 2}); + Map.insert({Keys[2], 3}); + EXPECT_EQ(Map.count(Keys[0]), 1u); + EXPECT_EQ(Map[Keys[0]], 1); + EXPECT_EQ(Map[Keys[1]], 2); + EXPECT_EQ(Map[Keys[2]], 3); + Map.clear(); + EXPECT_EQ(Map.find(Keys[0]), Map.end()); + EXPECT_EQ(Map.find(Keys[1]), Map.end()); + EXPECT_EQ(Map.find(Keys[2]), Map.end()); } +} // namespace diff --git a/wpiutil/src/test/native/cpp/llvm/FunctionExtrasTest.cpp b/wpiutil/src/test/native/cpp/llvm/FunctionExtrasTest.cpp index 9094e4e0bd..53508ccf79 100644 --- a/wpiutil/src/test/native/cpp/llvm/FunctionExtrasTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/FunctionExtrasTest.cpp @@ -291,4 +291,23 @@ TEST(UniqueFunctionTest, IncompleteTypes) { unique_function *()> IncompleteResultPointer; } +// Incomplete function returning an incomplete type +Incomplete incompleteFunction(); +const Incomplete incompleteFunctionConst(); + +// Check that we can assign a callable to a unique_function when the +// callable return value is incomplete. +TEST(UniqueFunctionTest, IncompleteCallableType) { + unique_function IncompleteReturnInCallable{incompleteFunction}; + unique_function IncompleteReturnInCallableConst{ + incompleteFunctionConst}; + unique_function IncompleteReturnInCallableConstConversion{ + incompleteFunction}; +} + +// Define the incomplete function +class Incomplete {}; +Incomplete incompleteFunction() { return {}; } +const Incomplete incompleteFunctionConst() { return {}; } + } // anonymous namespace diff --git a/wpiutil/src/test/native/cpp/llvm/SmallVectorTest.cpp b/wpiutil/src/test/native/cpp/llvm/SmallVectorTest.cpp index 56c27d6c0c..66cd5c2d39 100644 --- a/wpiutil/src/test/native/cpp/llvm/SmallVectorTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/SmallVectorTest.cpp @@ -313,6 +313,32 @@ TYPED_TEST(SmallVectorTest, ResizeShrinkTest) { EXPECT_EQ(5, Constructable::getNumDestructorCalls()); } +// Truncate test. +TYPED_TEST(SmallVectorTest, TruncateTest) { + SCOPED_TRACE("TruncateTest"); + + this->theVector.reserve(3); + this->makeSequence(this->theVector, 1, 3); + this->theVector.truncate(1); + + this->assertValuesInOrder(this->theVector, 1u, 1); + EXPECT_EQ(6, Constructable::getNumConstructorCalls()); + EXPECT_EQ(5, Constructable::getNumDestructorCalls()); + +#if !defined(NDEBUG) && GTEST_HAS_DEATH_TEST + EXPECT_DEATH(this->theVector.truncate(2), "Cannot increase size"); +#endif + this->theVector.truncate(1); + this->assertValuesInOrder(this->theVector, 1u, 1); + EXPECT_EQ(6, Constructable::getNumConstructorCalls()); + EXPECT_EQ(5, Constructable::getNumDestructorCalls()); + + this->theVector.truncate(0); + this->assertEmpty(this->theVector); + EXPECT_EQ(6, Constructable::getNumConstructorCalls()); + EXPECT_EQ(6, Constructable::getNumDestructorCalls()); +} + // Resize bigger test. TYPED_TEST(SmallVectorTest, ResizeGrowTest) { SCOPED_TRACE("ResizeGrowTest"); diff --git a/wpiutil/src/test/native/cpp/llvm/StringMapTest.cpp b/wpiutil/src/test/native/cpp/llvm/StringMapTest.cpp index 5602008f86..71baa20105 100644 --- a/wpiutil/src/test/native/cpp/llvm/StringMapTest.cpp +++ b/wpiutil/src/test/native/cpp/llvm/StringMapTest.cpp @@ -110,6 +110,13 @@ TEST_F(StringMapTest, ConstEmptyMapTest) { EXPECT_TRUE(constTestMap.find(testKeyStr) == constTestMap.end()); } +// initializer_list ctor test; also implicitly tests initializer_list and +// iterator overloads of insert(). +TEST_F(StringMapTest, InitializerListCtor) { + testMap = StringMap({{"key", 1}}); + assertSingleItemMap(); +} + // A map with a single entry. TEST_F(StringMapTest, SingleEntryMapTest) { testMap[testKey] = testValue; @@ -300,7 +307,7 @@ TEST_F(StringMapTest, InsertOrAssignTest) { EXPECT_EQ(0, try1.first->second.copy); } -TEST_F(StringMapTest, IterMapKeys) { +TEST_F(StringMapTest, IterMapKeysSmallVector) { StringMap Map; Map["A"] = 1; Map["B"] = 2;