[PATCH] D84839: Add document outline symbols from unnamed contexts, e.g. extern "C".

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 31 09:02:51 PDT 2020


kadircet added a comment.

In D84839#2187222 <https://reviews.llvm.org/D84839#2187222>, @ilya-golovenko wrote:

> @kadircet I decided to add `OnlyChildren` to `enum VisitKind` instead of making a `VisitKindSet` - this helped to minimize the changes in `shouldVisit()`.  What do you think?

SGTM.



================
Comment at: clang-tools-extra/clangd/FindSymbols.cpp:203
       return;
-    llvm::Optional<DocumentSymbol> Sym = declToSym(AST.getASTContext(), *ND);
-    if (!Sym)
-      return;
-    if (Visit == VisitKind::DeclAndChildren)
-      traverseChildren(D, Sym->children);
-    Results.push_back(std::move(*Sym));
+    if (Visit == VisitKind::OnlyChildren) {
+      traverseChildren(D, Results);
----------------
ah this is complicated now, but at least for the sake of nestedness:
```
if (Visit == OnlyChildren)
  return traverseChildren;

// We must have the Decl in the result set.
auto *ND = llvm::cast<NamedDecl>(D);
auto Sym = declToSym(AST.getASTContext(), *ND);
if (!Sym) return;
Results.push_back(std::move(*Sym));

if(Visit == OnlyDecl) return;

assert(Visit == DeclAndChildren && "Unexpected VisitKind");
traverseChildren(Result.back()->children);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84839



More information about the cfe-commits mailing list