Skip to content

Commit 4fd9989

Browse files
committed
[clang-tidy] Fix bugprone-unchecked-optional-access in FormatStringConverter
1 parent eabda17 commit 4fd9989

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,11 @@ void FormatStringConverter::applyFixes(DiagnosticBuilder &Diag,
800800
}
801801

802802
for (const auto &[ArgIndex, Replacement] : ArgFixes) {
803-
const SourceLocation AfterOtherSide =
804-
Lexer::findNextToken(Args[ArgIndex]->getEndLoc(), SM, LangOpts)
805-
->getLocation();
803+
const auto NextToken =
804+
Lexer::findNextToken(Args[ArgIndex]->getEndLoc(), SM, LangOpts);
805+
if (!NextToken)
806+
continue;
807+
const SourceLocation AfterOtherSide = NextToken->getLocation();
806808

807809
Diag << FixItHint::CreateInsertion(Args[ArgIndex]->getBeginLoc(),
808810
Replacement, true)

0 commit comments

Comments
 (0)