Files
allwpilib/upstream_utils/llvm_patches/0017-ErrorHandling-prefer-fmtlib.patch
2026-05-26 21:55:50 -07:00

55 lines
2.2 KiB
Diff

From 0000000000000000000000000000000000000000 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 17/34] ErrorHandling: prefer fmtlib
---
llvm/lib/Support/ErrorHandling.cpp | 19 ++++++-------------
1 file changed, 6 insertions(+), 13 deletions(-)
diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
index 69328303a1cc0cc6e210de5adbb4fdafafbe978f..cb455ed43ffba58443fd71dcdb2e60cc7fc812a6 100644
--- a/llvm/lib/Support/ErrorHandling.cpp
+++ b/llvm/lib/Support/ErrorHandling.cpp
@@ -23,7 +23,7 @@
#include "llvm/Support/Signals.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/WindowsError.h"
-#include "llvm/Support/raw_ostream.h"
+#include "wpi/util/print.hpp"
#include <cassert>
#include <cstdlib>
#include <mutex>
@@ -109,14 +109,7 @@ void llvm::report_fatal_error(std::string_view Reason, bool GenCrashDiag) {
if (handler) {
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
- // raw ostreams can call report_fatal_error.
- SmallVector<char, 64> Buffer;
- raw_svector_ostream OS(Buffer);
- OS << "LLVM ERROR: " << Reason << "\n";
- std::string_view MessageStr = OS.str();
- write_retry(2, MessageStr.data(), MessageStr.size());
+ wpi::util::print(stderr, "LLVM ERROR: {}\n", Reason);
}
exit(1);
@@ -203,11 +196,11 @@ void llvm::llvm_unreachable_internal(const char *msg, const char *file,
// llvm_unreachable is intended to be used to indicate "impossible"
// situations, and not legitimate runtime errors.
if (msg)
- dbgs() << msg << "\n";
- dbgs() << "UNREACHABLE executed";
+ wpi::util::print(stderr, "{}\n", msg);
+ std::fputs("UNREACHABLE executed", stderr);
if (file)
- dbgs() << " at " << file << ":" << line;
- dbgs() << "!\n";
+ wpi::util::print(stderr, " at {}:{}", file, line);
+ wpi::util::print(stderr, "!\n");
abort();
#ifdef LLVM_BUILTIN_UNREACHABLE
// Windows systems and possibly others don't declare abort() to be noreturn,