diff options
author | Alexander Kornienko <alexfh@google.com> | 2014-06-02 20:32:06 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2014-06-02 20:32:06 +0000 |
commit | 26e40fecdbd65d3254f5702f2fb09dac1a43e7a9 (patch) | |
tree | cde6353c61613be143726b5d934480b0c0fe57c0 /clang-tidy/tool/ClangTidyMain.cpp | |
parent | 7c2c4080a49ee8ec1e55b1258a9d220c49ca17c4 (diff) |
Exit with error when no checks enabled.
Summary:
This seems like a more appropriate reaction to the user specifying a
single check with a wrong name, for example.
Reviewers: klimek
Reviewed By: klimek
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D3981
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@210043 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/tool/ClangTidyMain.cpp')
-rw-r--r-- | clang-tidy/tool/ClangTidyMain.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/clang-tidy/tool/ClangTidyMain.cpp b/clang-tidy/tool/ClangTidyMain.cpp index 41b66d66..f338805f 100644 --- a/clang-tidy/tool/ClangTidyMain.cpp +++ b/clang-tidy/tool/ClangTidyMain.cpp @@ -119,15 +119,23 @@ int main(int argc, const char **argv) { return 1; } + std::vector<std::string> EnabledChecks = clang::tidy::getCheckNames(Options); + // FIXME: Allow using --list-checks without positional arguments. if (ListChecks) { llvm::outs() << "Enabled checks:"; - for (auto CheckName : clang::tidy::getCheckNames(Options)) + for (auto CheckName : EnabledChecks) llvm::outs() << "\n " << CheckName; llvm::outs() << "\n\n"; return 0; } + if (EnabledChecks.empty()) { + llvm::errs() << "Error: no checks enabled.\n"; + llvm::cl::PrintHelpMessage(/*Hidden=*/false, /*Categorized=*/true); + return 1; + } + std::vector<clang::tidy::ClangTidyError> Errors; clang::tidy::ClangTidyStats Stats = clang::tidy::runClangTidy(Options, OptionsParser.getCompilations(), |