Update LLVM libraries to 14.0.6 (#4350)

The main noticeable change is the SmallString conversion operator to std::string is now explicit instead of implicit.
This commit is contained in:
Tyler Veness
2022-08-15 05:38:15 -07:00
committed by GitHub
parent c5db23f296
commit 0e0786331a
70 changed files with 1211 additions and 823 deletions

View File

@@ -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};
}
}
}

View File

@@ -1098,13 +1098,13 @@ std::vector<UsbCameraInfo> 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);

View File

@@ -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 <pj.reiniger@gmail.com>
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);

View File

@@ -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 <pj.reiniger@gmail.com>
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 <typename... Ts> struct DenseMapInfo<std::tuple<Ts...>> {
template <> struct DenseMapInfo<hash_code> {
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<unsigned>(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<T, TriviallyCopyable>::takeAllocationForGrow(
@@ -444,7 +444,7 @@ void SmallVectorTemplateBase<T, TriviallyCopyable>::takeAllocationForGrow(
free(this->begin());
this->BeginX = NewElts;
@@ -93,7 +79,7 @@ index b8a11030fc33..602fcc5b7a98 100644
}
/// SmallVectorTemplateBase<TriviallyCopyable = true> - 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 <typename T, std::size_t SizeOfT> 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.

View File

@@ -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 <pj.reiniger@gmail.com>
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<llvm::disjunction<
template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
protected:
@@ -20,7 +20,7 @@ index e67ef7377c88..1a26cb702cae 100644
template <typename T, class = void>
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

View File

@@ -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 <pj.reiniger@gmail.com>
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 @@

View File

@@ -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 <pj.reiniger@gmail.com>
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

View File

@@ -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 <pj.reiniger@gmail.com>
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<T, LN, C> &LHS, const SmallSet<T, RN, C> &RHS) {
@@ -270,7 +270,7 @@ bool operator==(const SmallSet<T, LN, C> &LHS, const SmallSet<T, RN, C> &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());

View File

@@ -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 <pj.reiniger@gmail.com>
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 <chrono>
#include <ctime>
@@ -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) {

View File

@@ -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 <pj.reiniger@gmail.com>
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 <typename FunctionT> 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 <typename T>
@@ -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 <typename T, typename Enable> struct DenseMapInfo;
/// An opaque object representing a hash code.
@@ -679,4 +684,8 @@ hash_code hash_value(const std::basic_string<T> &arg) {
@@ -687,4 +692,8 @@ template <> struct DenseMapInfo<hash_code, void> {
} // 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 <algorithm>
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 <map>
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 {

View File

@@ -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 <pj.reiniger@gmail.com>
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 <optional>
#include <string>
#include <tuple>
@@ -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 <typename HasherT, llvm::support::endianness Endianness>
- friend void addHash(HashBuilderImpl<HasherT, Endianness> &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<bool> HasColors;
bool IsRegularFile = false;
- mutable std::optional<bool> 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<sys::fs::FileLocker> tryLockFor(std::chrono::milliseconds Timeout);
- Expected<sys::fs::FileLocker> 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 <char C>
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<sys::fs::FileLocker>
-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() {}

View File

@@ -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 <pj.reiniger@gmail.com>
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 <typename IteratorT> class iterator_range;
/// Using 64 bit size is desirable for cases like SmallVector<char>, 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 <class T, typename = void> struct SmallVectorAlignmentAndSize {
@@ -108,8 +103,8 @@ template <class T, typename = void> struct SmallVectorAlignmentAndSize {
/// to avoid unnecessarily requiring T to be complete.
template <typename T, typename = void>
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<T *>(
@@ -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<void *, 1>) ==
@@ -51,10 +51,6 @@ static_assert(sizeof(SmallVector<void *, 1>) ==
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<Size_T>::grow_pod(void *FirstEl, size_t MinSize,
@@ -134,20 +127,3 @@ void SmallVectorBase<Size_T>::grow_pod(void *FirstEl, size_t MinSize,
this->BeginX = NewElts;
this->Capacity = NewCapacity;
}

View File

@@ -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 <pj.reiniger@gmail.com>
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 <system_error>
#include <type_traits>
@@ -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);
}

View File

@@ -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 <pj.reiniger@gmail.com>
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 <typename ValueTy>
@@ -474,6 +490,91 @@ private:
std::string_view Key;
@@ -483,6 +499,91 @@ public:
std::string_view operator*() const { return this->wrapped()->getKey(); }
};
+template <typename ValueTy>
@@ -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;

View File

@@ -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 <pj.reiniger@gmail.com>
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 {

View File

@@ -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 <pj.reiniger@gmail.com>
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 {

View File

@@ -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 <pj.reiniger@gmail.com>
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<std::is_signed<T>::value, T> MulOverflow(T X, T Y, T &Result) {

View File

@@ -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 <pj.reiniger@gmail.com>
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 <initializer_list>
#include <iterator>
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 <string_view>
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 <string>
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 <sys/stat.h>
// <fcntl.h> 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 <tuple>
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 @@

View File

@@ -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 <pj.reiniger@gmail.com>
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 <typename PointerT, unsigned IntBits, typename PtrTraits>
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 {

View File

@@ -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 <pj.reiniger@gmail.com>
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<std::unique_ptr<WritableMemoryBuffer>>
getMemoryBufferForStream(sys::fs::file_t FD, const Twine &BufferName) {
- const ssize_t ChunkSize = 4096*4;
- SmallString<ChunkSize> Buffer;
+ constexpr size_t ChunkSize = 4096*4;
+ SmallVector<uint8_t, ChunkSize> Buffer;
// Read into Buffer until we hit EOF.
for (;;) {
Buffer.reserve(Buffer.size() + ChunkSize);

View File

@@ -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 <pj.reiniger@gmail.com>
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 <mutex>
@@ -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

View File

@@ -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 <pj.reiniger@gmail.com>
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 <type_traits>
#include <vector>

View File

@@ -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 <pj.reiniger@gmail.com>
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<LLVMFatalErrorHandler>(user_data);
- handler(reason.c_str());
- handler(reason);
-}
-
-void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler) {
@@ -74,10 +77,10 @@ index 9ee52a02c214..77c3a37475d0 100644
#include <winerror.h>
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<HANDLE>(::_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) {

View File

@@ -1,28 +0,0 @@
From 333f987aa17d7138af8bf6e41d5749041793a721 Mon Sep 17 00:00:00 2001
From: PJ Reiniger <pj.reiniger@gmail.com>
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) {

View File

@@ -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 <pj.reiniger@gmail.com>
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) {

View File

@@ -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 <pj.reiniger@gmail.com>
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<const char> S) {
@@ -72,7 +72,7 @@ index 87da616b75d4..c6c52d25adb1 100644
const UTF8 *Start = reinterpret_cast<const UTF8 *>(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<const char>(), 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 {

View File

@@ -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 <pj.reiniger@gmail.com>
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;

View File

@@ -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 <pj.reiniger@gmail.com>
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) {

View File

@@ -0,0 +1,69 @@
From 8f51777a3117a7b010a4cfb2ded1f5d226466f34 Mon Sep 17 00:00:00 2001
From: Tyler Veness <calcmogul@gmail.com>
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 <cassert>
#include <cstddef>
#include <cstdint>
+#include <type_traits>
namespace llvm {
+namespace detail {
+template <typename T, typename... Us> struct TypesAreDistinct;
+template <typename T, typename... Us>
+struct TypesAreDistinct
+ : std::integral_constant<bool, !std::disjunction_v<std::is_same<T, Us>...> &&
+ TypesAreDistinct<Us...>::value> {};
+template <typename T> struct TypesAreDistinct<T> : 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 <typename... Ts> struct TypesAreDistinct;
+template <> struct TypesAreDistinct<> : std::true_type {};
+template <typename... Ts>
+struct TypesAreDistinct
+ : std::integral_constant<bool, detail::TypesAreDistinct<Ts...>::value> {};
+
+/// Find the first index where a type appears in a list of types.
+///
+/// FirstIndexOfType<T, Us...>::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<Us...>::value).
+///
+/// It is a compile-time error to instantiate when T is not present in Us, i.e.
+/// if is_one_of<T, Us...>::value is false.
+template <typename T, typename... Us> struct FirstIndexOfType;
+template <typename T, typename U, typename... Us>
+struct FirstIndexOfType<T, U, Us...>
+ : std::integral_constant<size_t, 1 + FirstIndexOfType<T, Us...>::value> {};
+template <typename T, typename... Us>
+struct FirstIndexOfType<T, T, Us...> : std::integral_constant<size_t, 0> {};
+
+/// Find the type at a given index in a list of types.
+///
+/// TypeAtIndex<I, Ts...> is the type at index I in Ts.
+template <size_t I, typename... Ts>
+using TypeAtIndex = std::tuple_element_t<I, std::tuple<Ts...>>;
+
namespace pointer_union_detail {
/// Determine the number of bits required to store integers with values < n.
/// This is ceil(log2(n)).

View File

@@ -0,0 +1,34 @@
From 498e56e09e8f264978831519ff9c8afa701bf208 Mon Sep 17 00:00:00 2001
From: Tyler Veness <calcmogul@gmail.com>
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<int> Map;
- Map["A"] = 1;
- Map["B"] = 2;
- Map["C"] = 3;
- Map["D"] = 3;
-
- std::vector<std::string_view> Keys{Map.keys().begin(), Map.keys().end()};
- llvm::sort(Keys);
-
- std::vector<std::string_view> Expected{{"A", "B", "C", "D"}};
- EXPECT_EQ(Expected, Keys);
-}
-
TEST_F(StringMapTest, IterMapKeysSmallVector) {
StringMap<int> Map;
Map["A"] = 1;

View File

@@ -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

View File

@@ -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));
}

View File

@@ -132,15 +132,16 @@ static _Function_class_(DNS_QUERY_COMPLETION_ROUTINE) VOID WINAPI
reinterpret_cast<const wpi::UTF16*>(wideView.data()),
splitIndex};
wpi::convertUTF16ToUTF8String(wideStr, storage);
auto& pair = data.txt.emplace_back(
std::pair<std::string, std::string>{storage.string(), {}});
auto& pair =
data.txt.emplace_back(std::pair<std::string, std::string>{
std::string{storage}, {}});
storage.clear();
wideStr = wpi::span<const wpi::UTF16>{
reinterpret_cast<const wpi::UTF16*>(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;

View File

@@ -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(),

View File

@@ -104,8 +104,8 @@ bool convertUTF16ToUTF8String(span<const char> SrcBytes, SmallVectorImpl<char> &
std::vector<UTF16> 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;
}

View File

@@ -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);

View File

@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "wpi/MemAlloc.h"
#include <new>
// These are out of line to have __cpp_aligned_new not affect ABI.

View File

@@ -237,7 +237,7 @@ static std::unique_ptr<WritableMemoryBuffer> 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<WritableMemoryBuffer> GetMemoryBufferForStream(
return nullptr;
}
#endif
buffer.set_size(buffer.size() + readBytes);
} while (readBytes != 0);
return GetMemBufferCopyImpl(buffer, bufferName, ec);

View File

@@ -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 <algorithm>

View File

@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "wpi/SmallVector.h"
#include "wpi/MemAlloc.h"
#include <cstdint>
#ifdef LLVM_ENABLE_EXCEPTIONS
#include <stdexcept>
@@ -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<void *, 0>) ==
sizeof(unsigned) * 2 + sizeof(void *),
@@ -43,8 +53,7 @@ static_assert(sizeof(SmallVector<void *, 1>) ==
/// 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 " +

View File

@@ -11,7 +11,6 @@
//===----------------------------------------------------------------------===//
#include "wpi/StringMap.h"
#include "wpi/StringExtras.h"
#include "wpi/DJB.h"
#include "wpi/MathExtras.h"

View File

@@ -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);

View File

@@ -23,10 +23,8 @@
#include "wpi/fs.h"
#include "wpi/MathExtras.h"
#include <algorithm>
#include <cctype>
#include <cerrno>
#include <cstdio>
#include <iterator>
#include <sys/stat.h>
// <fcntl.h> 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<HANDLE>(::_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);
}

View File

@@ -21,6 +21,7 @@
#include "wpi/Compiler.h"
#include "wpi/MemAlloc.h"
#include <type_traits>
namespace wpi {

View File

@@ -13,6 +13,7 @@
#include <chrono>
#include <ctime>
#include <ratio>
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 <typename D = std::chrono::nanoseconds>
using TimePoint = std::chrono::time_point<std::chrono::system_clock, D>;

View File

@@ -16,9 +16,6 @@
#define WPIUTIL_WPI_COMPILER_H
#ifdef __cplusplus
#include <new>
#endif
#include <stddef.h>
#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

View File

@@ -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

View File

@@ -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 <cassert>
#include <cstddef>
#include <cstdint>
#include <tuple>
#include <utility>
namespace wpi {
@@ -39,7 +40,12 @@ static inline unsigned combineHashValue(unsigned a, unsigned b) {
} // end namespace detail
template<typename T>
/// 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<typename T, typename Enable = void>
struct DenseMapInfo {
//static inline T getEmptyKey();
//static inline T getTombstoneKey();
@@ -282,13 +288,6 @@ template <typename... Ts> struct DenseMapInfo<std::tuple<Ts...>> {
}
};
template <> struct DenseMapInfo<hash_code> {
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<unsigned>(val); }
static bool isEqual(hash_code LHS, hash_code RHS) { return LHS == RHS; }
};
} // end namespace wpi
#endif // WPIUTIL_WPI_DENSEMAPINFO_H

View File

@@ -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

View File

@@ -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);
}

View File

@@ -37,6 +37,7 @@
#include "wpi/STLForwardCompat.h"
#include "wpi/MemAlloc.h"
#include "wpi/type_traits.h"
#include <cstring>
#include <memory>
#include <type_traits>
@@ -57,6 +58,7 @@ template <typename FunctionT> 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 <typename CallableT, typename ThisT>
using EnableUnlessSameType =
std::enable_if_t<!std::is_same<remove_cvref_t<CallableT>, ThisT>::value>;
template <typename CallableT, typename Ret, typename... Params>
using EnableIfCallable =
std::enable_if_t<std::is_void<Ret>::value ||
std::is_convertible<decltype(std::declval<CallableT>()(
std::declval<Params>()...)),
Ret>::value>;
using EnableIfCallable = std::enable_if_t<wpi::disjunction<
std::is_void<Ret>,
std::is_same<decltype(std::declval<CallableT>()(std::declval<Params>()...)),
Ret>,
std::is_same<const decltype(std::declval<CallableT>()(
std::declval<Params>()...)),
Ret>,
std::is_convertible<decltype(std::declval<CallableT>()(
std::declval<Params>()...)),
Ret>>::value>;
template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
protected:

View File

@@ -60,6 +60,7 @@
#endif
namespace wpi {
template <typename T, typename Enable> struct DenseMapInfo;
/// An opaque object representing a hash code.
///
@@ -681,6 +682,13 @@ hash_code hash_value(const std::basic_string<T> &arg) {
return hash_combine_range(arg.begin(), arg.end());
}
template <> struct DenseMapInfo<hash_code, void> {
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

View File

@@ -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 <algorithm>
#include <cassert>
#include <cstddef>
#include <iterator>
@@ -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;

View File

@@ -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 <typename T> struct DenseMapInfo;
template <typename T, typename Enable> struct DenseMapInfo;
template <typename PointerT, unsigned IntBits, typename PtrTraits>
struct PointerIntPairInfo;
@@ -180,7 +181,7 @@ struct PointerIntPairInfo {
// Provide specialization of DenseMapInfo for PointerIntPair.
template <typename PointerTy, unsigned IntBits, typename IntType>
struct DenseMapInfo<PointerIntPair<PointerTy, IntBits, IntType>> {
struct DenseMapInfo<PointerIntPair<PointerTy, IntBits, IntType>, void> {
using Ty = PointerIntPair<PointerTy, IntBits, IntType>;
static Ty getEmptyKey() {

View File

@@ -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 <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <type_traits>
namespace wpi {
template <typename T> struct PointerUnionTypeSelectorReturn {
using Return = T;
};
namespace detail {
template <typename T, typename... Us> struct TypesAreDistinct;
template <typename T, typename... Us>
struct TypesAreDistinct
: std::integral_constant<bool, !std::disjunction_v<std::is_same<T, Us>...> &&
TypesAreDistinct<Us...>::value> {};
template <typename T> struct TypesAreDistinct<T> : 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<T1, T2, EQ, NE>::Return;
/// \endcode
///
/// Ret will be EQ type if T1 is same as T2 or NE type otherwise.
template <typename T1, typename T2, typename RET_EQ, typename RET_NE>
struct PointerUnionTypeSelector {
using Return = typename PointerUnionTypeSelectorReturn<RET_NE>::Return;
};
/// Expensive (currently quadratic in sizeof(Ts...)), and so should only be
/// asserted once per instantiation of a type which requires it.
template <typename... Ts> struct TypesAreDistinct;
template <> struct TypesAreDistinct<> : std::true_type {};
template <typename... Ts>
struct TypesAreDistinct
: std::integral_constant<bool, detail::TypesAreDistinct<Ts...>::value> {};
template <typename T, typename RET_EQ, typename RET_NE>
struct PointerUnionTypeSelector<T, T, RET_EQ, RET_NE> {
using Return = typename PointerUnionTypeSelectorReturn<RET_EQ>::Return;
};
/// Find the first index where a type appears in a list of types.
///
/// FirstIndexOfType<T, Us...>::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<Us...>::value).
///
/// It is a compile-time error to instantiate when T is not present in Us, i.e.
/// if is_one_of<T, Us...>::value is false.
template <typename T, typename... Us> struct FirstIndexOfType;
template <typename T, typename U, typename... Us>
struct FirstIndexOfType<T, U, Us...>
: std::integral_constant<size_t, 1 + FirstIndexOfType<T, Us...>::value> {};
template <typename T, typename... Us>
struct FirstIndexOfType<T, T, Us...> : std::integral_constant<size_t, 0> {};
template <typename T1, typename T2, typename RET_EQ, typename RET_NE>
struct PointerUnionTypeSelectorReturn<
PointerUnionTypeSelector<T1, T2, RET_EQ, RET_NE>> {
using Return =
typename PointerUnionTypeSelector<T1, T2, RET_EQ, RET_NE>::Return;
};
/// Find the type at a given index in a list of types.
///
/// TypeAtIndex<I, Ts...> is the type at index I in Ts.
template <size_t I, typename... Ts>
using TypeAtIndex = std::tuple_element_t<I, std::tuple<Ts...>>;
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<int>({PointerLikeTypeTraits<Ts>::NumLowBitsAvailable...});
}
/// Find the index of a type in a list of types. TypeIndex<T, Us...>::Index
/// is the index of T in Us, or sizeof...(Us) if T does not appear in the
/// list.
template <typename T, typename ...Us> struct TypeIndex;
template <typename T, typename ...Us> struct TypeIndex<T, T, Us...> {
static constexpr int Index = 0;
};
template <typename T, typename U, typename... Us>
struct TypeIndex<T, U, Us...> {
static constexpr int Index = 1 + TypeIndex<T, Us...>::Index;
};
template <typename T> struct TypeIndex<T> {
static constexpr int Index = 0;
};
/// Find the first type in a list of types.
template <typename T, typename...> struct GetFirstType {
using type = T;
@@ -145,6 +148,7 @@ namespace pointer_union_detail {
/// P = (float*)0;
/// Y = P.get<float*>(); // ok.
/// X = P.get<int*>(); // runtime assertion failure.
/// PointerUnion<int*, int*> Q; // compile time failure.
template <typename... PTs>
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<PTs...>>,
0, PTs...> {
static_assert(TypesAreDistinct<PTs...>::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 <typename First, typename ...Rest>'
// 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<PTs...>::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 <typename T> bool is() const {
constexpr int Index = pointer_union_detail::TypeIndex<T, PTs...>::Index;
static_assert(Index < sizeof...(PTs),
"PointerUnion::is<T> given type not in the union");
return this->Val.getInt() == Index;
return this->Val.getInt() == FirstIndexOfType<T, PTs...>::value;
}
/// Returns the value of the specified pointer type.

View File

@@ -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

View File

@@ -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.
//
//===----------------------------------------------------------------------===//

View File

@@ -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

View File

@@ -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 <cstddef>
#include <string>
#include <string_view>
namespace wpi {
@@ -70,16 +72,16 @@ public:
/// Append from a list of std::string_views.
void append(std::initializer_list<std::string_view> 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) {

View File

@@ -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 <algorithm>
#include <cassert>
@@ -42,6 +40,8 @@
namespace wpi {
template <typename IteratorT> 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<unsigned>(N);
@@ -575,6 +571,16 @@ protected:
explicit SmallVectorImpl(unsigned N)
: SmallVectorTemplateBase<T>(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 <bool ForOverwrite> 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<true>(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<T> &SmallVectorImpl<T>::operator=(SmallVectorImpl<T> &&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<T>::operator=(::std::move(RHS));
if (N) {
SmallVectorImpl<T>::operator=(::std::move(RHS));
return *this;
}
// SmallVectorImpl<T>::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<T, N> &X) {
return X.capacity_in_bytes();
}
template <typename RangeType>
using ValueTypeFromRangeType =
typename std::remove_const<typename std::remove_reference<
decltype(*std::begin(std::declval<RangeType &>()))>::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 <unsigned Size, typename R>
SmallVector<typename std::remove_const<typename std::remove_reference<
decltype(*std::begin(std::declval<R &>()))>::type>::type,
Size>
SmallVector<ValueTypeFromRangeType<R>, Size> to_vector(R &&Range) {
return {std::begin(Range), std::end(Range)};
}
template <typename R>
SmallVector<ValueTypeFromRangeType<R>,
CalculateSmallVectorDefaultInlinedElements<
ValueTypeFromRangeType<R>>::value>
to_vector(R &&Range) {
return {std::begin(Range), std::end(Range)};
}

View File

@@ -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<std::pair<std::string_view, ValueTy>> List)
: StringMapImpl(List.size(), static_cast<unsigned>(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 <typename InputIt> 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<std::pair<std::string_view, ValueTy>> 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 <typename V>
@@ -485,13 +500,7 @@ public:
explicit StringMapKeyIterator(StringMapConstIterator<ValueTy> 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 <typename ValueTy>

View File

@@ -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

View File

@@ -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 <typename RefT>
PointerProxy(RefT &&R) : R(std::forward<RefT>(R)) {}
public:
PointerT operator->() const { return &R; }
};
public:
DerivedT operator+(DifferenceTypeT n) const {
static_assert(std::is_base_of<iterator_facade_base, DerivedT>::value,
@@ -172,19 +202,13 @@ public:
return !(static_cast<const DerivedT &>(*this) < RHS);
}
PointerT operator->() { return &static_cast<DerivedT *>(this)->operator*(); }
PointerT operator->() const {
return &static_cast<const DerivedT *>(this)->operator*();
}
ReferenceProxy operator[](DifferenceTypeT n) {
static_assert(IsRandomAccess,
"Subscripting is only defined for random access iterators.");
return ReferenceProxy(static_cast<DerivedT *>(this)->operator+(n));
PointerProxy operator->() const {
return static_cast<const DerivedT *>(this)->operator*();
}
ReferenceProxy operator[](DifferenceTypeT n) const {
static_assert(IsRandomAccess,
"Subscripting is only defined for random access iterators.");
return ReferenceProxy(static_cast<const DerivedT *>(this)->operator+(n));
return static_cast<const DerivedT *>(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 <typename RangeT, typename WrappedIteratorT =

View File

@@ -16,7 +16,6 @@
#include "wpi/SmallVector.h"
#include "wpi/span.h"
#include <cassert>
#include <chrono>
#include <cstddef>
#include <cstdint>
#include <cstring>
@@ -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<raw_ostream> 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(); }
};

View File

@@ -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<const char>(), 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 {

View File

@@ -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 <typename T>
struct DenseMapInfo<T, std::enable_if_t<std::is_base_of<A, T>::value>> {
static inline T getEmptyKey() { return {static_cast<int>(~0)}; }
static inline T getTombstoneKey() { return {static_cast<int>(~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<B, int> 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

View File

@@ -291,4 +291,23 @@ TEST(UniqueFunctionTest, IncompleteTypes) {
unique_function<Templated<Incomplete> *()> 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<Incomplete()> IncompleteReturnInCallable{incompleteFunction};
unique_function<const Incomplete()> IncompleteReturnInCallableConst{
incompleteFunctionConst};
unique_function<const Incomplete()> IncompleteReturnInCallableConstConversion{
incompleteFunction};
}
// Define the incomplete function
class Incomplete {};
Incomplete incompleteFunction() { return {}; }
const Incomplete incompleteFunctionConst() { return {}; }
} // anonymous namespace

View File

@@ -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");

View File

@@ -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<uint32_t>({{"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<int> Map;
Map["A"] = 1;
Map["B"] = 2;