[PATCH] D47331: [clangd] Remove accessors for top-level decls from preamble

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 25 00:41:07 PDT 2018

sammccall added a comment.

Wow, nice!
Just unsure about the test helper. (We can rewrite it in another way if needed)

Comment at: clangd/ClangdUnit.h:88
-  /// This function returns all top-level decls, including those that come
-  /// from Preamble. Decls, coming from Preamble, have to be deserialized, so
-  /// this call might be expensive.
-  ArrayRef<const Decl *> getTopLevelDecls();
+  /// This function returns top-level decls, present in the main file of the
+  /// AST. The result does not include the decls that come from the preamble.
nit: remove comma

Comment at: unittests/clangd/TestTU.cpp:77
   const NamedDecl *Result = nullptr;
-  for (const Decl *D : AST.getTopLevelDecls()) {
+  for (const Decl *D : AST.getLocalTopLevelDecls()) {
     auto *ND = dyn_cast<NamedDecl>(D);
isn't this incorrect? Or should be "findDeclInMainFile" or similar?

I'd think this would conflict with your other patch, which uses this to test the boost of things that come from the header.

  rCTE Clang Tools Extra


More information about the cfe-commits mailing list