This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Enable include insertion for dynamic index
ClosedPublic

Authored by kadircet on Jan 31 2019, 4:50 AM.

Event Timeline

kadircet created this revision.Jan 31 2019, 4:50 AM
kadircet retitled this revision from [clangd] Enable include insertion for static index to [clangd] Enable include insertion for dynamic index.Jan 31 2019, 4:53 AM
ioeric added inline comments.Feb 4 2019, 3:13 AM
clangd/ClangdUnit.cpp
100

Does this have to own the IWYUHandler? Could we create one when getCommentHandler is called?

124

This looks like a memory leak? release()?

340

I think so? A header file (with IWYU pragma) can also be the main file.

unittests/clangd/CodeCompleteTests.cpp
2317

nit: maybe put this close to test cases that involve preamble. e.g. IndexSuppressesPreambleCompletions

2331

nit: just use std::string for readability.

unittests/clangd/FileIndexTests.cpp
207

Are we sure the comment will be included in the preamble if there is no #include block?

Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2019, 3:13 AM
kadircet updated this revision to Diff 185030.Feb 4 2019, 5:26 AM
kadircet marked 6 inline comments as done.
  • Address comments.
  • Call addSystemHeaderMappings when we are building ast without preamble.
clangd/ClangdUnit.cpp
100

The class needs to own it, since preprocessor doesn't take the ownership. But we can move the creation to getcommenthandler.

124

Preprocessor doesn't take the ownership, so this seems to be correct ?

340

Also call addSystemHeadersMapping in case there is no preamble.

ioeric accepted this revision.Feb 4 2019, 7:01 AM

lgtm.

Note that this will enable include insertions for everyone (even without index switched on). Not sure if we should provide options.

clangd/ClangdServer.cpp
16

nit: is this used?

This revision is now accepted and ready to land.Feb 4 2019, 7:01 AM
kadircet marked an inline comment as done.Feb 4 2019, 7:49 AM

I don't think so, since the only reason this already wasn't enabled was because there was a fixme ? Also we want people to use -background-index by default in future so I think it should be OK

kadircet updated this revision to Diff 185052.Feb 4 2019, 7:49 AM
  • Delete unnecessary include
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2019, 8:19 AM