In preparation for removing exception handling in tablegen, add
authorJoerg Sonnenberger <joerg@bec.de>
Thu, 25 Oct 2012 16:35:18 +0000 (16:35 +0000)
committerJoerg Sonnenberger <joerg@bec.de>
Thu, 25 Oct 2012 16:35:18 +0000 (16:35 +0000)
PrintFatalError, which combines PrintError with exit(1).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166690 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/TableGen/Error.h
lib/TableGen/Error.cpp

index 5c1c3adf7e74ea518826b0b8ae6d5aca6c6b527f..3f7b7f4e8c41bd4d3a95c7ef412024a5d6a99a50 100644 (file)
@@ -40,6 +40,9 @@ void PrintError(const char *Loc, const Twine &Msg);
 void PrintError(const Twine &Msg);
 void PrintError(const TGError &Error);
 
+LLVM_ATTRIBUTE_NORETURN void PrintFatalError(const std::string &Msg);
+LLVM_ATTRIBUTE_NORETURN void PrintFatalError(ArrayRef<SMLoc> ErrorLoc,
+                                             const std::string &Msg);
 
 extern SourceMgr SrcMgr;
 
index 5dd688cb6750b51914390b46b829e15f734de061..ad98fba9baf6c2991138c303a868872157fed9cb 100644 (file)
@@ -16,6 +16,8 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/raw_ostream.h"
 
+#include <cstdlib>
+
 namespace llvm {
 
 SourceMgr SrcMgr;
@@ -63,4 +65,14 @@ void PrintError(const TGError &Error) {
   PrintError(Error.getLoc(), Error.getMessage());
 }
 
+void PrintFatalError(const std::string &Msg) {
+  PrintError(Twine(Msg));
+  std::exit(1);
+}
+
+void PrintFatalError(ArrayRef<SMLoc> ErrorLoc, const std::string &Msg) {
+  PrintError(ErrorLoc, Msg);
+  std::exit(1);
+}
+
 } // end namespace llvm