llvm.org GIT mirror llvm / f8ea5a5
Make sure TableGen exits with an error code after printing errors. This makes it possible to report multiple errors in one invocation. There are already calls to PrintError in CodeGenDAGPatterns.cpp which previously would not cause TableGen to fail. <rdar://problem/13463339> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@177573 91177308-0d34-0410-b5e6-96231b3b80d8 Jakob Stoklund Olesen 7 years ago
3 changed file(s) with 12 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
3131 const std::string &Msg);
3232
3333 extern SourceMgr SrcMgr;
34 extern unsigned ErrorsPrinted;
3435
3536
3637 } // end namespace "llvm"
1919 namespace llvm {
2020
2121 SourceMgr SrcMgr;
22 unsigned ErrorsPrinted = 0;
2223
2324 static void PrintMessage(ArrayRef Loc, SourceMgr::DiagKind Kind,
2425 const Twine &Msg) {
26 // Count the total number of errors printed.
27 // This is used to exit with an error code if there were any errors.
28 if (Kind == SourceMgr::DK_Error)
29 ++ErrorsPrinted;
30
2531 SMLoc NullLoc;
2632 if (Loc.empty())
2733 Loc = NullLoc;
116116 if (MainFn(Out.os(), Records))
117117 return 1;
118118
119 if (ErrorsPrinted > 0) {
120 errs() << argv0 << ": " << ErrorsPrinted << " errors.\n";
121 return 1;
122 }
123
119124 // Declare success.
120125 Out.keep();
121126 return 0;
122
123 return 1;
124127 }
125128
126129 }