Error.cpp revision 234982
1285101Semaste//===- Error.cpp - tblgen error handling helper routines --------*- C++ -*-===//
2285101Semaste//
3285101Semaste//                     The LLVM Compiler Infrastructure
4285101Semaste//
5285101Semaste// This file is distributed under the University of Illinois Open Source
6285101Semaste// License. See LICENSE.TXT for details.
7285101Semaste//
8285101Semaste//===----------------------------------------------------------------------===//
9285101Semaste//
10285101Semaste// This file contains error handling helper routines to pretty-print diagnostic
11285101Semaste// messages from tblgen.
12285101Semaste//
13285101Semaste//===----------------------------------------------------------------------===//
14285101Semaste
15285101Semaste#include "llvm/TableGen/Error.h"
16285101Semaste#include "llvm/ADT/Twine.h"
17285101Semaste#include "llvm/Support/raw_ostream.h"
18285101Semaste
19285101Semastenamespace llvm {
20285101Semaste
21285101SemasteSourceMgr SrcMgr;
22287505Sdim
23285101Semastevoid PrintWarning(SMLoc WarningLoc, const Twine &Msg) {
24285101Semaste  SrcMgr.PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg);
25285101Semaste}
26285101Semaste
27285101Semastevoid PrintWarning(const char *Loc, const Twine &Msg) {
28285101Semaste  SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Warning, Msg);
29285101Semaste}
30287505Sdim
31285101Semastevoid PrintWarning(const Twine &Msg) {
32285101Semaste  errs() << "warning:" << Msg << "\n";
33285101Semaste}
34285101Semaste
35285101Semastevoid PrintWarning(const TGError &Warning) {
36285101Semaste  PrintWarning(Warning.getLoc(), Warning.getMessage());
37285101Semaste}
38285101Semaste
39285101Semastevoid PrintError(SMLoc ErrorLoc, const Twine &Msg) {
40285101Semaste  SrcMgr.PrintMessage(ErrorLoc, SourceMgr::DK_Error, Msg);
41285101Semaste}
42285101Semaste
43287505Sdimvoid PrintError(const char *Loc, const Twine &Msg) {
44285101Semaste  SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Error, Msg);
45285101Semaste}
46285101Semaste
47285101Semastevoid PrintError(const Twine &Msg) {
48285101Semaste  errs() << "error:" << Msg << "\n";
49285101Semaste}
50285101Semaste
51285101Semastevoid PrintError(const TGError &Error) {
52285101Semaste  PrintError(Error.getLoc(), Error.getMessage());
53285101Semaste}
54285101Semaste
55285101Semaste} // end namespace llvm
56285101Semaste