Skip to content

Commit

Permalink
[clangd] Remove ReferenceFinder::Reference::Target
Browse files Browse the repository at this point in the history
No one was using it

Differential Revision: https://reviews.llvm.org/D139998
  • Loading branch information
HighCommander4 committed Dec 16, 2022
1 parent cf63261 commit 40d29c0
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions clang-tools-extra/clangd/XRefs.cpp
Expand Up @@ -857,7 +857,6 @@ class ReferenceFinder : public index::IndexDataConsumer {
struct Reference {
syntax::Token SpelledTok;
index::SymbolRoleSet Role;
SymbolID Target;

Range range(const SourceManager &SM) const {
return halfOpenToRange(SM, SpelledTok.range(SM).toCharRange(SM));
Expand All @@ -868,10 +867,8 @@ class ReferenceFinder : public index::IndexDataConsumer {
const llvm::ArrayRef<const NamedDecl *> Targets,
bool PerToken)
: PerToken(PerToken), AST(AST) {
for (const NamedDecl *ND : Targets) {
const Decl *CD = ND->getCanonicalDecl();
TargetDeclToID[CD] = getSymbolID(CD);
}
for (const NamedDecl *ND : Targets)
TargetDecls.insert(ND->getCanonicalDecl());
}

std::vector<Reference> take() && {
Expand All @@ -897,8 +894,7 @@ class ReferenceFinder : public index::IndexDataConsumer {
llvm::ArrayRef<index::SymbolRelation> Relations,
SourceLocation Loc,
index::IndexDataConsumer::ASTNodeInfo ASTNode) override {
auto DeclID = TargetDeclToID.find(D->getCanonicalDecl());
if (DeclID == TargetDeclToID.end())
if (!TargetDecls.contains(D->getCanonicalDecl()))
return true;
const SourceManager &SM = AST.getSourceManager();
if (!isInsideMainFile(Loc, SM))
Expand Down Expand Up @@ -926,7 +922,7 @@ class ReferenceFinder : public index::IndexDataConsumer {
for (SourceLocation L : Locs) {
L = SM.getFileLoc(L);
if (const auto *Tok = TB.spelledTokenAt(L))
References.push_back({*Tok, Roles, DeclID->getSecond()});
References.push_back({*Tok, Roles});
}
return true;
}
Expand All @@ -935,7 +931,7 @@ class ReferenceFinder : public index::IndexDataConsumer {
bool PerToken; // If true, report 3 references for split ObjC selector names.
std::vector<Reference> References;
const ParsedAST &AST;
llvm::DenseMap<const Decl *, SymbolID> TargetDeclToID;
llvm::DenseSet<const Decl *> TargetDecls;
};

std::vector<ReferenceFinder::Reference>
Expand Down

0 comments on commit 40d29c0

Please sign in to comment.