Skip to content

Commit f08fcd5

Browse files
kazutakahirataziqingluo-90
authored andcommitted
[clang-tidy] Use structured bindings (NFC)
(cherry picked from commit a5f368a)
1 parent 69846df commit f08fcd5

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,9 @@ int clangTidyMain(int argc, const char **argv) {
519519
std::vector<clang::tidy::ClangTidyOptionsProvider::OptionsSource>
520520
RawOptions = OptionsProvider->getRawOptions(FilePath);
521521
for (const std::string &Check : EnabledChecks) {
522-
for (auto It = RawOptions.rbegin(); It != RawOptions.rend(); ++It) {
523-
if (It->first.Checks && GlobList(*It->first.Checks).contains(Check)) {
524-
llvm::outs() << "'" << Check << "' is enabled in the " << It->second
522+
for (const auto &[Opts, Source] : llvm::reverse(RawOptions)) {
523+
if (Opts.Checks && GlobList(*Opts.Checks).contains(Check)) {
524+
llvm::outs() << "'" << Check << "' is enabled in the " << Source
525525
<< ".\n";
526526
break;
527527
}
@@ -557,20 +557,16 @@ int clangTidyMain(int argc, const char **argv) {
557557
NamesAndOptions Valid =
558558
getAllChecksAndOptions(AllowEnablingAnalyzerAlphaCheckers);
559559
bool AnyInvalid = false;
560-
for (const std::pair<ClangTidyOptions, std::string> &OptionWithSource :
561-
RawOptions) {
562-
const ClangTidyOptions &Opts = OptionWithSource.first;
560+
for (const auto &[Opts, Source] : RawOptions) {
563561
if (Opts.Checks)
564-
AnyInvalid |=
565-
verifyChecks(Valid.Names, *Opts.Checks, OptionWithSource.second);
562+
AnyInvalid |= verifyChecks(Valid.Names, *Opts.Checks, Source);
566563

567564
for (auto Key : Opts.CheckOptions.keys()) {
568565
if (Valid.Options.contains(Key))
569566
continue;
570567
AnyInvalid = true;
571-
auto &Output =
572-
llvm::WithColor::warning(llvm::errs(), OptionWithSource.second)
573-
<< "unknown check option '" << Key << '\'';
568+
auto &Output = llvm::WithColor::warning(llvm::errs(), Source)
569+
<< "unknown check option '" << Key << '\'';
574570
llvm::StringRef Closest = closest(Key, Valid.Options);
575571
if (!Closest.empty())
576572
Output << "; did you mean '" << Closest << '\'';

0 commit comments

Comments
 (0)