mirror of
https://github.com/intel/llvm.git
synced 2026-01-28 09:14:23 +08:00
https://commondatastorage.googleapis.com/chromium-browser-clang/llvm-include-analysis.html Excessive use of the <string> 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 <string> 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
32 lines
1.3 KiB
C++
32 lines
1.3 KiB
C++
/*===-- clang-c/FatalErrorHandler.cpp - Fatal Error Handling ------*- C -*-===*\
|
|
|* *|
|
|
|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
|
|
|* Exceptions. *|
|
|
|* See https://llvm.org/LICENSE.txt for license information. *|
|
|
|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
|
|
|* *|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
#include "clang-c/FatalErrorHandler.h"
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
#include <stdlib.h>
|
|
|
|
static void aborting_fatal_error_handler(void *, const char *reason,
|
|
bool) {
|
|
// Write the result out to stderr avoiding errs() because raw_ostreams can
|
|
// call report_fatal_error.
|
|
fprintf(stderr, "LIBCLANG FATAL ERROR: %s\n", reason);
|
|
::abort();
|
|
}
|
|
|
|
extern "C" {
|
|
void clang_install_aborting_llvm_fatal_error_handler(void) {
|
|
llvm::remove_fatal_error_handler();
|
|
llvm::install_fatal_error_handler(aborting_fatal_error_handler, nullptr);
|
|
}
|
|
|
|
void clang_uninstall_llvm_fatal_error_handler(void) {
|
|
llvm::remove_fatal_error_handler();
|
|
}
|
|
}
|