diff options
author | Sam McCall <sam.mccall@gmail.com> | 2018-11-26 09:51:50 +0000 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2018-11-26 09:51:50 +0000 |
commit | 6e2d2a33b6be376e52688705db22534b336f5529 (patch) | |
tree | 1e7ed4997044b9a0784a97d8da0d945a05574616 /clang-tools-extra/unittests/clangd/GlobalCompilationDatabaseTests.cpp | |
parent | dbfa9c3e0a34807489d31fca7dac3de5c1e0446d (diff) | |
download | bcm5719-llvm-6e2d2a33b6be376e52688705db22534b336f5529.tar.gz bcm5719-llvm-6e2d2a33b6be376e52688705db22534b336f5529.zip |
[clangd] Auto-index watches global CDB for changes.
Summary:
Instead of receiving compilation commands, auto-index is triggered by just
filenames to reindex, and gets commands from the global comp DB internally.
This has advantages:
- more of the work can be done asynchronously (fetching compilation commands
upfront can be slow for large CDBs)
- we get access to the CDB which can be used to retrieve interpolated commands
for headers (useful in some cases where the original TU goes away)
- fits nicely with the filename-only change observation from r347297
The interface to GlobalCompilationDatabase gets extended: when retrieving a
compile command, the GCDB can optionally report the project the file belongs to.
This naturally fits together with getCompileCommand: it's hard to implement one
without the other. But because most callers don't care, I've ended up with an
awkward optional-out-param-in-virtual method pattern - maybe there's a better
one.
This is the main missing integration point between ClangdServer and
BackgroundIndex, after this we should be able to add an auto-index flag.
Reviewers: ioeric, kadircet
Subscribers: MaskRay, jkorous, arphaman, cfe-commits, ilya-biryukov
Differential Revision: https://reviews.llvm.org/D54865
llvm-svn: 347538
Diffstat (limited to 'clang-tools-extra/unittests/clangd/GlobalCompilationDatabaseTests.cpp')
-rw-r--r-- | clang-tools-extra/unittests/clangd/GlobalCompilationDatabaseTests.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clang-tools-extra/unittests/clangd/GlobalCompilationDatabaseTests.cpp b/clang-tools-extra/unittests/clangd/GlobalCompilationDatabaseTests.cpp index f502f79b71f..f3916108c63 100644 --- a/clang-tools-extra/unittests/clangd/GlobalCompilationDatabaseTests.cpp +++ b/clang-tools-extra/unittests/clangd/GlobalCompilationDatabaseTests.cpp @@ -41,9 +41,12 @@ class OverlayCDBTest : public ::testing::Test { class BaseCDB : public GlobalCompilationDatabase { public: Optional<tooling::CompileCommand> - getCompileCommand(StringRef File) const override { - if (File == testPath("foo.cc")) + getCompileCommand(StringRef File, ProjectInfo *Project) const override { + if (File == testPath("foo.cc")) { + if (Project) + Project->SourceRoot = testRoot(); return cmd(File, "-DA=1"); + } return None; } |