| 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 | void PrintNote(const Twine &Msg); |
| 26 | void PrintNote(function_ref<void(raw_ostream &OS)> PrintMsg); |
| 27 | void PrintNote(ArrayRef<SMLoc> NoteLoc, const Twine &Msg); |
| 28 | |
| 29 | [[noreturn]] void PrintFatalNote(const Twine &Msg); |
| 30 | [[noreturn]] void PrintFatalNote(ArrayRef<SMLoc> ErrorLoc, const Twine &Msg); |
| 31 | [[noreturn]] void PrintFatalNote(const Record *Rec, const Twine &Msg); |
| 32 | [[noreturn]] void PrintFatalNote(const RecordVal *RecVal, const Twine &Msg); |
| 33 | |
| 34 | void PrintWarning(const Twine &Msg); |
| 35 | void PrintWarning(ArrayRef<SMLoc> WarningLoc, const Twine &Msg); |
| 36 | void PrintWarning(const char *Loc, const Twine &Msg); |
| 37 | |
| 38 | void PrintError(const Twine &Msg); |
| 39 | void PrintError(function_ref<void(raw_ostream &OS)> PrintMsg); |
| 40 | void PrintError(ArrayRef<SMLoc> ErrorLoc, const Twine &Msg); |
| 41 | void PrintError(const char *Loc, const Twine &Msg); |
| 42 | void PrintError(const Record *Rec, const Twine &Msg); |
| 43 | void PrintError(const RecordVal *RecVal, const Twine &Msg); |
| 44 | |
| 45 | [[noreturn]] void PrintFatalError(const Twine &Msg); |
| 46 | [[noreturn]] void PrintFatalError(ArrayRef<SMLoc> ErrorLoc, const Twine &Msg); |
| 47 | [[noreturn]] void PrintFatalError(const Record *Rec, const Twine &Msg); |
| 48 | [[noreturn]] void PrintFatalError(const RecordVal *RecVal, const Twine &Msg); |
| 49 | [[noreturn]] void PrintFatalError(function_ref<void(raw_ostream &OS)> PrintMsg); |
| 50 | |
| 51 | // Returns true if the assert failed. |
| 52 | bool CheckAssert(SMLoc Loc, const Init *Condition, const Init *Message); |
| 53 | void dumpMessage(SMLoc Loc, const Init *Message); |
| 54 | |
| 55 | extern SourceMgr SrcMgr; |
| 56 | extern unsigned ErrorsPrinted; |
| 57 | |
| 58 | } // end namespace llvm |
| 59 | |
| 60 | #endif |
| 61 | |