diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2013-03-20 20:43:11 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2013-03-20 20:43:11 +0000 |
commit | f8ea5a5a27222f3b0f6daaddc47f79fb969c7448 (patch) | |
tree | 2c7591084215204aebae95211fad2641000c08fb | |
parent | 6115ed0e4347f17504f72e4d37545b4230b2cb50 (diff) | |
download | llvm-f8ea5a5a27222f3b0f6daaddc47f79fb969c7448.tar.gz llvm-f8ea5a5a27222f3b0f6daaddc47f79fb969c7448.tar.bz2 llvm-f8ea5a5a27222f3b0f6daaddc47f79fb969c7448.tar.xz |
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
-rw-r--r-- | include/llvm/TableGen/Error.h | 1 | ||||
-rw-r--r-- | lib/TableGen/Error.cpp | 6 | ||||
-rw-r--r-- | lib/TableGen/Main.cpp | 7 |
3 files changed, 12 insertions, 2 deletions
diff --git a/include/llvm/TableGen/Error.h b/include/llvm/TableGen/Error.h index 2f6b7e625c..2d0a2b45a9 100644 --- a/include/llvm/TableGen/Error.h +++ b/include/llvm/TableGen/Error.h @@ -32,6 +32,7 @@ LLVM_ATTRIBUTE_NORETURN void PrintFatalError(ArrayRef<SMLoc> ErrorLoc, const std::string &Msg); extern SourceMgr SrcMgr; +extern unsigned ErrorsPrinted; } // end namespace "llvm" 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; } } |