forked from OSchip/llvm-project
[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 <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
This commit is contained in:
parent
0a031f5c88
commit
e463b69736
|
@ -32,7 +32,7 @@ static llvm::cl::list<std::string> OptInputs(llvm::cl::Positional,
|
|||
llvm::cl::ZeroOrMore,
|
||||
llvm::cl::desc("[code to run]"));
|
||||
|
||||
static void LLVMErrorHandler(void *UserData, const std::string &Message,
|
||||
static void LLVMErrorHandler(void *UserData, const char *Message,
|
||||
bool GenCrashDiag) {
|
||||
auto &Diags = *static_cast<clang::DiagnosticsEngine *>(UserData);
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ using namespace llvm::opt;
|
|||
// Main driver
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
static void LLVMErrorHandler(void *UserData, const std::string &Message,
|
||||
static void LLVMErrorHandler(void *UserData, const char *Message,
|
||||
bool GenCrashDiag) {
|
||||
DiagnosticsEngine &Diags = *static_cast<DiagnosticsEngine*>(UserData);
|
||||
|
||||
|
|
|
@ -550,7 +550,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
|
|||
return Failed;
|
||||
}
|
||||
|
||||
static void LLVMErrorHandler(void *UserData, const std::string &Message,
|
||||
static void LLVMErrorHandler(void *UserData, const char *Message,
|
||||
bool GenCrashDiag) {
|
||||
DiagnosticsEngine &Diags = *static_cast<DiagnosticsEngine*>(UserData);
|
||||
|
||||
|
|
|
@ -11,11 +11,11 @@
|
|||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
static void aborting_fatal_error_handler(void *, const std::string &reason,
|
||||
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.c_str());
|
||||
fprintf(stderr, "LIBCLANG FATAL ERROR: %s\n", reason);
|
||||
::abort();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@
|
|||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
class StringRef;
|
||||
class StringRef;
|
||||
class Twine;
|
||||
|
||||
/// 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
|
||||
|
|
|
@ -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<LLVMFatalErrorHandler>(user_data);
|
||||
handler(reason.c_str());
|
||||
handler(reason);
|
||||
}
|
||||
|
||||
void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler) {
|
||||
|
|
|
@ -30,7 +30,7 @@ static jmp_buf JmpBuf;
|
|||
|
||||
namespace {
|
||||
|
||||
void MyFatalErrorHandler(void *user_data, const std::string& reason,
|
||||
void MyFatalErrorHandler(void *user_data, const char *reason,
|
||||
bool gen_crash_diag) {
|
||||
// Don't bother printing reason, just return to the test function,
|
||||
// since a fatal error represents a successful parse (i.e. it correctly
|
||||
|
|
|
@ -107,7 +107,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void handleLLVMFatalError(void *, const std::string &Message, bool) {
|
||||
static void handleLLVMFatalError(void *, const char *Message, bool) {
|
||||
// TODO: Would it be better to call into the fuzzer internals directly?
|
||||
dbgs() << "LLVM ERROR: " << Message << "\n"
|
||||
<< "Aborting to trigger fuzzer exit handling.\n";
|
||||
|
|
|
@ -170,7 +170,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void handleLLVMFatalError(void *, const std::string &Message, bool) {
|
||||
static void handleLLVMFatalError(void *, const char *Message, bool) {
|
||||
// TODO: Would it be better to call into the fuzzer internals directly?
|
||||
dbgs() << "LLVM ERROR: " << Message << "\n"
|
||||
<< "Aborting to trigger fuzzer exit handling.\n";
|
||||
|
|
Loading…
Reference in New Issue