This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Remove accessors for top-level decls from preamble
ClosedPublic

Authored by ilya-biryukov on May 24 2018, 9:06 AM.

Details

Summary

They cause lots of deserialization and are not actually used.
The ParsedAST accessor that previously returned those was renamed from
getTopLevelDecls to getLocalTopLevelDecls in order to avoid
confusion.

This change should considerably improve the speed of findDefinition
and other features that try to find AST nodes, corresponding to the
locations in the source code.

Diff Detail

Event Timeline

ilya-biryukov created this revision.May 24 2018, 9:06 AM

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

clangd/ClangdUnit.h
91–93

nit: remove comma

unittests/clangd/TestTU.cpp
74–75

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.

Nice! This looks good to me. Just some nits. I'll let Sam stamp.

clangd/ClangdUnit.h
84

IIUC, ASTContext in a ParsedAST may not contain information from preambles and thus may give an incomplete AST. If so, I think we should make this more explicit in the class level to make sure this is not misused (e.g. in case the incomplete context is used to build dynamic index).

121–124

nit: also rename this and add comment?

ilya-biryukov marked 3 inline comments as done.
  • Rename the field in addition to the getter
  • Address review comments
ilya-biryukov added inline comments.May 25 2018, 7:05 AM
clangd/ClangdUnit.h
84

Added a small doc comment about it. Let me know if you feel we need to elaborate more on this.
I don't think anything changed wrt to this behavior in this patch, apart from the fact that we used to deserialize more stuff most of the time before so this wan't as visible.

unittests/clangd/TestTU.cpp
74–75

Thanks for spotting that, I would also expect this to fail in the new patch.
I'll look into rewriting this helper.

  • Rewrote findDecl, it will deserialize decls if needed now
sammccall accepted this revision.May 25 2018, 9:20 AM
This revision is now accepted and ready to land.May 25 2018, 9:20 AM
ilya-biryukov marked 2 inline comments as done.May 25 2018, 9:43 AM
This revision was automatically updated to reflect the committed changes.