[clang-tools-extra] a5f368a - [clang-tidy] Use structured bindings (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 6 20:49:02 PST 2022
Author: Kazu Hirata
Date: 2022-11-06T20:48:55-08:00
New Revision: a5f368af6d9e469ad2a7f83ce5957776746fa0ca
URL: https://github.com/llvm/llvm-project/commit/a5f368af6d9e469ad2a7f83ce5957776746fa0ca
DIFF: https://github.com/llvm/llvm-project/commit/a5f368af6d9e469ad2a7f83ce5957776746fa0ca.diff
LOG: [clang-tidy] Use structured bindings (NFC)
Added:
Modified:
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index 67d8ccbd6cad4..f089abf69dce6 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -519,9 +519,9 @@ int clangTidyMain(int argc, const char **argv) {
std::vector<clang::tidy::ClangTidyOptionsProvider::OptionsSource>
RawOptions = OptionsProvider->getRawOptions(FilePath);
for (const std::string &Check : EnabledChecks) {
- for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
- if (It->first.Checks && GlobList(*It->first.Checks).contains(Check)) {
- llvm::outs() << "'" << Check << "' is enabled in the " << It->second
+ for (const auto &[Opts, Source] : llvm::reverse(RawOptions)) {
+ if (Opts.Checks && GlobList(*Opts.Checks).contains(Check)) {
+ llvm::outs() << "'" << Check << "' is enabled in the " << Source
<< ".\n";
break;
}
@@ -557,20 +557,16 @@ int clangTidyMain(int argc, const char **argv) {
NamesAndOptions Valid =
getAllChecksAndOptions(AllowEnablingAnalyzerAlphaCheckers);
bool AnyInvalid = false;
- for (const std::pair<ClangTidyOptions, std::string> &OptionWithSource :
- RawOptions) {
- const ClangTidyOptions &Opts = OptionWithSource.first;
+ for (const auto &[Opts, Source] : RawOptions) {
if (Opts.Checks)
- AnyInvalid |=
- verifyChecks(Valid.Names, *Opts.Checks, OptionWithSource.second);
+ AnyInvalid |= verifyChecks(Valid.Names, *Opts.Checks, Source);
for (auto Key : Opts.CheckOptions.keys()) {
if (Valid.Options.contains(Key))
continue;
AnyInvalid = true;
- auto &Output =
- llvm::WithColor::warning(llvm::errs(), OptionWithSource.second)
- << "unknown check option '" << Key << '\'';
+ auto &Output = llvm::WithColor::warning(llvm::errs(), Source)
+ << "unknown check option '" << Key << '\'';
llvm::StringRef Closest = closest(Key, Valid.Options);
if (!Closest.empty())
Output << "; did you mean '" << Closest << '\'';
More information about the cfe-commits
mailing list