From: Daniel Dunbar Date: Fri, 24 Jul 2009 07:58:10 +0000 (+0000) Subject: Allow llvm_report_error to accept a Twine. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=82a29b6a02324e65847ed99bae84dafb2755ea32;p=oota-llvm.git Allow llvm_report_error to accept a Twine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76961 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Support/ErrorHandling.h b/include/llvm/Support/ErrorHandling.h index bdee5b1c24b..94541b52f7f 100644 --- a/include/llvm/Support/ErrorHandling.h +++ b/include/llvm/Support/ErrorHandling.h @@ -19,6 +19,8 @@ #include namespace llvm { + class Twine; + /// An error handler callback. typedef void (*llvm_error_handler_t)(const std::string& reason); @@ -44,7 +46,9 @@ namespace llvm { /// standard error, followed by a newline. /// After the error handler is called this function will call exit(1), it /// does not return. + void llvm_report_error(const char *reason) NORETURN; void llvm_report_error(const std::string &reason) NORETURN; + void llvm_report_error(const Twine &reason) NORETURN; /// This function calls abort(), and prints the optional message to stderr. /// Use the llvm_unreachable macro (that adds location info), instead of diff --git a/lib/Support/ErrorHandling.cpp b/lib/Support/ErrorHandling.cpp index e1ee1880c62..d60dc1d2ad2 100644 --- a/lib/Support/ErrorHandling.cpp +++ b/lib/Support/ErrorHandling.cpp @@ -12,7 +12,7 @@ // Callbacks can be registered for these errors through this API. //===----------------------------------------------------------------------===// -#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/Twine.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Threading.h" @@ -35,16 +35,25 @@ void llvm_remove_error_handler(void) { ErrorHandler = 0; } +void llvm_report_error(const char *reason) { + llvm_report_error(Twine(reason)); +} + void llvm_report_error(const std::string &reason) { + llvm_report_error(Twine(reason)); +} + +void llvm_report_error(const Twine &reason) { if (!ErrorHandler) { errs() << "LLVM ERROR: " << reason << "\n"; } else { - ErrorHandler(reason); + ErrorHandler(reason.str()); } exit(1); } -void llvm_unreachable_internal(const char *msg, const char *file, unsigned line) { +void llvm_unreachable_internal(const char *msg, const char *file, + unsigned line) { if (msg) errs() << msg << "\n"; errs() << "UNREACHABLE executed";