summaryrefslogtreecommitdiffstats
path: root/llvm/lib/TableGen/Error.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2011-10-01 16:41:13 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2011-10-01 16:41:13 +0000
commit84c287e33cc3f46e7d6868de14809bd5ae4a84b1 (patch)
treead37ce90aefb034b6343822dd390be8a46cbd31c /llvm/lib/TableGen/Error.cpp
parent20dde1e8fb1c757eef7b3340f4500729abb6c0fa (diff)
downloadbcm5719-llvm-84c287e33cc3f46e7d6868de14809bd5ae4a84b1.tar.gz
bcm5719-llvm-84c287e33cc3f46e7d6868de14809bd5ae4a84b1.zip
Move TableGen's parser and entry point into a library
This is the first step towards splitting LLVM and Clang's tblgen executables. llvm-svn: 140951
Diffstat (limited to 'llvm/lib/TableGen/Error.cpp')
-rw-r--r--llvm/lib/TableGen/Error.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/llvm/lib/TableGen/Error.cpp b/llvm/lib/TableGen/Error.cpp
new file mode 100644
index 00000000000..5b2cbbfec4b
--- /dev/null
+++ b/llvm/lib/TableGen/Error.cpp
@@ -0,0 +1,39 @@
+//===- Error.cpp - tblgen error handling helper routines --------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains error handling helper routines to pretty-print diagnostic
+// messages from tblgen.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/TableGen/Error.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace llvm {
+
+SourceMgr SrcMgr;
+
+void PrintError(SMLoc ErrorLoc, const Twine &Msg) {
+ SrcMgr.PrintMessage(ErrorLoc, Msg, "error");
+}
+
+void PrintError(const char *Loc, const Twine &Msg) {
+ SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), Msg, "error");
+}
+
+void PrintError(const Twine &Msg) {
+ errs() << "error:" << Msg << "\n";
+}
+
+void PrintError(const TGError &Error) {
+ PrintError(Error.getLoc(), Error.getMessage());
+}
+
+} // end namespace llvm
OpenPOWER on IntegriCloud