@@ -526,6 +526,24 @@ static bool verifyFileExtensions(
526526 return AnyInvalid;
527527}
528528
529+ static bool verifyOptions (const llvm::StringSet<> &ValidOptions,
530+ const ClangTidyOptions::OptionMap &OptionMap,
531+ StringRef Source) {
532+ bool AnyInvalid = false ;
533+ for (auto Key : OptionMap.keys ()) {
534+ if (ValidOptions.contains (Key))
535+ continue ;
536+ AnyInvalid = true ;
537+ auto &Output = llvm::WithColor::warning (llvm::errs (), Source)
538+ << " unknown check option '" << Key << ' \' ' ;
539+ llvm::StringRef Closest = closest (Key, ValidOptions);
540+ if (!Closest.empty ())
541+ Output << " ; did you mean '" << Closest << ' \' ' ;
542+ Output << VerifyConfigWarningEnd;
543+ }
544+ return AnyInvalid;
545+ }
546+
529547static SmallString<256 > makeAbsolute (llvm::StringRef Input) {
530548 if (Input.empty ())
531549 return {};
@@ -629,29 +647,17 @@ int clangTidyMain(int argc, const char **argv) {
629647 if (VerifyConfig) {
630648 std::vector<ClangTidyOptionsProvider::OptionsSource> RawOptions =
631649 OptionsProvider->getRawOptions (FileName);
632- NamesAndOptions Valid =
650+ ChecksAndOptions Valid =
633651 getAllChecksAndOptions (AllowEnablingAnalyzerAlphaCheckers);
634652 bool AnyInvalid = false ;
635653 for (const auto &[Opts, Source] : RawOptions) {
636654 if (Opts.Checks )
637- AnyInvalid |= verifyChecks (Valid.Names , *Opts.Checks , Source);
638-
655+ AnyInvalid |= verifyChecks (Valid.Checks , *Opts.Checks , Source);
639656 if (Opts.HeaderFileExtensions && Opts.ImplementationFileExtensions )
640657 AnyInvalid |=
641658 verifyFileExtensions (*Opts.HeaderFileExtensions ,
642659 *Opts.ImplementationFileExtensions , Source);
643-
644- for (auto Key : Opts.CheckOptions .keys ()) {
645- if (Valid.Options .contains (Key))
646- continue ;
647- AnyInvalid = true ;
648- auto &Output = llvm::WithColor::warning (llvm::errs (), Source)
649- << " unknown check option '" << Key << ' \' ' ;
650- llvm::StringRef Closest = closest (Key, Valid.Options );
651- if (!Closest.empty ())
652- Output << " ; did you mean '" << Closest << ' \' ' ;
653- Output << VerifyConfigWarningEnd;
654- }
660+ AnyInvalid |= verifyOptions (Valid.Options , Opts.CheckOptions , Source);
655661 }
656662 if (AnyInvalid)
657663 return 1 ;
0 commit comments