summaryrefslogtreecommitdiff
path: root/lib/TableGen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/TableGen')
-rw-r--r--lib/TableGen/Error.cpp6
-rw-r--r--lib/TableGen/Main.cpp7
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/TableGen/Error.cpp b/lib/TableGen/Error.cpp
index ec84a72454..928b1203cd 100644
--- a/lib/TableGen/Error.cpp
+++ b/lib/TableGen/Error.cpp
@@ -20,9 +20,15 @@
namespace llvm {
SourceMgr SrcMgr;
+unsigned ErrorsPrinted = 0;
static void PrintMessage(ArrayRef<SMLoc> 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;
diff --git a/lib/TableGen/Main.cpp b/lib/TableGen/Main.cpp
index e1cd623783..dc4167b305 100644
--- a/lib/TableGen/Main.cpp
+++ b/lib/TableGen/Main.cpp
@@ -117,11 +117,14 @@ int TableGenMain(char *argv0, TableGenMainFn *MainFn) {
if (MainFn(Out.os(), Records))
return 1;
+ if (ErrorsPrinted > 0) {
+ errs() << argv0 << ": " << ErrorsPrinted << " errors.\n";
+ return 1;
+ }
+
// Declare success.
Out.keep();
return 0;
-
- return 1;
}
}