[PATCH] D47272: [clangd] Build index on preamble changes instead of the AST changes

Eric Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 24 07:24:52 PDT 2018

ioeric added inline comments.

Comment at: clangd/index/FileIndex.cpp:37
+  std::vector<Decl *> TopLevelDecls(
+      AST.getTranslationUnitDecl()->decls().begin(),
+      AST.getTranslationUnitDecl()->decls().end());
ilya-biryukov wrote:
> ioeric wrote:
> > Would this give us decls in namespaces? It seems that `AST.getTranslationUnitDecl()->decls()` are only decls that are immediately inside the TU context. 
> I'll double check and add a test for that, but I think the indexer visits the namespaces that we provide, I'm not sure if we have tests though.
Oh, right! In that case, it seems that a single TU decl which contains all interesting decls would be sufficient? Is it possible that preamble doesn't have all available top level decls in TU decl? This seems to be possible for ParsedAST, which is why we used `getTopLevelDecls`, I think?

  rCTE Clang Tools Extra


More information about the cfe-commits mailing list