File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -265,8 +265,16 @@ const ClangTidyOptions &ClangTidyContext::getOptions() const {
265265ClangTidyOptions ClangTidyContext::getOptionsForFile (StringRef File) const {
266266 // Merge options on top of getDefaults() as a safeguard against options with
267267 // unset values.
268- return ClangTidyOptions::getDefaults ().merge (
269- *OptionsProvider->getOptions (File), 0 );
268+ ClangTidyOptions defaultOptions = ClangTidyOptions::getDefaults ();
269+ llvm::ErrorOr<ClangTidyOptions> fileOptions =
270+ OptionsProvider->getOptions (File);
271+
272+ // If there was an error parsing the options, just use the default options.
273+ // Ideally, the options for each file should be validated before this point.
274+ if (!fileOptions)
275+ return defaultOptions;
276+
277+ return defaultOptions.merge (*fileOptions, 0 );
270278}
271279
272280void ClangTidyContext::setEnableProfiling (bool P) { Profile = P; }
Original file line number Diff line number Diff line change @@ -630,6 +630,17 @@ int clangTidyMain(int argc, const char **argv) {
630630 if (!EffectiveOptions)
631631 return 1 ;
632632
633+ // Validate the configuration files associated with all input files so we can
634+ // return an error up front.
635+ if (PathList.size () > 1 ) {
636+ for (auto iter = PathList.begin () + 1 ; iter != PathList.end (); ++iter) {
637+ llvm::ErrorOr<ClangTidyOptions> Options =
638+ OptionsProvider->getOptions (*iter);
639+ if (!Options)
640+ return 1 ;
641+ }
642+ }
643+
633644 std::vector<std::string> EnabledChecks =
634645 getCheckNames (*EffectiveOptions, AllowEnablingAnalyzerAlphaCheckers);
635646
You can’t perform that action at this time.
0 commit comments