[PATCH] D89670: [clangd] Store the containing symbol for refs

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 24 18:49:28 PDT 2020


nridge marked an inline comment as done.
nridge added inline comments.


================
Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:349
+        SymbolRef{SM.getFileLoc(Loc), Roles,
+                  dyn_cast_or_null<NamedDecl>(ASTNode.Parent)});
   // Don't continue indexing if this is a mere reference.
----------------
kadircet wrote:
> What does `ASTNode.Parent` correspond to in here? I couldn't find any clarifications on libIndex side, are we sure that's always what we want? It would be nice to have some tests demonstrating what this corresponds to in a variety of cases.
> 
> Also why do we only store `NamedDecl`s as containers? It makes sense from CallHierarchy perspective as we are only interested in function-like containers, and they are nameddecls (?). But these might as well be `TranslationUnitDecl` (?) for top level declarations,
I wrote a test with various cases I could think of, and the choice of decl coming from `ASTNode.Parent` seems reasonable to me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D89670/new/

https://reviews.llvm.org/D89670



More information about the cfe-commits mailing list