diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2021-06-13 19:31:46 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2021-06-13 19:37:19 +0000 |
commit | e8d8bef961a50d4dc22501cde4fb9fb0be1b2532 (patch) | |
tree | 94f04805f47bb7c59ae29690d8952b6074fff602 /contrib/llvm-project/llvm/lib/TableGen/Error.cpp | |
parent | bb130ff39747b94592cb26d71b7cb097b9a4ea6b (diff) | |
parent | b60736ec1405bb0a8dd40989f67ef4c93da068ab (diff) |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/TableGen/Error.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/TableGen/Error.cpp | 85 |
1 files changed, 80 insertions, 5 deletions
diff --git a/contrib/llvm-project/llvm/lib/TableGen/Error.cpp b/contrib/llvm-project/llvm/lib/TableGen/Error.cpp index 54b063cb4f8d..eed4de67942a 100644 --- a/contrib/llvm-project/llvm/lib/TableGen/Error.cpp +++ b/contrib/llvm-project/llvm/lib/TableGen/Error.cpp @@ -11,11 +11,12 @@ // //===----------------------------------------------------------------------===// -#include "llvm/TableGen/Error.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Support/Signals.h" #include "llvm/Support/WithColor.h" -#include "llvm/Support/raw_ostream.h" +#include "llvm/TableGen/Error.h" +#include "llvm/TableGen/Record.h" #include <cstdlib> namespace llvm { @@ -39,12 +40,54 @@ static void PrintMessage(ArrayRef<SMLoc> Loc, SourceMgr::DiagKind Kind, "instantiated from multiclass"); } -void PrintNote(const Twine &Msg) { WithColor::note() << Msg << "\n"; } +// Functions to print notes. + +void PrintNote(const Twine &Msg) { + WithColor::note() << Msg << "\n"; +} void PrintNote(ArrayRef<SMLoc> NoteLoc, const Twine &Msg) { PrintMessage(NoteLoc, SourceMgr::DK_Note, Msg); } +// Functions to print fatal notes. + +void PrintFatalNote(const Twine &Msg) { + PrintNote(Msg); + // The following call runs the file cleanup handlers. + sys::RunInterruptHandlers(); + std::exit(1); +} + +void PrintFatalNote(ArrayRef<SMLoc> NoteLoc, const Twine &Msg) { + PrintNote(NoteLoc, Msg); + // The following call runs the file cleanup handlers. + sys::RunInterruptHandlers(); + std::exit(1); +} + +// This method takes a Record and uses the source location +// stored in it. +void PrintFatalNote(const Record *Rec, const Twine &Msg) { + PrintNote(Rec->getLoc(), Msg); + // The following call runs the file cleanup handlers. + sys::RunInterruptHandlers(); + std::exit(1); +} + +// This method takes a RecordVal and uses the source location +// stored in it. +void PrintFatalNote(const RecordVal *RecVal, const Twine &Msg) { + PrintNote(RecVal->getLoc(), Msg); + // The following call runs the file cleanup handlers. + sys::RunInterruptHandlers(); + std::exit(1); +} + +// Functions to print warnings. + +void PrintWarning(const Twine &Msg) { WithColor::warning() << Msg << "\n"; } + void PrintWarning(ArrayRef<SMLoc> WarningLoc, const Twine &Msg) { PrintMessage(WarningLoc, SourceMgr::DK_Warning, Msg); } @@ -53,7 +96,9 @@ void PrintWarning(const char *Loc, const Twine &Msg) { SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Warning, Msg); } -void PrintWarning(const Twine &Msg) { WithColor::warning() << Msg << "\n"; } +// Functions to print errors. + +void PrintError(const Twine &Msg) { WithColor::error() << Msg << "\n"; } void PrintError(ArrayRef<SMLoc> ErrorLoc, const Twine &Msg) { PrintMessage(ErrorLoc, SourceMgr::DK_Error, Msg); @@ -63,7 +108,19 @@ void PrintError(const char *Loc, const Twine &Msg) { SrcMgr.PrintMessage(SMLoc::getFromPointer(Loc), SourceMgr::DK_Error, Msg); } -void PrintError(const Twine &Msg) { WithColor::error() << Msg << "\n"; } +// This method takes a Record and uses the source location +// stored in it. +void PrintError(const Record *Rec, const Twine &Msg) { + PrintMessage(Rec->getLoc(), SourceMgr::DK_Error, Msg); +} + +// This method takes a RecordVal and uses the source location +// stored in it. +void PrintError(const RecordVal *RecVal, const Twine &Msg) { + PrintMessage(RecVal->getLoc(), SourceMgr::DK_Error, Msg); +} + +// Functions to print fatal errors. void PrintFatalError(const Twine &Msg) { PrintError(Msg); @@ -79,4 +136,22 @@ void PrintFatalError(ArrayRef<SMLoc> ErrorLoc, const Twine &Msg) { std::exit(1); } +// This method takes a Record and uses the source location +// stored in it. +void PrintFatalError(const Record *Rec, const Twine &Msg) { + PrintError(Rec->getLoc(), Msg); + // The following call runs the file cleanup handlers. + sys::RunInterruptHandlers(); + std::exit(1); +} + +// This method takes a RecordVal and uses the source location +// stored in it. +void PrintFatalError(const RecordVal *RecVal, const Twine &Msg) { + PrintError(RecVal->getLoc(), Msg); + // The following call runs the file cleanup handlers. + sys::RunInterruptHandlers(); + std::exit(1); +} + } // end namespace llvm |