[llvm-commits] [llvm] r76961 - in /llvm/trunk: include/llvm/Support/ErrorHandling.h lib/Support/ErrorHandling.cpp

Daniel Dunbar daniel at zuster.org
Fri Jul 24 00:58:26 PDT 2009


Author: ddunbar
Date: Fri Jul 24 02:58:10 2009
New Revision: 76961

URL: http://llvm.org/viewvc/llvm-project?rev=76961&view=rev
Log:
Allow llvm_report_error to accept a Twine.

Modified:
    llvm/trunk/include/llvm/Support/ErrorHandling.h
    llvm/trunk/lib/Support/ErrorHandling.cpp

Modified: llvm/trunk/include/llvm/Support/ErrorHandling.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ErrorHandling.h?rev=76961&r1=76960&r2=76961&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/ErrorHandling.h (original)
+++ llvm/trunk/include/llvm/Support/ErrorHandling.h Fri Jul 24 02:58:10 2009
@@ -19,6 +19,8 @@
 #include <string>
 
 namespace llvm {
+  class Twine;
+
   /// An error handler callback.
   typedef void (*llvm_error_handler_t)(const std::string& reason);
 
@@ -44,7 +46,9 @@
   /// 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

Modified: llvm/trunk/lib/Support/ErrorHandling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ErrorHandling.cpp?rev=76961&r1=76960&r2=76961&view=diff

==============================================================================
--- llvm/trunk/lib/Support/ErrorHandling.cpp (original)
+++ llvm/trunk/lib/Support/ErrorHandling.cpp Fri Jul 24 02:58:10 2009
@@ -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 @@
   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";





More information about the llvm-commits mailing list