This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Parse all comments in Sema and completion.
ClosedPublic

Authored by ilya-biryukov on Apr 24 2018, 4:53 AM.

Details

Summary

And add tests for the comment extraction code.

clangd will now show non-doxygen comments in completion for results
coming from Sema and Dynamic index.
Static index does not include the comments yet, I will enable it in
a separate commit after investigating which implications it has for
the size of the index.

Diff Detail

Event Timeline

ilya-biryukov created this revision.Apr 24 2018, 4:53 AM

Code looks good/simple, just a couple of design questions

clangd/ClangdUnit.cpp
320

Any idea about whether this will affect performance significantly?
Less for this patch, and more for whether this should be an option in the future that we might e.g. only do during indexing.

clangd/CodeComplete.cpp
652

Are we sure we want to do this in code complete? I would have thought the more natural approach would be to implement resolve in terms of lookup in the index, and only provide it there.
The lack of good support for resolve in YCM LSP shouldn't be a problem as YCM doesn't actually use doc comments (I think?).

ilya-biryukov added inline comments.Apr 25 2018, 3:22 AM
clangd/ClangdUnit.cpp
320

Hopefully, there should be no significant difference, but I'll do some benchmarks with both real code and artificial comment-heave code to make sure that's the case.
It would certainly eat a bit more memory, but it shouldn't be significant as we only store an extra list of sourceranges for comments.
Even for this patch, maybe we would want to only enable it in the AST but not in the preamble. I'll get some numbers and come back to this.

clangd/CodeComplete.cpp
652

It seems to give a better user-experience:

  • Some items come only from Sema, so getting documentation for local variables and class members is currently only possible through Sema. We could probably omit the docs for the local vars and put class members into the index, though.
  • If the comment for the completion is in the current file, we should prefer the latest version, not one from the index that might be stale.

However, it does mean sending docs along with the results, I don't think LSP will allow us to properly handle the lifetime of docs from the completion AST, so we won't be able to delay their result until resolve time.

sammccall accepted this revision.Apr 27 2018, 5:01 AM

LG (once the dependencies are done!)

clangd/ClangdUnit.cpp
320

No need to block on the numbers from my point of view, though I would be interested.

maybe we would want to only enable it in the AST but not in the preamble

You're talking about gathering the information, right?
How would this work? Given that e.g. class members come from the preamble and we need the comments from there.

clangd/CodeComplete.cpp
652

Yeah, Sema-only results. I wasn't thinking.

We can send eager docs from sema results and still fill ind index docs at resolve time. This all sounds good.

This revision is now accepted and ready to land.Apr 27 2018, 5:01 AM
  • Moved tests to clang
  • Added tests that all comments are being parsed.
This revision was automatically updated to reflect the committed changes.