Error.cpp revision 234982
1//===- 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
15#include "llvm/TableGen/Error.h"
16#include "llvm/ADT/Twine.h"
17#include "llvm/Support/raw_ostream.h"
18
19namespace llvm {
20
21SourceMgr SrcMgr;
22
23void PrintWarning(SMLoc WarningLoc, const Twine &Msg) {
24  SrcMgr.PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg);
25}
26
27void PrintWarning(const char *Loc, const Twine &Msg) {
28  SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Warning, Msg);
29}
30
31void PrintWarning(const Twine &Msg) {
32  errs() << "warning:" << Msg << "\n";
33}
34
35void PrintWarning(const TGError &Warning) {
36  PrintWarning(Warning.getLoc(), Warning.getMessage());
37}
38
39void PrintError(SMLoc ErrorLoc, const Twine &Msg) {
40  SrcMgr.PrintMessage(ErrorLoc, SourceMgr::DK_Error, Msg);
41}
42
43void PrintError(const char *Loc, const Twine &Msg) {
44  SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Error, Msg);
45}
46
47void PrintError(const Twine &Msg) {
48  errs() << "error:" << Msg << "\n";
49}
50
51void PrintError(const TGError &Error) {
52  PrintError(Error.getLoc(), Error.getMessage());
53}
54
55} // end namespace llvm
56