Skip to content

Commit

Permalink
Fix the buildbot failure.
Browse files Browse the repository at this point in the history
Looks like we hit a bug in iterator of DeclContextLookupResult, workaround
by a forloop.

http://45.33.8.238/win/27605/step_4.txt
  • Loading branch information
hokein committed Nov 10, 2020
1 parent 47fcf23 commit a97d7b9
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions clang-tools-extra/clangd/refactor/Rename.cpp
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit a97d7b9

Please sign in to comment.