summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2018-04-09 15:12:10 +0000
committerAlexander Kornienko <alexfh@google.com>2018-04-09 15:12:10 +0000
commitc3ad02e84009a2d32501cde8704b3b1271944184 (patch)
tree848c075312633eff1073ec879043be3187f6aedc /clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
parente9a5a2f10ca1d04fbf06b50dcb052711b8ddb1e7 (diff)
downloadbcm5719-llvm-c3ad02e84009a2d32501cde8704b3b1271944184.tar.gz
bcm5719-llvm-c3ad02e84009a2d32501cde8704b3b1271944184.zip
[clang-tidy] Return non-zero exit code for clang errors.
Summary: Updated tests broken by this change. Fixes https://bugs.llvm.org/show_bug.cgi?id=27628 Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D45258 llvm-svn: 329579
Diffstat (limited to 'clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index 8f0c420b379..273e4b97b73 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -448,10 +448,9 @@ static int clangTidyMain(int argc, const char **argv) {
runClangTidy(Context, OptionsParser.getCompilations(), PathList, BaseFS,
EnableCheckProfile ? &Profile : nullptr);
ArrayRef<ClangTidyError> Errors = Context.getErrors();
- bool FoundErrors =
- std::find_if(Errors.begin(), Errors.end(), [](const ClangTidyError &E) {
- return E.DiagLevel == ClangTidyError::Error;
- }) != Errors.end();
+ bool FoundErrors = llvm::find_if(Errors, [](const ClangTidyError &E) {
+ return E.DiagLevel == ClangTidyError::Error;
+ }) != Errors.end();
const bool DisableFixes = Fix && FoundErrors && !FixErrors;
@@ -491,6 +490,19 @@ static int clangTidyMain(int argc, const char **argv) {
return WErrorCount;
}
+ if (FoundErrors) {
+ // TODO: Figure out when zero exit code should be used with -fix-errors:
+ // a. when a fix has been applied for an error
+ // b. when a fix has been applied for all errors
+ // c. some other condition.
+ // For now always returning zero when -fix-errors is used.
+ if (FixErrors)
+ return 0;
+ if (!Quiet)
+ llvm::errs() << "Found compiler error(s).\n";
+ return 1;
+ }
+
return 0;
}
OpenPOWER on IntegriCloud