diff --git a/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp --- a/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp @@ -79,12 +79,11 @@ // written type. auto Matches = match(expr(hasDescendant(typeLoc().bind("t"))), *E, *Result.Context); - const auto *TL = selectFirst("t", Matches); - assert(TL); - D << FixItHint::CreateInsertion( - Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager, - getLangOpts()), - Replacement); + if (const auto *TL = selectFirst("t", Matches)) + D << FixItHint::CreateInsertion( + Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager, + getLangOpts()), + Replacement); } } // namespace bugprone