[clang-tools-extra] 40d29c0 - [clangd] Remove ReferenceFinder::Reference::Target

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 16 11:44:56 PST 2022


Author: Nathan Ridge
Date: 2022-12-16T14:44:44-05:00
New Revision: 40d29c0a714d7a19110f6f43d0af4c3df249c458

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

LOG: [clangd] Remove ReferenceFinder::Reference::Target

No one was using it

Differential Revision: https://reviews.llvm.org/D139998

Added: 
    

Modified: 
    clang-tools-extra/clangd/XRefs.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clangd/XRefs.cpp b/clang-tools-extra/clangd/XRefs.cpp
index df82d8d9fa738..d86b91c430156 100644
--- a/clang-tools-extra/clangd/XRefs.cpp
+++ b/clang-tools-extra/clangd/XRefs.cpp
@@ -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));
@@ -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() && {
@@ -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))
@@ -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;
   }
@@ -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>


        


More information about the cfe-commits mailing list