[PATCH] D91122: [clangd] Call hierarchy (XRefs layer, incoming calls)
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 15 18:18:27 PST 2020
nridge added inline comments.
================
Comment at: clang-tools-extra/clangd/XRefs.cpp:1317
-static Optional<TypeHierarchyItem>
-symbolToTypeHierarchyItem(const Symbol &S, const SymbolIndex *Index,
- PathRef TUPath) {
----------------
kadircet wrote:
> that's a great change to have, but maybe leave it out of this patch?
Since we are unifying the function with `symbolToCallHierarchyItem`, and that didn't have an `Index` parameter, it made more sense to keep the removal.
================
Comment at: clang-tools-extra/clangd/XRefs.h:109
+/// Get call hierarchy information at \p Pos.
+llvm::Optional<std::vector<CallHierarchyItem>>
+prepareCallHierarchy(ParsedAST &AST, Position Pos, const SymbolIndex *Index,
----------------
kadircet wrote:
> what's the distinction between empty and none return values ? (same for others)
Generally speaking, a `None` result means "the input was not recognized in some way", while an empty vector result means "there are no results for this input".
For `prepareCallHierarchy`, the inputs encode a source location, and the operation asks "give me `CallHierarchyItem`s for suitable declarations (i.e. functions) at this location. So, `None` means "the source location could not be recognized" (`sourceLocationInMainFile` failed), while an empty result means "there are no declarations of functions at this location".
For `incomingCalls` and `outgoingCalls`, the inputs encode a declaration of a function, and the operation asks "give me its callers / callees". So, a `None` means "could not locate the function (i.e. symbol)", while an empty result means "this function has no callers / callees".
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91122/new/
https://reviews.llvm.org/D91122
More information about the cfe-commits
mailing list