In preparation for removing exception handling in tablegen, add
[oota-llvm.git] / include / llvm / TableGen / Error.h
1 //===- llvm/TableGen/Error.h - tblgen error handling helpers ----*- 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 #ifndef LLVM_TABLEGEN_ERROR_H
16 #define LLVM_TABLEGEN_ERROR_H
17
18 #include "llvm/Support/SourceMgr.h"
19
20 namespace llvm {
21
22 class TGError {
23   SmallVector<SMLoc, 4> Locs;
24   std::string Message;
25 public:
26   TGError(ArrayRef<SMLoc> locs, const std::string &message)
27     : Locs(locs.begin(), locs.end()), Message(message) {}
28
29   ArrayRef<SMLoc> getLoc() const { return Locs; }
30   const std::string &getMessage() const { return Message; }
31 };
32
33 void PrintWarning(ArrayRef<SMLoc> WarningLoc, const Twine &Msg);
34 void PrintWarning(const char *Loc, const Twine &Msg);
35 void PrintWarning(const Twine &Msg);
36 void PrintWarning(const TGError &Warning);
37
38 void PrintError(ArrayRef<SMLoc> ErrorLoc, const Twine &Msg);
39 void PrintError(const char *Loc, const Twine &Msg);
40 void PrintError(const Twine &Msg);
41 void PrintError(const TGError &Error);
42
43 LLVM_ATTRIBUTE_NORETURN void PrintFatalError(const std::string &Msg);
44 LLVM_ATTRIBUTE_NORETURN void PrintFatalError(ArrayRef<SMLoc> ErrorLoc,
45                                              const std::string &Msg);
46
47 extern SourceMgr SrcMgr;
48
49
50 } // end namespace "llvm"
51
52 #endif