This is needed to implement call hierarchy.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
350 ms | windows > LLVM.CodeGen/AMDGPU::ds_read2.ll |
Event Timeline
clang-tools-extra/clangd/index/SymbolCollector.cpp | ||
---|---|---|
349 | 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 NamedDecls 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, |
clang-tools-extra/clangd/index/SymbolCollector.cpp | ||
---|---|---|
349 | I wrote a test with various cases I could think of, and the choice of decl coming from ASTNode.Parent seems reasonable to me. |
clang-tools-extra/clangd/index/Ref.h | ||
---|---|---|
91 | i am afraid we are going to have an indeterminate value here if for whatever reason Container detection fails. (e.g. for macros, or if ASTNode.Parent set to nullptr by libindex). Sent out https://reviews.llvm.org/D90397 to address the issue. | |
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp | ||
779 | can we also have an assertion checking containers for top level symbols are the same ? and extend the test to have multiple declarations inside:
and ensure the container is same for those (and different than top-level symbols themselves). It is okay for those symbols. Note that it is OK for namespaces to be not in the index, i just want to make sure the containers for the top-level symbols inside a namespace are the same. |
Address review comments
clang-tools-extra/clangd/index/Ref.h | ||
---|---|---|
91 | Good catch, and thank you for addressing this! |
thanks, LGTM!
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp | ||
---|---|---|
782 | can you also assert containers here are non-null (and below) | |
803 | nit: i would suggest writing these in the form of: auto Container = [](StringRef RangeName){ auto Ref = findRefWithRange(RangeName; ASSERT_TRUE(Ref); ASSERT_FALSE(Ref->Container.isNull()); return Ref->Container; }; EXPECT_EQ(Container("sym1"), Container("sym2")); EXPECT_NE(Container("sym1"), Container("sym2")); then you could update the ones above as: EXPECT_EQ(Container("rangename"), findSymbol(Symbols, "symname")); |
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp | ||
---|---|---|
782 | It looks like the container is null for toplevel decls. Is that a problem? |
(I will wait for a response about the containers for top-level decls before committing.)
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp | ||
---|---|---|
803 | Revised as suggested, except for allowing a null container for top-level decls. |
clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp | ||
---|---|---|
770 | nit: instead of making this part of the lambda and complicating the signature I would just check this holds for classscope1 and namespacescope1 explicitly. it should be true for other cases anyways, as we are checking equality with non-null smybolids. | |
782 | I think that's OK for now, might be worth leaving a comment tho. (at Ref::Container) |
i am afraid we are going to have an indeterminate value here if for whatever reason Container detection fails. (e.g. for macros, or if ASTNode.Parent set to nullptr by libindex).
Sent out https://reviews.llvm.org/D90397 to address the issue.