From e463b69736da8b0a950ecd937cf990401bdfcdeb Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Tue, 5 Oct 2021 10:51:28 +0100 Subject: [Support] Change fatal_error_handler_t to take a const char* instead of std::string https://commondatastorage.googleapis.com/chromium-browser-clang/llvm-include-analysis.html Excessive use of the header has a massive impact on compile time; its most commonly included via the ErrorHandling.h header, which has to be included in many key headers, impacting many source files that have no need for std::string. As an initial step toward removing the include from ErrorHandling.h, this patch proposes to update the fatal_error_handler_t handler to just take a raw const char* instead. The next step will be to remove the report_fatal_error std::string variant, which will involve a lot of cleanup and better use of Twine/StringRef. Differential Revision: https://reviews.llvm.org/D111049 --- llvm/lib/Support/ErrorHandling.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'llvm/lib/Support/ErrorHandling.cpp') diff --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp index ce63442..b15c36f 100644 --- a/llvm/lib/Support/ErrorHandling.cpp +++ b/llvm/lib/Support/ErrorHandling.cpp @@ -105,7 +105,7 @@ void llvm::report_fatal_error(const Twine &Reason, bool GenCrashDiag) { } if (handler) { - handler(handlerData, Reason.str(), GenCrashDiag); + handler(handlerData, Reason.str().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 @@ -218,11 +218,11 @@ void llvm::llvm_unreachable_internal(const char *msg, const char *file, #endif } -static void bindingsErrorHandler(void *user_data, const std::string& reason, +static void bindingsErrorHandler(void *user_data, const char *reason, bool gen_crash_diag) { LLVMFatalErrorHandler handler = LLVM_EXTENSION reinterpret_cast(user_data); - handler(reason.c_str()); + handler(reason); } void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler) { -- cgit v1.1