@@ -41,8 +41,8 @@ SuspiciousIncludeCheck::SuspiciousIncludeCheck(StringRef Name,
4141 : ClangTidyCheck(Name, Context),
4242 HeaderFileExtensions (Context->getHeaderFileExtensions ()),
4343 ImplementationFileExtensions(Context->getImplementationFileExtensions ()),
44- IgnoredRegexString(Options.get(" IgnoredRegex" )),
45- IgnoredRegex(IgnoredRegexString.value_or(StringRef{}) ) {}
44+ IgnoredRegexString(Options.get(" IgnoredRegex" ).value_or(StringRef{}) ),
45+ IgnoredRegex(IgnoredRegexString) {}
4646
4747void SuspiciousIncludeCheck::registerPPCallbacks (
4848 const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) {
@@ -51,8 +51,8 @@ void SuspiciousIncludeCheck::registerPPCallbacks(
5151}
5252
5353void SuspiciousIncludeCheck::storeOptions (ClangTidyOptions::OptionMap &Opts) {
54- if (IgnoredRegexString.has_value ())
55- Options.store (Opts, " IgnoredRegex" , IgnoredRegexString. value () );
54+ if (! IgnoredRegexString.empty ())
55+ Options.store (Opts, " IgnoredRegex" , IgnoredRegexString);
5656}
5757
5858void SuspiciousIncludePPCallbacks::InclusionDirective (
@@ -63,10 +63,8 @@ void SuspiciousIncludePPCallbacks::InclusionDirective(
6363 if (IncludeTok.getIdentifierInfo ()->getPPKeywordID () == tok::pp_import)
6464 return ;
6565
66- if (Check.IgnoredRegexString .has_value () &&
67- Check.IgnoredRegex .match (FileName)) {
66+ if (!Check.IgnoredRegexString .empty () && Check.IgnoredRegex .match (FileName))
6867 return ;
69- }
7068
7169 SourceLocation DiagLoc = FilenameRange.getBegin ().getLocWithOffset (1 );
7270
0 commit comments