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.

Diff Detail

Repository
rL LLVM

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 ↗(On Diff #184485)

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

125 ↗(On Diff #184485)

This looks like a memory leak? release()?

338 ↗(On Diff #184485)

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

unittests/clangd/CodeCompleteTests.cpp
2287 ↗(On Diff #184485)

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

2301 ↗(On Diff #184485)

nit: just use std::string for readability.

unittests/clangd/FileIndexTests.cpp
207 ↗(On Diff #184485)

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 ↗(On Diff #184485)

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

125 ↗(On Diff #184485)

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

338 ↗(On Diff #184485)

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 ↗(On Diff #185030)

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