<div dir="ltr"><div dir="ltr"><div dir="ltr">Sorry Douglas. It was indeed a flaky test. Disabled in r344586 and then fixed in r344595.</div></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Oct 16, 2018 at 3:57 AM <<a href="mailto:douglas.yung@sony.com">douglas.yung@sony.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Sam,<br>
<br>
The test you added in this commit is timing out when run on the PS4 Windows bot:<br>
<br>
<a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/20724/steps/test/logs/stdio" rel="noreferrer" target="_blank">http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/20724/steps/test/logs/stdio</a><br>
<br>
command timed out: 1200 seconds without output running ['ninja', '-j', '36', 'check-all'], attempting to kill<br>
FAIL: Extra Tools Unit Tests :: clangd/./ClangdTests.exe/BackgroundIndexTest.IndexTwoFiles (44401 of 44401)<br>
******************** TEST 'Extra Tools Unit Tests :: clangd/./ClangdTests.exe/BackgroundIndexTest.IndexTwoFiles' FAILED ********************<br>
Note: Google Test filter = BackgroundIndexTest.IndexTwoFiles<br>
<br>
[==========] Running 1 test from 1 test case.<br>
<br>
[----------] Global test environment set-up.<br>
<br>
[----------] 1 test from BackgroundIndexTest<br>
<br>
[ RUN ] BackgroundIndexTest.IndexTwoFiles<br>
<br>
<br>
********************<br>
program finished with exit code 1<br>
elapsedTime=1446.100000<br>
<br>
Can you take a look?<br>
<br>
Douglas Yung<br>
<br>
> -----Original Message-----<br>
> From: cfe-commits [mailto:<a href="mailto:cfe-commits-bounces@lists.llvm.org" target="_blank">cfe-commits-bounces@lists.llvm.org</a>] On Behalf<br>
> Of Sam McCall via cfe-commits<br>
> Sent: Monday, October 15, 2018 6:34<br>
> To: <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
> Subject: [clang-tools-extra] r344513 - [clangd] Minimal implementation<br>
> of automatic static index (not enabled).<br>
> <br>
> Author: sammccall<br>
> Date: Mon Oct 15 06:34:10 2018<br>
> New Revision: 344513<br>
> <br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=344513&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=344513&view=rev</a><br>
> Log:<br>
> [clangd] Minimal implementation of automatic static index (not<br>
> enabled).<br>
> <br>
> Summary:<br>
> See <a href="http://tinyurl.com/clangd-automatic-index" rel="noreferrer" target="_blank">tinyurl.com/clangd-automatic-index</a> for design and goals.<br>
> <br>
> Lots of limitations to keep this patch smallish, TODOs everywhere:<br>
> - no serialization to disk<br>
> - no changes to dynamic index, which now has a much simpler job<br>
> - no partitioning of symbols by file to avoid duplication of header<br>
> symbols<br>
> - no reindexing of edited files<br>
> - only a single worker thread<br>
> - compilation database is slurped synchronously (doesn't scale)<br>
> - uses memindex, rebuilds after every file (should be dex,<br>
> periodically)<br>
> <br>
> It's not hooked up to ClangdServer/ClangdLSPServer yet: the layering<br>
> isn't clear (it should really be in ClangdServer, but ClangdLSPServer<br>
> has all the CDB interactions).<br>
> <br>
> Reviewers: ioeric<br>
> <br>
> Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman,<br>
> kadircet, jfb, cfe-commits<br>
> <br>
> Differential Revision: <a href="https://reviews.llvm.org/D53032" rel="noreferrer" target="_blank">https://reviews.llvm.org/D53032</a><br>
> <br>
> Added:<br>
> clang-tools-extra/trunk/clangd/index/Background.cpp<br>
> clang-tools-extra/trunk/clangd/index/Background.h<br>
> clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp<br>
> Modified:<br>
> clang-tools-extra/trunk/clangd/CMakeLists.txt<br>
> clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt<br>
> clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp<br>
> clang-tools-extra/trunk/unittests/clangd/SyncAPI.h<br>
> <br>
> Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-</a><br>
> extra/trunk/clangd/CMakeLists.txt?rev=344513&r1=344512&r2=344513&view=d<br>
> iff<br>
> =======================================================================<br>
> =======<br>
> --- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)<br>
> +++ clang-tools-extra/trunk/clangd/CMakeLists.txt Mon Oct 15 06:34:10<br>
> 2018<br>
> @@ -38,6 +38,7 @@ add_clang_library(clangDaemon<br>
> URI.cpp<br>
> XRefs.cpp<br>
> <br>
> + index/Background.cpp<br>
> index/CanonicalIncludes.cpp<br>
> index/FileIndex.cpp<br>
> index/Index.cpp<br>
> <br>
> Added: clang-tools-extra/trunk/clangd/index/Background.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-</a><br>
> extra/trunk/clangd/index/Background.cpp?rev=344513&view=auto<br>
> =======================================================================<br>
> =======<br>
> --- clang-tools-extra/trunk/clangd/index/Background.cpp (added)<br>
> +++ clang-tools-extra/trunk/clangd/index/Background.cpp Mon Oct 15<br>
> 06:34:10 2018<br>
> @@ -0,0 +1,191 @@<br>
> +//===-- Background.cpp - Build an index in a background thread -------<br>
> -----===//<br>
> +//<br>
> +// The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open<br>
> Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===-----------------------------------------------------------------<br>
> -----===//<br>
> +<br>
> +#include "index/Background.h"<br>
> +#include "ClangdUnit.h"<br>
> +#include "Compiler.h"<br>
> +#include "Logger.h"<br>
> +#include "Trace.h"<br>
> +#include "index/IndexAction.h"<br>
> +#include "index/MemIndex.h"<br>
> +#include "index/Serialization.h"<br>
> +#include "llvm/Support/SHA1.h"<br>
> +#include <random><br>
> +<br>
> +using namespace llvm;<br>
> +namespace clang {<br>
> +namespace clangd {<br>
> +<br>
> +BackgroundIndex::BackgroundIndex(Context BackgroundContext,<br>
> + StringRef ResourceDir,<br>
> + const FileSystemProvider &FSProvider)<br>
> + : SwapIndex(llvm::make_unique<MemIndex>()),<br>
> ResourceDir(ResourceDir),<br>
> + FSProvider(FSProvider),<br>
> BackgroundContext(std::move(BackgroundContext)),<br>
> + Thread([this] { run(); }) {}<br>
> +<br>
> +BackgroundIndex::~BackgroundIndex() {<br>
> + stop();<br>
> + Thread.join();<br>
> +}<br>
> +<br>
> +void BackgroundIndex::stop() {<br>
> + {<br>
> + std::lock_guard<std::mutex> Lock(QueueMu);<br>
> + ShouldStop = true;<br>
> + }<br>
> + QueueCV.notify_all();<br>
> +}<br>
> +<br>
> +void BackgroundIndex::run() {<br>
> + WithContext Background(std::move(BackgroundContext));<br>
> + while (true) {<br>
> + llvm::Optional<Task> Task;<br>
> + {<br>
> + std::unique_lock<std::mutex> Lock(QueueMu);<br>
> + QueueCV.wait(Lock, [&] { return ShouldStop || !Queue.empty();<br>
> });<br>
> + if (ShouldStop) {<br>
> + Queue.clear();<br>
> + QueueCV.notify_all();<br>
> + return;<br>
> + }<br>
> + ++NumActiveTasks;<br>
> + Task = std::move(Queue.front());<br>
> + Queue.pop_front();<br>
> + }<br>
> + (*Task)();<br>
> + {<br>
> + std::unique_lock<std::mutex> Lock(QueueMu);<br>
> + assert(NumActiveTasks > 0 && "before decrementing");<br>
> + --NumActiveTasks;<br>
> + }<br>
> + QueueCV.notify_all();<br>
> + }<br>
> +}<br>
> +<br>
> +void BackgroundIndex::blockUntilIdleForTest() {<br>
> + std::unique_lock<std::mutex> Lock(QueueMu);<br>
> + QueueCV.wait(Lock, [&] { return Queue.empty() && NumActiveTasks ==<br>
> 0; });<br>
> +}<br>
> +<br>
> +void BackgroundIndex::enqueue(StringRef Directory,<br>
> + tooling::CompileCommand Cmd) {<br>
> + std::lock_guard<std::mutex> Lock(QueueMu);<br>
> + enqueueLocked(std::move(Cmd));<br>
> +}<br>
> +<br>
> +void BackgroundIndex::enqueueAll(StringRef Directory,<br>
> + const tooling::CompilationDatabase<br>
> &CDB) {<br>
> + trace::Span Tracer("BackgroundIndexEnqueueCDB");<br>
> + // FIXME: this function may be slow. Perhaps enqueue a task to re-<br>
> read the CDB<br>
> + // from disk and enqueue the commands asynchronously?<br>
> + auto Cmds = CDB.getAllCompileCommands();<br>
> + SPAN_ATTACH(Tracer, "commands", int64_t(Cmds.size()));<br>
> + std::mt19937 Generator(std::random_device{}());<br>
> + std::shuffle(Cmds.begin(), Cmds.end(), Generator);<br>
> + log("Enqueueing {0} commands for indexing from {1}", Cmds.size(),<br>
> Directory);<br>
> + {<br>
> + std::lock_guard<std::mutex> Lock(QueueMu);<br>
> + for (auto &Cmd : Cmds)<br>
> + enqueueLocked(std::move(Cmd));<br>
> + }<br>
> + QueueCV.notify_all();<br>
> +}<br>
> +<br>
> +void BackgroundIndex::enqueueLocked(tooling::CompileCommand Cmd) {<br>
> + Queue.push_back(Bind(<br>
> + [this](tooling::CompileCommand Cmd) {<br>
> + std::string Filename = Cmd.Filename;<br>
> + Cmd.CommandLine.push_back("-resource-dir=" + ResourceDir);<br>
> + if (auto Error = index(std::move(Cmd)))<br>
> + log("Indexing {0} failed: {1}", Filename, std::move(Error));<br>
> + },<br>
> + std::move(Cmd)));<br>
> +}<br>
> +<br>
> +llvm::Error BackgroundIndex::index(tooling::CompileCommand Cmd) {<br>
> + trace::Span Tracer("BackgroundIndex");<br>
> + SPAN_ATTACH(Tracer, "file", Cmd.Filename);<br>
> + SmallString<128> AbsolutePath;<br>
> + if (llvm::sys::path::is_absolute(Cmd.Filename)) {<br>
> + AbsolutePath = Cmd.Filename;<br>
> + } else {<br>
> + AbsolutePath = Cmd.Directory;<br>
> + llvm::sys::path::append(AbsolutePath, Cmd.Filename);<br>
> + }<br>
> +<br>
> + auto FS = FSProvider.getFileSystem();<br>
> + auto Buf = FS->getBufferForFile(AbsolutePath);<br>
> + if (!Buf)<br>
> + return errorCodeToError(Buf.getError());<br>
> + StringRef Contents = Buf->get()->getBuffer();<br>
> + auto Hash = SHA1::hash({(const uint8_t *)Contents.data(),<br>
> Contents.size()});<br>
> +<br>
> + if (FileHash.lookup(AbsolutePath) == Hash) {<br>
> + vlog("No need to index {0}, already up to date", AbsolutePath);<br>
> + return Error::success();<br>
> + }<br>
> +<br>
> + log("Indexing {0}", Cmd.Filename, toHex(Hash));<br>
> + ParseInputs Inputs;<br>
> + Inputs.FS = std::move(FS);<br>
> + Inputs.FS->setCurrentWorkingDirectory(Cmd.Directory);<br>
> + Inputs.CompileCommand = std::move(Cmd);<br>
> + auto CI = buildCompilerInvocation(Inputs);<br>
> + if (!CI)<br>
> + return createStringError(llvm::inconvertibleErrorCode(),<br>
> + "Couldn't build compiler invocation");<br>
> + IgnoreDiagnostics IgnoreDiags;<br>
> + auto Clang = prepareCompilerInstance(<br>
> + std::move(CI), /*Preamble=*/nullptr, std::move(*Buf),<br>
> + std::make_shared<PCHContainerOperations>(), Inputs.FS,<br>
> IgnoreDiags);<br>
> + if (!Clang)<br>
> + return createStringError(llvm::inconvertibleErrorCode(),<br>
> + "Couldn't build compiler instance");<br>
> +<br>
> + SymbolCollector::Options IndexOpts;<br>
> + SymbolSlab Symbols;<br>
> + RefSlab Refs;<br>
> + IndexFileIn IndexData;<br>
> + auto Action = createStaticIndexingAction(<br>
> + IndexOpts, [&](SymbolSlab S) { Symbols = std::move(S); },<br>
> + [&](RefSlab R) { Refs = std::move(R); });<br>
> +<br>
> + // We're going to run clang here, and it could potentially crash.<br>
> + // We could use CrashRecoveryContext to try to make indexing crashes<br>
> nonfatal,<br>
> + // but the leaky "recovery" is pretty scary too in a long-running<br>
> process.<br>
> + // If crashes are a real problem, maybe we should fork a child<br>
> process.<br>
> +<br>
> + const FrontendInputFile &Input = Clang-<br>
> >getFrontendOpts().Inputs.front();<br>
> + if (!Action->BeginSourceFile(*Clang, Input))<br>
> + return createStringError(llvm::inconvertibleErrorCode(),<br>
> + "BeginSourceFile() failed");<br>
> + if (!Action->Execute())<br>
> + return createStringError(llvm::inconvertibleErrorCode(),<br>
> + "Execute() failed");<br>
> + Action->EndSourceFile();<br>
> +<br>
> + log("Indexed {0} ({1} symbols, {2} refs)",<br>
> Inputs.CompileCommand.Filename,<br>
> + Symbols.size(), Refs.size());<br>
> + SPAN_ATTACH(Tracer, "symbols", int(Symbols.size()));<br>
> + SPAN_ATTACH(Tracer, "refs", int(Refs.size()));<br>
> + // FIXME: partition the symbols by file rather than TU, to avoid<br>
> duplication.<br>
> + IndexedSymbols.update(AbsolutePath,<br>
> +<br>
> llvm::make_unique<SymbolSlab>(std::move(Symbols)),<br>
> + llvm::make_unique<RefSlab>(std::move(Refs)));<br>
> + FileHash[AbsolutePath] = Hash;<br>
> +<br>
> + // FIXME: this should rebuild once-in-a-while, not after every file.<br>
> + // At that point we should use Dex, too.<br>
> + vlog("Rebuilding automatic index");<br>
> + reset(IndexedSymbols.buildMemIndex());<br>
> + return Error::success();<br>
> +}<br>
> +<br>
> +} // namespace clangd<br>
> +} // namespace clang<br>
> <br>
> Added: clang-tools-extra/trunk/clangd/index/Background.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-</a><br>
> extra/trunk/clangd/index/Background.h?rev=344513&view=auto<br>
> =======================================================================<br>
> =======<br>
> --- clang-tools-extra/trunk/clangd/index/Background.h (added)<br>
> +++ clang-tools-extra/trunk/clangd/index/Background.h Mon Oct 15<br>
> 06:34:10 2018<br>
> @@ -0,0 +1,79 @@<br>
> +//===--- Background.h - Build an index in a background thread ----*-<br>
> C++-*-===//<br>
> +//<br>
> +// The LLVM Compiler Infrastructure<br>
> +//<br>
> +// This file is distributed under the University of Illinois Open<br>
> Source<br>
> +// License. See LICENSE.TXT for details.<br>
> +//<br>
> +//===-----------------------------------------------------------------<br>
> -----===//<br>
> +<br>
> +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUND_H<br>
> +#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_BACKGROUND_H<br>
> +<br>
> +#include "Context.h"<br>
> +#include "FSProvider.h"<br>
> +#include "index/FileIndex.h"<br>
> +#include "index/Index.h"<br>
> +#include "clang/Tooling/CompilationDatabase.h"<br>
> +#include "llvm/Support/SHA1.h"<br>
> +#include <condition_variable><br>
> +#include <deque><br>
> +#include <thread><br>
> +<br>
> +namespace clang {<br>
> +namespace clangd {<br>
> +<br>
> +// Builds an in-memory index by by running the static indexer action<br>
> over<br>
> +// all commands in a compilation database. Indexing happens in the<br>
> background.<br>
> +// FIXME: it should also persist its state on disk for fast start.<br>
> +// FIXME: it should watch for changes to files on disk.<br>
> +class BackgroundIndex : public SwapIndex {<br>
> +public:<br>
> + // FIXME: resource-dir injection should be hoisted somewhere common.<br>
> + BackgroundIndex(Context BackgroundContext, StringRef ResourceDir,<br>
> + const FileSystemProvider &);<br>
> + ~BackgroundIndex(); // Blocks while the current task finishes.<br>
> +<br>
> + // Enqueue a translation unit for indexing.<br>
> + // The indexing happens in a background thread, so the symbols will<br>
> be<br>
> + // available sometime later.<br>
> + void enqueue(llvm::StringRef Directory, tooling::CompileCommand);<br>
> + // Index all TUs described in the compilation database.<br>
> + void enqueueAll(llvm::StringRef Directory,<br>
> + const tooling::CompilationDatabase &);<br>
> +<br>
> + // Cause background threads to stop after ther current task, any<br>
> remaining<br>
> + // tasks will be discarded.<br>
> + void stop();<br>
> +<br>
> + // Wait until the queue is empty, to allow deterministic testing.<br>
> + void blockUntilIdleForTest();<br>
> +<br>
> +private:<br>
> + // configuration<br>
> + std::string ResourceDir;<br>
> + const FileSystemProvider &FSProvider;<br>
> + Context BackgroundContext;<br>
> +<br>
> + // index state<br>
> + llvm::Error index(tooling::CompileCommand);<br>
> + FileSymbols IndexedSymbols; // Index contents.<br>
> + using Hash = decltype(llvm::SHA1::hash({}));<br>
> + llvm::StringMap<Hash> FileHash; // Digest of indexed file.<br>
> +<br>
> + // queue management<br>
> + using Task = std::function<void()>; // FIXME: use multiple worker<br>
> threads.<br>
> + void run(); // Main loop executed by Thread. Runs tasks from Queue.<br>
> + void enqueueLocked(tooling::CompileCommand Cmd);<br>
> + std::thread Thread;<br>
> + std::mutex QueueMu;<br>
> + unsigned NumActiveTasks = 0; // Only idle when queue is empty *and*<br>
> no tasks.<br>
> + std::condition_variable QueueCV;<br>
> + bool ShouldStop = false;<br>
> + std::deque<Task> Queue;<br>
> +};<br>
> +<br>
> +} // namespace clangd<br>
> +} // namespace clang<br>
> +<br>
> +#endif<br>
> <br>
> Added: clang-tools-<br>
> extra/trunk/unittests/clangd/BackgroundIndexTests.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-</a><br>
> extra/trunk/unittests/clangd/BackgroundIndexTests.cpp?rev=344513&view=a<br>
> uto<br>
> =======================================================================<br>
> =======<br>
> --- clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp<br>
> (added)<br>
> +++ clang-tools-extra/trunk/unittests/clangd/BackgroundIndexTests.cpp<br>
> Mon Oct 15 06:34:10 2018<br>
> @@ -0,0 +1,37 @@<br>
> +#include "SyncAPI.h"<br>
> +#include "TestFS.h"<br>
> +#include "index/Background.h"<br>
> +#include "gmock/gmock.h"<br>
> +#include "gtest/gtest.h"<br>
> +<br>
> +using testing::UnorderedElementsAre;<br>
> +<br>
> +namespace clang {<br>
> +namespace clangd {<br>
> +<br>
> +MATCHER_P(Named, N, "") { return arg.Name == N; }<br>
> +<br>
> +TEST(BackgroundIndexTest, IndexTwoFiles) {<br>
> + MockFSProvider FS;<br>
> + // a.h yields different symbols when included by A.cc vs B.cc.<br>
> + // Currently we store symbols for each TU, so we get both.<br>
> + FS.Files[testPath("root/A.h")] = "void a_h(); void NAME(){}";<br>
> + FS.Files[testPath("root/A.cc")] = "#include \"A.h\"";<br>
> + FS.Files[testPath("root/B.cc")] = "#define NAME bar\n#include<br>
> \"A.h\"";<br>
> + BackgroundIndex Idx(Context::empty(), "", FS);<br>
> +<br>
> + tooling::CompileCommand Cmd;<br>
> + Cmd.Filename = testPath("root/A.cc");<br>
> + Cmd.Directory = testPath("root");<br>
> + Cmd.CommandLine = {"clang++", "-DNAME=foo", testPath("root/A.cc")};<br>
> + Idx.enqueue(testPath("root"), Cmd);<br>
> + Cmd.CommandLine.back() = Cmd.Filename = testPath("root/B.cc");<br>
> + Idx.enqueue(testPath("root"), Cmd);<br>
> +<br>
> + Idx.blockUntilIdleForTest();<br>
> + EXPECT_THAT(runFuzzyFind(Idx, ""),<br>
> + UnorderedElementsAre(Named("a_h"), Named("foo"),<br>
> Named("bar")));<br>
> +}<br>
> +<br>
> +} // namespace clangd<br>
> +} // namespace clang<br>
> <br>
> Modified: clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-</a><br>
> extra/trunk/unittests/clangd/CMakeLists.txt?rev=344513&r1=344512&r2=344<br>
> 513&view=diff<br>
> =======================================================================<br>
> =======<br>
> --- clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt (original)<br>
> +++ clang-tools-extra/trunk/unittests/clangd/CMakeLists.txt Mon Oct 15<br>
> 06:34:10 2018<br>
> @@ -10,6 +10,7 @@ include_directories(<br>
> <br>
> add_extra_unittest(ClangdTests<br>
> Annotations.cpp<br>
> + BackgroundIndexTests.cpp<br>
> CancellationTests.cpp<br>
> ClangdTests.cpp<br>
> ClangdUnitTests.cpp<br>
> <br>
> Modified: clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-</a><br>
> extra/trunk/unittests/clangd/SyncAPI.cpp?rev=344513&r1=344512&r2=344513<br>
> &view=diff<br>
> =======================================================================<br>
> =======<br>
> --- clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp (original)<br>
> +++ clang-tools-extra/trunk/unittests/clangd/SyncAPI.cpp Mon Oct 15<br>
> 06:34:10 2018<br>
> @@ -125,5 +125,17 @@ runDocumentSymbols(ClangdServer &Server,<br>
> return std::move(*Result);<br>
> }<br>
> <br>
> +SymbolSlab runFuzzyFind(const SymbolIndex &Index, StringRef Query) {<br>
> + FuzzyFindRequest Req;<br>
> + Req.Query = Query;<br>
> + return runFuzzyFind(Index, Req);<br>
> +}<br>
> +<br>
> +SymbolSlab runFuzzyFind(const SymbolIndex &Index, const<br>
> FuzzyFindRequest &Req) {<br>
> + SymbolSlab::Builder Builder;<br>
> + Index.fuzzyFind(Req, [&](const Symbol &Sym) { Builder.insert(Sym);<br>
> });<br>
> + return std::move(Builder).build();<br>
> +}<br>
> +<br>
> } // namespace clangd<br>
> } // namespace clang<br>
> <br>
> Modified: clang-tools-extra/trunk/unittests/clangd/SyncAPI.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-</a><br>
> extra/trunk/unittests/clangd/SyncAPI.h?rev=344513&r1=344512&r2=344513&v<br>
> iew=diff<br>
> =======================================================================<br>
> =======<br>
> --- clang-tools-extra/trunk/unittests/clangd/SyncAPI.h (original)<br>
> +++ clang-tools-extra/trunk/unittests/clangd/SyncAPI.h Mon Oct 15<br>
> 06:34:10 2018<br>
> @@ -17,7 +17,7 @@<br>
> #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_SYNCAPI_H<br>
> <br>
> #include "ClangdServer.h"<br>
> -#include <future><br>
> +#include "index/Index.h"<br>
> <br>
> namespace clang {<br>
> namespace clangd {<br>
> @@ -50,6 +50,9 @@ runWorkspaceSymbols(ClangdServer &Server<br>
> llvm::Expected<std::vector<SymbolInformation>><br>
> runDocumentSymbols(ClangdServer &Server, PathRef File);<br>
> <br>
> +SymbolSlab runFuzzyFind(const SymbolIndex &Index, StringRef Query);<br>
> +SymbolSlab runFuzzyFind(const SymbolIndex &Index, const<br>
> FuzzyFindRequest &Req);<br>
> +<br>
> } // namespace clangd<br>
> } // namespace clang<br>
> <br>
> <br>
> <br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>