Change else if => if after return, after r203265
[oota-llvm.git] / lib / TableGen / Error.cpp
index ec84a72454f65a90a23e74ceea79b920c76d87f6..928b1203cd8f108ca0b4b180f56bf1f2fdebc7b9 100644 (file)
 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;