Skip to content

Commit 26d1aa7

Browse files
committed
Revert "[clang-tidy] Fix bugprone-unchecked-optional-access in ClangTidyDiagnosticConsumer"
This reverts commit 7f6239f.
1 parent a9d0e38 commit 26d1aa7

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,13 @@ static bool parseFileExtensions(llvm::ArrayRef<std::string> AllFileExtensions,
239239
void ClangTidyContext::setCurrentFile(StringRef File) {
240240
CurrentFile = std::string(File);
241241
CurrentOptions = getOptionsForFile(CurrentFile);
242-
CheckFilter =
243-
std::make_unique<CachedGlobList>(getOptions().Checks.value_or(""));
244-
WarningAsErrorFilter = std::make_unique<CachedGlobList>(
245-
getOptions().WarningsAsErrors.value_or(""));
246-
if (!parseFileExtensions(getOptions().HeaderFileExtensions.value_or(
247-
std::vector<std::string>()),
242+
CheckFilter = std::make_unique<CachedGlobList>(*getOptions().Checks);
243+
WarningAsErrorFilter =
244+
std::make_unique<CachedGlobList>(*getOptions().WarningsAsErrors);
245+
if (!parseFileExtensions(*getOptions().HeaderFileExtensions,
248246
HeaderFileExtensions))
249247
this->configurationDiag("Invalid header file extensions");
250-
if (!parseFileExtensions(getOptions().ImplementationFileExtensions.value_or(
251-
std::vector<std::string>()),
248+
if (!parseFileExtensions(*getOptions().ImplementationFileExtensions,
252249
ImplementationFileExtensions))
253250
this->configurationDiag("Invalid implementation file extensions");
254251
}
@@ -572,7 +569,7 @@ void ClangTidyDiagnosticConsumer::checkFilters(SourceLocation Location,
572569
return;
573570
}
574571

575-
if (!Context.getOptions().SystemHeaders.value_or(false) &&
572+
if (!*Context.getOptions().SystemHeaders &&
576573
(Sources.isInSystemHeader(Location) || Sources.isInSystemMacro(Location)))
577574
return;
578575

@@ -603,15 +600,15 @@ void ClangTidyDiagnosticConsumer::checkFilters(SourceLocation Location,
603600

604601
llvm::Regex *ClangTidyDiagnosticConsumer::getHeaderFilter() {
605602
if (!HeaderFilter)
606-
HeaderFilter = std::make_unique<llvm::Regex>(
607-
Context.getOptions().HeaderFilterRegex.value_or(""));
603+
HeaderFilter =
604+
std::make_unique<llvm::Regex>(*Context.getOptions().HeaderFilterRegex);
608605
return HeaderFilter.get();
609606
}
610607

611608
llvm::Regex *ClangTidyDiagnosticConsumer::getExcludeHeaderFilter() {
612609
if (!ExcludeHeaderFilter)
613610
ExcludeHeaderFilter = std::make_unique<llvm::Regex>(
614-
Context.getOptions().ExcludeHeaderFilterRegex.value_or(""));
611+
*Context.getOptions().ExcludeHeaderFilterRegex);
615612
return ExcludeHeaderFilter.get();
616613
}
617614

0 commit comments

Comments
 (0)