[clang-tools-extra] a97d7b9 - Fix the buildbot failure.

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 10 04:12:18 PST 2020


Author: Haojian Wu
Date: 2020-11-10T13:11:54+01:00
New Revision: a97d7b9159a0178b774c20358047035f0091efb3

URL: https://github.com/llvm/llvm-project/commit/a97d7b9159a0178b774c20358047035f0091efb3
DIFF: https://github.com/llvm/llvm-project/commit/a97d7b9159a0178b774c20358047035f0091efb3.diff

LOG: Fix the buildbot failure.

Looks like we hit a bug in iterator of DeclContextLookupResult, workaround
by a forloop.

http://45.33.8.238/win/27605/step_4.txt

Added: 
    

Modified: 
    clang-tools-extra/clangd/refactor/Rename.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp b/clang-tools-extra/clangd/refactor/Rename.cpp
index 0e2209123eaa..5adcf6d0e86e 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -256,9 +256,9 @@ std::vector<SourceLocation> findOccurrencesWithinFile(ParsedAST &AST,
 
 // Lookup the declarations (if any) with the given Name in the context of
 // RenameDecl.
-NamedDecl *lookupSiblingWithName(const ASTContext &Ctx,
-                                 const NamedDecl &RenamedDecl,
-                                 llvm::StringRef Name) {
+const NamedDecl *lookupSiblingWithName(const ASTContext &Ctx,
+                                       const NamedDecl &RenamedDecl,
+                                       llvm::StringRef Name) {
   const auto &II = Ctx.Idents.get(Name);
   DeclarationName LookupName(&II);
   DeclContextLookupResult LookupResult;
@@ -285,11 +285,9 @@ NamedDecl *lookupSiblingWithName(const ASTContext &Ctx,
     break;
   }
   // Lookup may contain the RenameDecl itself, exclude it.
-  auto It = llvm::find_if(LookupResult, [&RenamedDecl](const NamedDecl *D) {
-    return D->getCanonicalDecl() != RenamedDecl.getCanonicalDecl();
-  });
-  if (It != LookupResult.end())
-    return *It;
+  for (const auto *D : LookupResult)
+    if (D->getCanonicalDecl() != RenamedDecl.getCanonicalDecl())
+      return D;
   return nullptr;
 }
 


        


More information about the cfe-commits mailing list