File tree 2 files changed +21
-2
lines changed
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 {
265
265
ClangTidyOptions ClangTidyContext::getOptionsForFile (StringRef File) const {
266
266
// Merge options on top of getDefaults() as a safeguard against options with
267
267
// 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 );
270
278
}
271
279
272
280
void 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) {
630
630
if (!EffectiveOptions)
631
631
return 1 ;
632
632
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
+
633
644
std::vector<std::string> EnabledChecks =
634
645
getCheckNames (*EffectiveOptions, AllowEnablingAnalyzerAlphaCheckers);
635
646
You can’t perform that action at this time.
0 commit comments