From a97d7b9159a0178b774c20358047035f0091efb3 Mon Sep 17 00:00:00 2001 From: Haojian Wu Date: Tue, 10 Nov 2020 13:05:45 +0100 Subject: [PATCH] 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 --- clang-tools-extra/clangd/refactor/Rename.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/clang-tools-extra/clangd/refactor/Rename.cpp b/clang-tools-extra/clangd/refactor/Rename.cpp index 0e2209123eaab..5adcf6d0e86ee 100644 --- a/clang-tools-extra/clangd/refactor/Rename.cpp +++ b/clang-tools-extra/clangd/refactor/Rename.cpp @@ -256,9 +256,9 @@ std::vector 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; }