hokein created this revision. hokein added a reviewer: gribozavr2. Herald added a subscriber: xazax.hun. Herald added a project: clang. hokein requested review of this revision.
I saw this crash in our internal production, but unfortunately didn't get reproduced testcase, we likely hit this crash when the AST is ill-formed (e.g. broken code). Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D91614 Files: clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp Index: clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp +++ 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<TypeLoc>("t", Matches); - assert(TL); - D << FixItHint::CreateInsertion( - Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager, - getLangOpts()), - Replacement); + if (const auto *TL = selectFirst<TypeLoc>("t", Matches)) + D << FixItHint::CreateInsertion( + Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager, + getLangOpts()), + Replacement); } } // namespace bugprone
Index: clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp +++ 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<TypeLoc>("t", Matches); - assert(TL); - D << FixItHint::CreateInsertion( - Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager, - getLangOpts()), - Replacement); + if (const auto *TL = selectFirst<TypeLoc>("t", Matches)) + D << FixItHint::CreateInsertion( + Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager, + getLangOpts()), + Replacement); } } // namespace bugprone
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits