mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
HAND FIXES: Update upstream for namespace changes
This commit is contained in:
committed by
Peter Johnson
parent
cf711a125e
commit
ae6c043632
@@ -17,8 +17,8 @@ def copy_upstream_src(wpilib_root: Path):
|
|||||||
# Rename namespace from argparse to wpi
|
# Rename namespace from argparse to wpi
|
||||||
with open(dest_filename) as f:
|
with open(dest_filename) as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
content = content.replace("namespace argparse", "namespace wpi")
|
content = content.replace("namespace argparse", "namespace wpi::util")
|
||||||
content = content.replace("argparse::", "wpi::")
|
content = content.replace("argparse::", "wpi::util::")
|
||||||
content = content.replace("ARGPARSE_", "WPI_")
|
content = content.replace("ARGPARSE_", "WPI_")
|
||||||
with open(dest_filename, "w") as f:
|
with open(dest_filename, "w") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ def copy_upstream_src(wpilib_root: Path):
|
|||||||
content = f.read()
|
content = f.read()
|
||||||
|
|
||||||
# Rename namespace from stdx to wpi
|
# Rename namespace from stdx to wpi
|
||||||
content = content.replace("namespace stdx", "namespace wpi")
|
content = content.replace("namespace stdx", "namespace wpi::util")
|
||||||
|
|
||||||
with open(filename, "w") as f:
|
with open(filename, "w") as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
|||||||
@@ -22,13 +22,13 @@ index 0000000000000000000000000000000000000000..16924894cc0c6085b27b33e6b9f2a6e6
|
|||||||
+# include <fstream>
|
+# include <fstream>
|
||||||
+# include <string>
|
+# include <string>
|
||||||
+
|
+
|
||||||
+namespace wpi {
|
+namespace wpi::util {
|
||||||
+
|
+
|
||||||
+bool is_debugger_present() noexcept
|
+bool is_debugger_present() noexcept
|
||||||
+{
|
+{
|
||||||
+ return false;
|
+ return false;
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+} // namespace wpi
|
+} // namespace wpi::util
|
||||||
+
|
+
|
||||||
+#endif
|
+#endif
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ def copy_upstream_src(wpilib_root: Path):
|
|||||||
# Rename namespace from tl to wpi, and detail to detail_expected
|
# Rename namespace from tl to wpi, and detail to detail_expected
|
||||||
with open(dest_filename) as f:
|
with open(dest_filename) as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
content = content.replace("namespace tl", "namespace wpi")
|
content = content.replace("namespace tl", "namespace wpi::util")
|
||||||
content = content.replace("tl::", "wpi::")
|
content = content.replace("tl::", "wpi::util::")
|
||||||
content = content.replace("TL_", "WPI_")
|
content = content.replace("TL_", "WPI_")
|
||||||
content = content.replace("namespace detail", "namespace detail_expected")
|
content = content.replace("namespace detail", "namespace detail_expected")
|
||||||
content = content.replace("detail::", "detail_expected::")
|
content = content.replace("detail::", "detail_expected::")
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ def copy_upstream_src(wpilib_root: Path):
|
|||||||
content = f.read()
|
content = f.read()
|
||||||
|
|
||||||
# Rename namespace from nlohmann to wpi
|
# Rename namespace from nlohmann to wpi
|
||||||
content = content.replace("namespace nlohmann", "namespace wpi")
|
content = content.replace("namespace nlohmann", "namespace wpi::util")
|
||||||
content = content.replace("nlohmann::", "wpi::")
|
content = content.replace("nlohmann::", "wpi::util::")
|
||||||
|
|
||||||
# Fix internal includes
|
# Fix internal includes
|
||||||
content = content.replace("include <nlohmann/", "include <wpi/util/")
|
content = content.replace("include <nlohmann/", "include <wpi/util/")
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ def run_global_replacements(wpiutil_llvm_files: list[Path]):
|
|||||||
content = f.read()
|
content = f.read()
|
||||||
|
|
||||||
# Rename namespace from llvm to wpi
|
# Rename namespace from llvm to wpi
|
||||||
content = content.replace("namespace llvm", "namespace wpi")
|
content = content.replace("namespace llvm", "namespace wpi::util")
|
||||||
content = content.replace("llvm:", "wpi:")
|
content = content.replace("llvm:", "wpi::util:")
|
||||||
|
|
||||||
# Fix #includes
|
# Fix #includes
|
||||||
content = content.replace('include "llvm/ADT', 'include "wpi/util')
|
content = content.replace('include "llvm/ADT', 'include "wpi/util')
|
||||||
@@ -83,10 +83,10 @@ def run_global_replacements(wpiutil_llvm_files: list[Path]):
|
|||||||
content = content.replace("llvm_is_multithreaded()", "1")
|
content = content.replace("llvm_is_multithreaded()", "1")
|
||||||
|
|
||||||
# Revert message in copyright header
|
# Revert message in copyright header
|
||||||
content = content.replace("/// Defines the wpi::", "/// Defines the llvm::")
|
content = content.replace("/// Defines the wpi::util::", "/// Defines the llvm::")
|
||||||
content = content.replace("// end llvm namespace", "// end wpi namespace")
|
content = content.replace("// end llvm namespace", "// end wpi::util namespace")
|
||||||
content = content.replace("// end namespace llvm", "// end namespace wpi")
|
content = content.replace("// end namespace llvm", "// end namespace wpi::util")
|
||||||
content = content.replace("// End llvm namespace", "// End wpi namespace")
|
content = content.replace("// End llvm namespace", "// End wpi::util namespace")
|
||||||
|
|
||||||
content = content.replace("fs::openFileForRead", "fs::OpenFileForRead")
|
content = content.replace("fs::openFileForRead", "fs::OpenFileForRead")
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ index 83d5586ae8a77ec585e7e59df3075ca59cfb9d0c..395965bc6fc969ed9a2d92743a0010dd
|
|||||||
} // end namespace llvm.
|
} // end namespace llvm.
|
||||||
|
|
||||||
diff --git a/llvm/lib/Support/ConvertUTF.cpp b/llvm/lib/Support/ConvertUTF.cpp
|
diff --git a/llvm/lib/Support/ConvertUTF.cpp b/llvm/lib/Support/ConvertUTF.cpp
|
||||||
index bc04c5ab5113563fb82d7b3b168985369b611f4b..15e9a4e5b4cba5802c053e22e0536b0820615dd2 100644
|
index bc04c5ab5113563fb82d7b3b168985369b611f4b..b1012d896bd8ba9e07221f87a358b90fe203b172 100644
|
||||||
--- a/llvm/lib/Support/ConvertUTF.cpp
|
--- a/llvm/lib/Support/ConvertUTF.cpp
|
||||||
+++ b/llvm/lib/Support/ConvertUTF.cpp
|
+++ b/llvm/lib/Support/ConvertUTF.cpp
|
||||||
@@ -67,6 +67,11 @@
|
@@ -67,6 +67,11 @@
|
||||||
@@ -116,7 +116,7 @@ index bc04c5ab5113563fb82d7b3b168985369b611f4b..15e9a4e5b4cba5802c053e22e0536b08
|
|||||||
+namespace windows {
|
+namespace windows {
|
||||||
+std::error_code CodePageToUTF16(unsigned codepage,
|
+std::error_code CodePageToUTF16(unsigned codepage,
|
||||||
+ std::string_view original,
|
+ std::string_view original,
|
||||||
+ wpi::SmallVectorImpl<wchar_t> &utf16) {
|
+ wpi::util::SmallVectorImpl<wchar_t> &utf16) {
|
||||||
+ if (!original.empty()) {
|
+ if (!original.empty()) {
|
||||||
+ int len = ::MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, original.data(),
|
+ int len = ::MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, original.data(),
|
||||||
+ original.size(), utf16.begin(), 0);
|
+ original.size(), utf16.begin(), 0);
|
||||||
@@ -144,19 +144,19 @@ index bc04c5ab5113563fb82d7b3b168985369b611f4b..15e9a4e5b4cba5802c053e22e0536b08
|
|||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+std::error_code UTF8ToUTF16(std::string_view utf8,
|
+std::error_code UTF8ToUTF16(std::string_view utf8,
|
||||||
+ wpi::SmallVectorImpl<wchar_t> &utf16) {
|
+ wpi::util::SmallVectorImpl<wchar_t> &utf16) {
|
||||||
+ return CodePageToUTF16(CP_UTF8, utf8, utf16);
|
+ return CodePageToUTF16(CP_UTF8, utf8, utf16);
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+std::error_code CurCPToUTF16(std::string_view curcp,
|
+std::error_code CurCPToUTF16(std::string_view curcp,
|
||||||
+ wpi::SmallVectorImpl<wchar_t> &utf16) {
|
+ wpi::util::SmallVectorImpl<wchar_t> &utf16) {
|
||||||
+ return CodePageToUTF16(CP_ACP, curcp, utf16);
|
+ return CodePageToUTF16(CP_ACP, curcp, utf16);
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+static
|
+static
|
||||||
+std::error_code UTF16ToCodePage(unsigned codepage, const wchar_t *utf16,
|
+std::error_code UTF16ToCodePage(unsigned codepage, const wchar_t *utf16,
|
||||||
+ size_t utf16_len,
|
+ size_t utf16_len,
|
||||||
+ wpi::SmallVectorImpl<char> &converted) {
|
+ wpi::util::SmallVectorImpl<char> &converted) {
|
||||||
+ if (utf16_len) {
|
+ if (utf16_len) {
|
||||||
+ // Get length.
|
+ // Get length.
|
||||||
+ int len = ::WideCharToMultiByte(codepage, 0, utf16, utf16_len, converted.begin(),
|
+ int len = ::WideCharToMultiByte(codepage, 0, utf16, utf16_len, converted.begin(),
|
||||||
@@ -186,12 +186,12 @@ index bc04c5ab5113563fb82d7b3b168985369b611f4b..15e9a4e5b4cba5802c053e22e0536b08
|
|||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+std::error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len,
|
+std::error_code UTF16ToUTF8(const wchar_t *utf16, size_t utf16_len,
|
||||||
+ wpi::SmallVectorImpl<char> &utf8) {
|
+ wpi::util::SmallVectorImpl<char> &utf8) {
|
||||||
+ return UTF16ToCodePage(CP_UTF8, utf16, utf16_len, utf8);
|
+ return UTF16ToCodePage(CP_UTF8, utf16, utf16_len, utf8);
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+std::error_code UTF16ToCurCP(const wchar_t *utf16, size_t utf16_len,
|
+std::error_code UTF16ToCurCP(const wchar_t *utf16, size_t utf16_len,
|
||||||
+ wpi::SmallVectorImpl<char> &curcp) {
|
+ wpi::util::SmallVectorImpl<char> &curcp) {
|
||||||
+ return UTF16ToCodePage(CP_ACP, utf16, utf16_len, curcp);
|
+ return UTF16ToCodePage(CP_ACP, utf16, utf16_len, curcp);
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Subject: [PATCH 19/36] Prefer fmtlib
|
|||||||
1 file changed, 6 insertions(+), 14 deletions(-)
|
1 file changed, 6 insertions(+), 14 deletions(-)
|
||||||
|
|
||||||
diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
|
diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
|
||||||
index d0fd67bd3c0d4cf33922cdda042531424d277951..2f160c45b47cf57bb28f6393dd56cde06089639b 100644
|
index d0fd67bd3c0d4cf33922cdda042531424d277951..c153b91391fe63e819e4907ac98d2ee26228107a 100644
|
||||||
--- a/llvm/lib/Support/ErrorHandling.cpp
|
--- a/llvm/lib/Support/ErrorHandling.cpp
|
||||||
+++ b/llvm/lib/Support/ErrorHandling.cpp
|
+++ b/llvm/lib/Support/ErrorHandling.cpp
|
||||||
@@ -22,7 +22,7 @@
|
@@ -22,7 +22,7 @@
|
||||||
@@ -33,7 +33,7 @@ index d0fd67bd3c0d4cf33922cdda042531424d277951..2f160c45b47cf57bb28f6393dd56cde0
|
|||||||
- std::string_view MessageStr = OS.str();
|
- std::string_view MessageStr = OS.str();
|
||||||
- ssize_t written = ::write(2, MessageStr.data(), MessageStr.size());
|
- ssize_t written = ::write(2, MessageStr.data(), MessageStr.size());
|
||||||
- (void)written; // If something went wrong, we deliberately just give up.
|
- (void)written; // If something went wrong, we deliberately just give up.
|
||||||
+ wpi::print(stderr, "LLVM ERROR: {}\n", Reason);
|
+ wpi::util::print(stderr, "LLVM ERROR: {}\n", Reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we reached here, we are failing ungracefully. Run the interrupt handlers
|
// If we reached here, we are failing ungracefully. Run the interrupt handlers
|
||||||
@@ -43,13 +43,13 @@ index d0fd67bd3c0d4cf33922cdda042531424d277951..2f160c45b47cf57bb28f6393dd56cde0
|
|||||||
if (msg)
|
if (msg)
|
||||||
- dbgs() << msg << "\n";
|
- dbgs() << msg << "\n";
|
||||||
- dbgs() << "UNREACHABLE executed";
|
- dbgs() << "UNREACHABLE executed";
|
||||||
+ wpi::print(stderr, "{}\n", msg);
|
+ wpi::util::print(stderr, "{}\n", msg);
|
||||||
+ std::fputs("UNREACHABLE executed", stderr);
|
+ std::fputs("UNREACHABLE executed", stderr);
|
||||||
if (file)
|
if (file)
|
||||||
- dbgs() << " at " << file << ":" << line;
|
- dbgs() << " at " << file << ":" << line;
|
||||||
- dbgs() << "!\n";
|
- dbgs() << "!\n";
|
||||||
+ wpi::print(stderr, " at {}:{}", file, line);
|
+ wpi::util::print(stderr, " at {}:{}", file, line);
|
||||||
+ wpi::print(stderr, "!\n");
|
+ wpi::util::print(stderr, "!\n");
|
||||||
abort();
|
abort();
|
||||||
#ifdef LLVM_BUILTIN_UNREACHABLE
|
#ifdef LLVM_BUILTIN_UNREACHABLE
|
||||||
// Windows systems and possibly others don't declare abort() to be noreturn,
|
// Windows systems and possibly others don't declare abort() to be noreturn,
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ index 990d3e4cfe53e025df6ce797f46f9de5af8ca6dc..264b8192a0473b94363765995517851c
|
|||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Subclass Interface
|
// Subclass Interface
|
||||||
diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
|
diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
|
||||||
index 2f160c45b47cf57bb28f6393dd56cde06089639b..9ef6f7da66c66a35b1ce63e603e8590c214f9843 100644
|
index c153b91391fe63e819e4907ac98d2ee26228107a..c9bb71be96f0ea3ad26c61cfa8ab35dfa6f60d02 100644
|
||||||
--- a/llvm/lib/Support/ErrorHandling.cpp
|
--- a/llvm/lib/Support/ErrorHandling.cpp
|
||||||
+++ b/llvm/lib/Support/ErrorHandling.cpp
|
+++ b/llvm/lib/Support/ErrorHandling.cpp
|
||||||
@@ -182,22 +182,6 @@ void llvm::llvm_unreachable_internal(const char *msg, const char *file,
|
@@ -182,22 +182,6 @@ void llvm::llvm_unreachable_internal(const char *msg, const char *file,
|
||||||
|
|||||||
@@ -8,11 +8,11 @@ Subject: [PATCH 22/36] OS-specific changes
|
|||||||
1 file changed, 7 insertions(+), 9 deletions(-)
|
1 file changed, 7 insertions(+), 9 deletions(-)
|
||||||
|
|
||||||
diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
|
diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
|
||||||
index 9ef6f7da66c66a35b1ce63e603e8590c214f9843..4436b8e7f3a68ba85f184ee71014b9c1e0511d8a 100644
|
index c9bb71be96f0ea3ad26c61cfa8ab35dfa6f60d02..01d46c847d274628fc2a8a39c44f0588b8c1bb06 100644
|
||||||
--- a/llvm/lib/Support/ErrorHandling.cpp
|
--- a/llvm/lib/Support/ErrorHandling.cpp
|
||||||
+++ b/llvm/lib/Support/ErrorHandling.cpp
|
+++ b/llvm/lib/Support/ErrorHandling.cpp
|
||||||
@@ -96,15 +96,7 @@ void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) {
|
@@ -96,15 +96,7 @@ void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) {
|
||||||
wpi::print(stderr, "LLVM ERROR: {}\n", Reason);
|
wpi::util::print(stderr, "LLVM ERROR: {}\n", Reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
- // If we reached here, we are failing ungracefully. Run the interrupt handlers
|
- // If we reached here, we are failing ungracefully. Run the interrupt handlers
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ def copy_upstream_src(wpilib_root: Path):
|
|||||||
namespace gch {
|
namespace gch {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using small_vector = wpi::SmallVector<T>;
|
using small_vector = wpi::util::SmallVector<T>;
|
||||||
|
|
||||||
} // namespace gch
|
} // namespace gch
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ index a2f94803e3744cee771669210d1af883160e9896..43dcc748b679eac89986b154b26a1c02
|
|||||||
void write32le(int32_t num) {
|
void write32le(int32_t num) {
|
||||||
if constexpr (std::endian::native != std::endian::little) {
|
if constexpr (std::endian::native != std::endian::little) {
|
||||||
- num = std::byteswap(num);
|
- num = std::byteswap(num);
|
||||||
+ num = wpi::byteswap(num);
|
+ num = wpi::util::byteswap(num);
|
||||||
}
|
}
|
||||||
m_file.write(reinterpret_cast<char*>(&num), sizeof(num));
|
m_file.write(reinterpret_cast<char*>(&num), sizeof(num));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user