This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Wait for first preamble before code completion
ClosedPublic

Authored by ilya-biryukov on Jul 4 2018, 6:57 AM.

Event Timeline

ilya-biryukov created this revision.Jul 4 2018, 6:57 AM
sammccall accepted this revision.Jul 5 2018, 12:58 AM

Nice fix!
Possible test: add a file with complicated preamble (billion laughs?) and immediately schedule 5 preamble actions. They should all get a non-null preamble and the pointers should all be the same.

clangd/TUScheduler.cpp
408

inline? should fit on one line...

clangd/TUScheduler.h
104

Not sure what "however" is contrasting with.

Could be just: "If there's no preamble yet (because the file was just opened), we'll wait for it to build. The preamble may still be null if it fails to build or is empty."

This revision is now accepted and ready to land.Jul 5 2018, 12:58 AM
ilya-biryukov marked an inline comment as done.
  • Add a test

Possible test: add a file with complicated preamble (billion laughs?) and immediately schedule 5 preamble actions. They should all get a non-null preamble and the pointers should all be the same.

The most trivial test that updates a file and immediately schedules a few preamble actions failed without this change for me. I have added it to the patch.

clangd/TUScheduler.cpp
408

This is used in TUScheduler, where we don't have access to the fields of ASTWorker.

This revision was automatically updated to reflect the committed changes.
This revision was automatically updated to reflect the committed changes.