[clang-tidy] Fix unused-variable warning after r361647.

Summary:
A range-for was added in r361647 where the range variable was only used in an
assertion.  As a result, it warned for Release builds. This revision
restructures the assertion to avoid the problem.

Patch by Yitzhak Mandelbaum.

Reviewers: ilya-biryukov

Reviewed By: ilya-biryukov

Subscribers: xazax.hun, cfe-commits

Tags: #clang-tools-extra, #clang

Differential Revision: https://reviews.llvm.org/D62412

llvm-svn: 361749
This commit is contained in:
Haojian Wu 2019-05-27 08:09:02 +00:00
parent 1d28030f99
commit c11de5eada
1 changed files with 7 additions and 6 deletions

View File

@ -7,21 +7,22 @@
//===----------------------------------------------------------------------===//
#include "TransformerClangTidyCheck.h"
#include "llvm/ADT/STLExtras.h"
namespace clang {
namespace tidy {
namespace utils {
using tooling::RewriteRule;
TransformerClangTidyCheck::TransformerClangTidyCheck(tooling::RewriteRule R,
TransformerClangTidyCheck::TransformerClangTidyCheck(RewriteRule R,
StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context), Rule(std::move(R)) {
for (const auto &Case : Rule.Cases) {
assert(Case.Explanation != nullptr &&
"clang-tidy checks must have an explanation by default;"
" explicitly provide an empty explanation if none is desired");
}
assert(llvm::all_of(Rule.Cases, [](const RewriteRule::Case &C) {
return C.Explanation != nullptr;
}) &&
"clang-tidy checks must have an explanation by default;"
" explicitly provide an empty explanation if none is desired");
}
void TransformerClangTidyCheck::registerMatchers(