[PATCH] D97889: [clang-tidy] Fix assert in modernize-loop-convert

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 3 14:39:38 PST 2021


njames93 created this revision.
njames93 added a reviewer: aaron.ballman.
Herald added subscribers: usaxena95, kadircet, xazax.hun.
njames93 requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang.

I'm unable to figure out a reproduction of this bug as it emerged when using clangd(On a ReleaseWithAssertions build) making it very hard to figure out the exact code that caught it.
However this is a pretty obvious check to include.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97889

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp


Index: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -313,6 +313,8 @@
   const auto *Member = dyn_cast<MemberExpr>(TheCall->getCallee());
   if (!Member)
     return nullptr;
+  if (!Member->getMemberDecl()->getDeclName().isIdentifier())
+    return nullptr;
   StringRef Name = Member->getMemberDecl()->getName();
   if (!Name.consume_back(IsBegin ? "begin" : "end"))
     return nullptr;
@@ -544,6 +546,7 @@
   std::vector<FixItHint> FixIts;
   if (VarNameFromAlias) {
     const auto *AliasVar = cast<VarDecl>(AliasDecl->getSingleDecl());
+    assert(AliasVar->getDeclName().isIdentifier());
     VarName = AliasVar->getName().str();
 
     // Use the type of the alias if it's not the same


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97889.327928.patch
Type: text/x-patch
Size: 907 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210303/a1bfefb9/attachment.bin>


More information about the cfe-commits mailing list