From 301faac18be3855f2b742accc5e1b0f71ea8e3c7 Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Thu, 22 Mar 2018 14:18:20 +0000 Subject: [PATCH] clang-tidy, modularize: return non-zero exit code on errors When no inputs given, the tools should not only produce the help message, but also return a non-zero exit code. Fixed tests accordingly. llvm-svn: 328199 --- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp | 4 ++-- clang-tools-extra/modularize/Modularize.cpp | 2 +- clang-tools-extra/test/clang-tidy/select-checks.cpp | 2 +- clang-tools-extra/test/modularize/NoProblemsNamespace.modularize | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp index eece876..8f0c420 100644 --- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp +++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp @@ -424,13 +424,13 @@ static int clangTidyMain(int argc, const char **argv) { if (EnabledChecks.empty()) { llvm::errs() << "Error: no checks enabled.\n"; llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true); - return 0; + return 1; } if (PathList.empty()) { llvm::errs() << "Error: no input files specified.\n"; llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true); - return 0; + return 1; } llvm::IntrusiveRefCntPtr BaseFS( VfsOverlay.empty() ? vfs::getRealFileSystem() diff --git a/clang-tools-extra/modularize/Modularize.cpp b/clang-tools-extra/modularize/Modularize.cpp index e5f19de..83f2340 100644 --- a/clang-tools-extra/modularize/Modularize.cpp +++ b/clang-tools-extra/modularize/Modularize.cpp @@ -825,7 +825,7 @@ int main(int Argc, const char **Argv) { // No go if we have no header list file. if (ListFileNames.size() == 0) { cl::PrintHelpMessage(); - return 0; + return 1; } std::unique_ptr ModUtil; diff --git a/clang-tools-extra/test/clang-tidy/select-checks.cpp b/clang-tools-extra/test/clang-tidy/select-checks.cpp index 12d05b4..791def7 100644 --- a/clang-tools-extra/test/clang-tidy/select-checks.cpp +++ b/clang-tools-extra/test/clang-tidy/select-checks.cpp @@ -1,5 +1,5 @@ // RUN: clang-tidy %s -checks='-*,llvm-namespace-*' -- 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' %s -// RUN: clang-tidy %s -checks='-*,an-unknown-check' -- 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK2 %s +// RUN: not clang-tidy %s -checks='-*,an-unknown-check' -- 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK2 %s // CHECK2: Error: no checks enabled. diff --git a/clang-tools-extra/test/modularize/NoProblemsNamespace.modularize b/clang-tools-extra/test/modularize/NoProblemsNamespace.modularize index 1c3f78d..93a4fea 100644 --- a/clang-tools-extra/test/modularize/NoProblemsNamespace.modularize +++ b/clang-tools-extra/test/modularize/NoProblemsNamespace.modularize @@ -1,3 +1,3 @@ -# RUN: modularize -block-check-header-list-only +# RUN: modularize -block-check-header-list-only %s Inputs/IncludeInNamespace.h -- 2.7.4