This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Always use the latest preamble
ClosedPublic

Authored by hokein on Aug 14 2018, 2:34 AM.

Details

Summary

Fix an inconsistent behavior of using LastBuiltPreamble/NewPreamble
in TUScheduler (see the test for details), AST should always use
NewPreamble. This patch makes LastBuiltPreamble always point to
NewPreamble.

Preamble rarely fails to build, even there are errors in headers, so we
assume it would not cause performace issue for code completion.

Diff Detail

Event Timeline

hokein created this revision.Aug 14 2018, 2:34 AM

Thanks, we were previously getting inconsistent ASTs (i.e. using different preambles), depending on whether they were built in TUScheduler::update or in TUScheduler::runWithAST handlers.
Just a few NITs.

clangd/TUScheduler.cpp
373

Maybe remove the comment? It does not seem to add any additional information on top of the code.

unittests/clangd/XRefsTests.cpp
1058

Maybe use runFindDefinitions instead of the two Server.findDefinitions() + Server.blockUntilIdleForTest() calls?

1061

NIT: just use cantFail(std::move(Loc)) to get the underlying vector and remove ASSERT_TRUE.
This gives equivalent results (crashes tests with assert failure internally in LLVM) with a simpler syntax.

1073

Same here: maybe use runFindDefinitions?

hokein updated this revision to Diff 160983.Aug 16 2018, 2:29 AM
hokein marked 4 inline comments as done.

Address review comments.

This revision is now accepted and ready to land.Aug 16 2018, 9:08 AM
This revision was automatically updated to reflect the committed changes.