This revision was automatically updated to reflect the committed changes.
Closed by commit rG66ace4dc0275: [clang-tidy] Fix a nullptr-access crash in 
unused-raii-check. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91614/new/

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

Reply via email to