]>
git.proxmox.com Git - rustc.git/blob - src/llvm/lib/TableGen/Error.cpp
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"
23 unsigned ErrorsPrinted
= 0;
25 static void PrintMessage(ArrayRef
<SMLoc
> Loc
, SourceMgr::DiagKind Kind
,
27 // Count the total number of errors printed.
28 // This is used to exit with an error code if there were any errors.
29 if (Kind
== SourceMgr::DK_Error
)
35 SrcMgr
.PrintMessage(Loc
.front(), Kind
, Msg
);
36 for (unsigned i
= 1; i
< Loc
.size(); ++i
)
37 SrcMgr
.PrintMessage(Loc
[i
], SourceMgr::DK_Note
,
38 "instantiated from multiclass");
41 void PrintWarning(ArrayRef
<SMLoc
> WarningLoc
, const Twine
&Msg
) {
42 PrintMessage(WarningLoc
, SourceMgr::DK_Warning
, Msg
);
45 void PrintWarning(const char *Loc
, const Twine
&Msg
) {
46 SrcMgr
.PrintMessage(SMLoc::getFromPointer(Loc
), SourceMgr::DK_Warning
, Msg
);
49 void PrintWarning(const Twine
&Msg
) {
50 errs() << "warning:" << Msg
<< "\n";
53 void PrintError(ArrayRef
<SMLoc
> ErrorLoc
, const Twine
&Msg
) {
54 PrintMessage(ErrorLoc
, SourceMgr::DK_Error
, Msg
);
57 void PrintError(const char *Loc
, const Twine
&Msg
) {
58 SrcMgr
.PrintMessage(SMLoc::getFromPointer(Loc
), SourceMgr::DK_Error
, Msg
);
61 void PrintError(const Twine
&Msg
) {
62 errs() << "error:" << Msg
<< "\n";
65 void PrintFatalError(const Twine
&Msg
) {
70 void PrintFatalError(ArrayRef
<SMLoc
> ErrorLoc
, const Twine
&Msg
) {
71 PrintError(ErrorLoc
, Msg
);
75 } // end namespace llvm