1 //===- Error.cpp - tblgen error handling helper routines --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains error handling helper routines to pretty-print diagnostic
11 // messages from tblgen.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/TableGen/Error.h"
16 #include "llvm/ADT/Twine.h"
17 #include "llvm/Support/raw_ostream.h"
24 static void PrintMessage(ArrayRef<SMLoc> Loc, SourceMgr::DiagKind Kind,
29 SrcMgr.PrintMessage(Loc.front(), Kind, Msg);
30 for (unsigned i = 1; i < Loc.size(); ++i)
31 SrcMgr.PrintMessage(Loc[i], SourceMgr::DK_Note,
32 "instantiated from multiclass");
35 void PrintWarning(ArrayRef<SMLoc> WarningLoc, const Twine &Msg) {
36 PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg);
39 void PrintWarning(const char *Loc, const Twine &Msg) {
40 SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Warning, Msg);
43 void PrintWarning(const Twine &Msg) {
44 errs() << "warning:" << Msg << "\n";
47 void PrintError(ArrayRef<SMLoc> ErrorLoc, const Twine &Msg) {
48 PrintMessage(ErrorLoc, SourceMgr::DK_Error, Msg);
51 void PrintError(const char *Loc, const Twine &Msg) {
52 SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Error, Msg);
55 void PrintError(const Twine &Msg) {
56 errs() << "error:" << Msg << "\n";
59 void PrintFatalError(const std::string &Msg) {
60 PrintError(Twine(Msg));
64 void PrintFatalError(ArrayRef<SMLoc> ErrorLoc, const std::string &Msg) {
65 PrintError(ErrorLoc, Msg);
69 } // end namespace llvm