summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/clangd/TestFS.cpp
diff options
context:
space:
mode:
authorSam McCall <sam.mccall@gmail.com>2018-11-26 09:51:50 +0000
committerSam McCall <sam.mccall@gmail.com>2018-11-26 09:51:50 +0000
commit6e2d2a33b6be376e52688705db22534b336f5529 (patch)
tree1e7ed4997044b9a0784a97d8da0d945a05574616 /clang-tools-extra/unittests/clangd/TestFS.cpp
parentdbfa9c3e0a34807489d31fca7dac3de5c1e0446d (diff)
downloadbcm5719-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/TestFS.cpp')
-rw-r--r--clang-tools-extra/unittests/clangd/TestFS.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang-tools-extra/unittests/clangd/TestFS.cpp b/clang-tools-extra/unittests/clangd/TestFS.cpp
index 86e10725eaa..b0938a59840 100644
--- a/clang-tools-extra/unittests/clangd/TestFS.cpp
+++ b/clang-tools-extra/unittests/clangd/TestFS.cpp
@@ -39,7 +39,8 @@ MockCompilationDatabase::MockCompilationDatabase(StringRef Directory,
}
Optional<tooling::CompileCommand>
-MockCompilationDatabase::getCompileCommand(PathRef File) const {
+MockCompilationDatabase::getCompileCommand(PathRef File,
+ ProjectInfo *Project) const {
if (ExtraClangFlags.empty())
return None;
@@ -58,6 +59,8 @@ MockCompilationDatabase::getCompileCommand(PathRef File) const {
CommandLine.push_back(RelativeFilePath.str());
}
+ if (Project)
+ Project->SourceRoot = Directory;
return {tooling::CompileCommand(
Directory != StringRef() ? Directory : sys::path::parent_path(File),
FileName, std::move(CommandLine), "")};
OpenPOWER on IntegriCloud