X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTableGen%2FError.cpp;h=8d9ae20dd52eda1a6dc0b0c24a1f0b870553f0b5;hb=fd0a8133e56e6c48d04e395290da69c3926a48d1;hp=0bb86b0686a0cd25265beb494930bac0126edbf2;hpb=61131ab15fd593a2e295d79fe2714e7bc21f2ec8;p=oota-llvm.git diff --git a/lib/TableGen/Error.cpp b/lib/TableGen/Error.cpp index 0bb86b0686a..8d9ae20dd52 100644 --- a/lib/TableGen/Error.cpp +++ b/lib/TableGen/Error.cpp @@ -15,15 +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; @@ -57,12 +62,12 @@ void PrintError(const Twine &Msg) { errs() << "error:" << Msg << "\n"; } -void PrintFatalError(const std::string &Msg) { - PrintError(Twine(Msg)); +void PrintFatalError(const Twine &Msg) { + PrintError(Msg); std::exit(1); } -void PrintFatalError(ArrayRef ErrorLoc, const std::string &Msg) { +void PrintFatalError(ArrayRef ErrorLoc, const Twine &Msg) { PrintError(ErrorLoc, Msg); std::exit(1); }