[PATCH] D91614: [clang-tidy] Fix a nullptr-access crash in unused-raii-check.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 23 00:44:46 PST 2020


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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91614.306972.patch
Type: text/x-patch
Size: 929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201123/e593b3cf/attachment.bin>


More information about the cfe-commits mailing list