| 1 | //===- llvm/TableGen/Error.h - tblgen error handling helpers ----*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file contains error handling helper routines to pretty-print diagnostic |
| 10 | // messages from tblgen. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_TABLEGEN_ERROR_H |
| 15 | #define LLVM_TABLEGEN_ERROR_H |
| 16 | |
| 17 | #include "llvm/ADT/STLFunctionalExtras.h" |
| 18 | #include "llvm/Support/SourceMgr.h" |
| 19 | |
| 20 | namespace llvm { |
| 21 | class Record; |
| 22 | class RecordVal; |
| 23 | class Init; |
| 24 | |
| 25 | LLVM_ABI void PrintNote(const Twine &Msg); |
| 26 | LLVM_ABI void PrintNote(function_ref<void(raw_ostream &OS)> PrintMsg); |
| 27 | LLVM_ABI void PrintNote(ArrayRef<SMLoc> NoteLoc, const Twine &Msg); |
| 28 | |
| 29 | [[noreturn]] LLVM_ABI void PrintFatalNote(const Twine &Msg); |
| 30 | [[noreturn]] LLVM_ABI void PrintFatalNote(ArrayRef<SMLoc> ErrorLoc, |
| 31 | const Twine &Msg); |
| 32 | [[noreturn]] LLVM_ABI void PrintFatalNote(const Record *Rec, const Twine &Msg); |
| 33 | [[noreturn]] LLVM_ABI void PrintFatalNote(const RecordVal *RecVal, |
| 34 | const Twine &Msg); |
| 35 | |
| 36 | LLVM_ABI void PrintWarning(const Twine &Msg); |
| 37 | LLVM_ABI void PrintWarning(ArrayRef<SMLoc> WarningLoc, const Twine &Msg); |
| 38 | LLVM_ABI void PrintWarning(const char *Loc, const Twine &Msg); |
| 39 | |
| 40 | LLVM_ABI void PrintError(const Twine &Msg); |
| 41 | LLVM_ABI void PrintError(function_ref<void(raw_ostream &OS)> PrintMsg); |
| 42 | LLVM_ABI void PrintError(ArrayRef<SMLoc> ErrorLoc, const Twine &Msg); |
| 43 | LLVM_ABI void PrintError(const char *Loc, const Twine &Msg); |
| 44 | LLVM_ABI void PrintError(const Record *Rec, const Twine &Msg); |
| 45 | LLVM_ABI void PrintError(const RecordVal *RecVal, const Twine &Msg); |
| 46 | |
| 47 | [[noreturn]] LLVM_ABI void PrintFatalError(const Twine &Msg); |
| 48 | [[noreturn]] LLVM_ABI void PrintFatalError(ArrayRef<SMLoc> ErrorLoc, |
| 49 | const Twine &Msg); |
| 50 | [[noreturn]] LLVM_ABI void PrintFatalError(const Record *Rec, const Twine &Msg); |
| 51 | [[noreturn]] LLVM_ABI void PrintFatalError(const RecordVal *RecVal, |
| 52 | const Twine &Msg); |
| 53 | [[noreturn]] LLVM_ABI void |
| 54 | PrintFatalError(function_ref<void(raw_ostream &OS)> PrintMsg); |
| 55 | |
| 56 | // Returns true if the assert failed. |
| 57 | LLVM_ABI bool CheckAssert(SMLoc Loc, const Init *Condition, |
| 58 | const Init *Message); |
| 59 | LLVM_ABI void dumpMessage(SMLoc Loc, const Init *Message); |
| 60 | |
| 61 | extern LLVM_ABI SourceMgr SrcMgr; |
| 62 | extern LLVM_ABI unsigned ErrorsPrinted; |
| 63 | |
| 64 | } // end namespace llvm |
| 65 | |
| 66 | #endif |
| 67 | |