X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTableGen%2FError.cpp;h=8d9ae20dd52eda1a6dc0b0c24a1f0b870553f0b5;hb=12af22e8cc217827cf4f118b0f5e4ebbda9925ae;hp=5dd688cb6750b51914390b46b829e15f734de061;hpb=376a8a773e38fdcd9102a40e08ab1e0661d645d9;p=oota-llvm.git diff --git a/lib/TableGen/Error.cpp b/lib/TableGen/Error.cpp index 5dd688cb675..8d9ae20dd52 100644 --- a/lib/TableGen/Error.cpp +++ b/lib/TableGen/Error.cpp @@ -15,13 +15,20 @@ #include "llvm/TableGen/Error.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/raw_ostream.h" +#include namespace llvm { SourceMgr SrcMgr; +unsigned ErrorsPrinted = 0; static void PrintMessage(ArrayRef Loc, SourceMgr::DiagKind Kind, const Twine &Msg) { + // Count the total number of errors printed. + // This is used to exit with an error code if there were any errors. + if (Kind == SourceMgr::DK_Error) + ++ErrorsPrinted; + SMLoc NullLoc; if (Loc.empty()) Loc = NullLoc; @@ -43,10 +50,6 @@ void PrintWarning(const Twine &Msg) { errs() << "warning:" << Msg << "\n"; } -void PrintWarning(const TGError &Warning) { - PrintWarning(Warning.getLoc(), Warning.getMessage()); -} - void PrintError(ArrayRef ErrorLoc, const Twine &Msg) { PrintMessage(ErrorLoc, SourceMgr::DK_Error, Msg); } @@ -59,8 +62,14 @@ void PrintError(const Twine &Msg) { errs() << "error:" << Msg << "\n"; } -void PrintError(const TGError &Error) { - PrintError(Error.getLoc(), Error.getMessage()); +void PrintFatalError(const Twine &Msg) { + PrintError(Msg); + std::exit(1); +} + +void PrintFatalError(ArrayRef ErrorLoc, const Twine &Msg) { + PrintError(ErrorLoc, Msg); + std::exit(1); } } // end namespace llvm