[PATCH] D139998: [clangd] Remove ReferenceFinder::Reference::Target
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 16 11:44:26 PST 2022
nridge updated this revision to Diff 483623.
nridge added a comment.
address nits
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D139998/new/
https://reviews.llvm.org/D139998
Files:
clang-tools-extra/clangd/XRefs.cpp
Index: clang-tools-extra/clangd/XRefs.cpp
===================================================================
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -857,7 +857,6 @@
struct Reference {
syntax::Token SpelledTok;
index::SymbolRoleSet Role;
- SymbolID Target;
Range range(const SourceManager &SM) const {
return halfOpenToRange(SM, SpelledTok.range(SM).toCharRange(SM));
@@ -868,10 +867,8 @@
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() && {
@@ -897,8 +894,7 @@
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))
@@ -926,7 +922,7 @@
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;
}
@@ -935,7 +931,7 @@
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>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139998.483623.patch
Type: text/x-patch
Size: 1967 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221216/c1b9972c/attachment-0001.bin>
More information about the cfe-commits
mailing list