[clang-tools-extra] [clang-tidy] Return error code on config parse error (PR #136167)
Carlos Galvez via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 29 12:17:36 PDT 2025
================
@@ -624,21 +623,29 @@ int clangTidyMain(int argc, const char **argv) {
}
SmallString<256> FilePath = makeAbsolute(FileName);
- ClangTidyOptions EffectiveOptions = OptionsProvider->getOptions(FilePath);
+ llvm::ErrorOr<ClangTidyOptions> EffectiveOptions =
+ OptionsProvider->getOptions(FilePath);
+
+ if (!EffectiveOptions)
+ return 1;
std::vector<std::string> EnabledChecks =
- getCheckNames(EffectiveOptions, AllowEnablingAnalyzerAlphaCheckers);
+ getCheckNames(*EffectiveOptions, AllowEnablingAnalyzerAlphaCheckers);
if (ExplainConfig) {
// FIXME: Show other ClangTidyOptions' fields, like ExtraArg.
- std::vector<clang::tidy::ClangTidyOptionsProvider::OptionsSource>
+ llvm::ErrorOr<
+ std::vector<clang::tidy::ClangTidyOptionsProvider::OptionsSource>>
RawOptions = OptionsProvider->getRawOptions(FilePath);
- for (const std::string &Check : EnabledChecks) {
- 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;
+
+ if (RawOptions) {
----------------
carlosgalvezp wrote:
if (!RawOptions) return 1?
https://github.com/llvm/llvm-project/pull/136167
More information about the cfe-commits
mailing list