blob: 5071ee77ac436e6c8928ab1895be0d4b76db184a [file] [log] [blame]
Jim Grosbach0b6a44a2011-06-21 22:55:50 +00001//===- Error.cpp - tblgen error handling helper routines --------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains error handling helper routines to pretty-print diagnostic
11// messages from tblgen.
12//
13//===----------------------------------------------------------------------===//
14
Peter Collingbourne7c788882011-10-01 16:41:13 +000015#include "llvm/TableGen/Error.h"
Jim Grosbach0b6a44a2011-06-21 22:55:50 +000016#include "llvm/ADT/Twine.h"
17#include "llvm/Support/raw_ostream.h"
18
19namespace llvm {
20
21SourceMgr SrcMgr;
22
23void PrintError(SMLoc ErrorLoc, const Twine &Msg) {
Chris Lattner3f2d5f62011-10-16 05:43:57 +000024 SrcMgr.PrintMessage(ErrorLoc, SourceMgr::DK_Error, Msg);
Jim Grosbach0b6a44a2011-06-21 22:55:50 +000025}
26
27void PrintError(const char *Loc, const Twine &Msg) {
Chris Lattner3f2d5f62011-10-16 05:43:57 +000028 SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Error, Msg);
Jim Grosbach0b6a44a2011-06-21 22:55:50 +000029}
30
31void PrintError(const Twine &Msg) {
32 errs() << "error:" << Msg << "\n";
33}
34
35void PrintError(const TGError &Error) {
36 PrintError(Error.getLoc(), Error.getMessage());
37}
38
39} // end namespace llvm