clang-tools  12.0.0git
Background.cpp
Go to the documentation of this file.
1 //===-- Background.cpp - Build an index in a background thread ------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "index/Background.h"
10 #include "Compiler.h"
11 #include "Config.h"
12 #include "Headers.h"
13 #include "ParsedAST.h"
14 #include "SourceCode.h"
15 #include "Symbol.h"
16 #include "URI.h"
18 #include "index/FileIndex.h"
19 #include "index/IndexAction.h"
20 #include "index/MemIndex.h"
21 #include "index/Ref.h"
22 #include "index/Relation.h"
23 #include "index/Serialization.h"
24 #include "index/SymbolCollector.h"
25 #include "support/Context.h"
26 #include "support/Logger.h"
27 #include "support/Path.h"
28 #include "support/Threading.h"
29 #include "support/ThreadsafeFS.h"
30 #include "support/Trace.h"
31 #include "clang/Basic/SourceLocation.h"
32 #include "clang/Basic/SourceManager.h"
33 #include "clang/Driver/Types.h"
34 #include "llvm/ADT/ArrayRef.h"
35 #include "llvm/ADT/DenseSet.h"
36 #include "llvm/ADT/Hashing.h"
37 #include "llvm/ADT/STLExtras.h"
38 #include "llvm/ADT/ScopeExit.h"
39 #include "llvm/ADT/StringMap.h"
40 #include "llvm/ADT/StringRef.h"
41 #include "llvm/ADT/StringSet.h"
42 #include "llvm/Support/Error.h"
43 #include "llvm/Support/Path.h"
44 #include "llvm/Support/Threading.h"
45 
46 #include <algorithm>
47 #include <atomic>
48 #include <chrono>
49 #include <condition_variable>
50 #include <cstddef>
51 #include <memory>
52 #include <mutex>
53 #include <numeric>
54 #include <queue>
55 #include <random>
56 #include <string>
57 #include <thread>
58 #include <utility>
59 #include <vector>
60 
61 namespace clang {
62 namespace clangd {
63 namespace {
64 
65 // We cannot use vfs->makeAbsolute because Cmd.FileName is either absolute or
66 // relative to Cmd.Directory, which might not be the same as current working
67 // directory.
68 llvm::SmallString<128> getAbsolutePath(const tooling::CompileCommand &Cmd) {
69  llvm::SmallString<128> AbsolutePath;
70  if (llvm::sys::path::is_absolute(Cmd.Filename)) {
71  AbsolutePath = Cmd.Filename;
72  } else {
73  AbsolutePath = Cmd.Directory;
74  llvm::sys::path::append(AbsolutePath, Cmd.Filename);
75  llvm::sys::path::remove_dots(AbsolutePath, true);
76  }
77  return AbsolutePath;
78 }
79 
80 bool shardIsStale(const LoadedShard &LS, llvm::vfs::FileSystem *FS) {
81  auto Buf = FS->getBufferForFile(LS.AbsolutePath);
82  if (!Buf) {
83  elog("Background-index: Couldn't read {0} to validate stored index: {1}",
84  LS.AbsolutePath, Buf.getError().message());
85  // There is no point in indexing an unreadable file.
86  return false;
87  }
88  return digest(Buf->get()->getBuffer()) != LS.Digest;
89 }
90 
91 } // namespace
92 
94  Context BackgroundContext, const ThreadsafeFS &TFS,
95  const GlobalCompilationDatabase &CDB,
96  BackgroundIndexStorage::Factory IndexStorageFactory, size_t ThreadPoolSize,
97  std::function<void(BackgroundQueue::Stats)> OnProgress,
98  std::function<Context(PathRef)> ContextProvider)
99  : SwapIndex(std::make_unique<MemIndex>()), TFS(TFS), CDB(CDB),
100  BackgroundContext(std::move(BackgroundContext)),
101  ContextProvider(std::move(ContextProvider)),
102  Rebuilder(this, &IndexedSymbols, ThreadPoolSize),
103  IndexStorageFactory(std::move(IndexStorageFactory)),
104  Queue(std::move(OnProgress)),
105  CommandsChanged(
106  CDB.watch([&](const std::vector<std::string> &ChangedFiles) {
107  enqueue(ChangedFiles);
108  })) {
109  assert(ThreadPoolSize > 0 && "Thread pool size can't be zero.");
110  assert(this->IndexStorageFactory && "Storage factory can not be null!");
111  for (unsigned I = 0; I < ThreadPoolSize; ++I) {
112  ThreadPool.runAsync("background-worker-" + llvm::Twine(I + 1), [this] {
113  WithContext Ctx(this->BackgroundContext.clone());
114  Queue.work([&] { Rebuilder.idle(); });
115  });
116  }
117 }
118 
120  stop();
121  ThreadPool.wait();
122 }
123 
124 BackgroundQueue::Task BackgroundIndex::changedFilesTask(
125  const std::vector<std::string> &ChangedFiles) {
126  BackgroundQueue::Task T([this, ChangedFiles] {
127  trace::Span Tracer("BackgroundIndexEnqueue");
128 
129  llvm::Optional<WithContext> WithProvidedContext;
130  if (ContextProvider)
131  WithProvidedContext.emplace(ContextProvider(/*Path=*/""));
132 
133  // We're doing this asynchronously, because we'll read shards here too.
134  log("Enqueueing {0} commands for indexing", ChangedFiles.size());
135  SPAN_ATTACH(Tracer, "files", int64_t(ChangedFiles.size()));
136 
137  auto NeedsReIndexing = loadProject(std::move(ChangedFiles));
138  // Run indexing for files that need to be updated.
139  std::shuffle(NeedsReIndexing.begin(), NeedsReIndexing.end(),
140  std::mt19937(std::random_device{}()));
141  std::vector<BackgroundQueue::Task> Tasks;
142  Tasks.reserve(NeedsReIndexing.size());
143  for (auto &Cmd : NeedsReIndexing)
144  Tasks.push_back(indexFileTask(std::move(Cmd)));
145  Queue.append(std::move(Tasks));
146  });
147 
148  T.QueuePri = LoadShards;
149  T.ThreadPri = llvm::ThreadPriority::Default;
150  return T;
151 }
152 
153 static llvm::StringRef filenameWithoutExtension(llvm::StringRef Path) {
154  Path = llvm::sys::path::filename(Path);
155  return Path.drop_back(llvm::sys::path::extension(Path).size());
156 }
157 
158 BackgroundQueue::Task BackgroundIndex::indexFileTask(std::string Path) {
159  std::string Tag = filenameWithoutExtension(Path).str();
160  BackgroundQueue::Task T([this, Path(std::move(Path))] {
161  llvm::Optional<WithContext> WithProvidedContext;
162  if (ContextProvider)
163  WithProvidedContext.emplace(ContextProvider(Path));
164  auto Cmd = CDB.getCompileCommand(Path);
165  if (!Cmd)
166  return;
167  if (auto Error = index(std::move(*Cmd)))
168  elog("Indexing {0} failed: {1}", Path, std::move(Error));
169  });
170  T.QueuePri = IndexFile;
171  T.Tag = std::move(Tag);
172  return T;
173 }
174 
175 void BackgroundIndex::boostRelated(llvm::StringRef Path) {
176  if (isHeaderFile(Path))
177  Queue.boost(filenameWithoutExtension(Path), IndexBoostedFile);
178 }
179 
180 /// Given index results from a TU, only update symbols coming from files that
181 /// are different or missing from than \p ShardVersionsSnapshot. Also stores new
182 /// index information on IndexStorage.
183 void BackgroundIndex::update(
184  llvm::StringRef MainFile, IndexFileIn Index,
185  const llvm::StringMap<ShardVersion> &ShardVersionsSnapshot,
186  bool HadErrors) {
187  // Keys are URIs.
188  llvm::StringMap<std::pair<Path, FileDigest>> FilesToUpdate;
189  // Note that sources do not contain any information regarding missing headers,
190  // since we don't even know what absolute path they should fall in.
191  for (const auto &IndexIt : *Index.Sources) {
192  const auto &IGN = IndexIt.getValue();
193  auto AbsPath = URI::resolve(IGN.URI, MainFile);
194  if (!AbsPath) {
195  elog("Failed to resolve URI: {0}", AbsPath.takeError());
196  continue;
197  }
198  const auto DigestIt = ShardVersionsSnapshot.find(*AbsPath);
199  // File has different contents, or indexing was successful this time.
200  if (DigestIt == ShardVersionsSnapshot.end() ||
201  DigestIt->getValue().Digest != IGN.Digest ||
202  (DigestIt->getValue().HadErrors && !HadErrors))
203  FilesToUpdate[IGN.URI] = {std::move(*AbsPath), IGN.Digest};
204  }
205 
206  // Shard slabs into files.
207  FileShardedIndex ShardedIndex(std::move(Index));
208 
209  // Build and store new slabs for each updated file.
210  for (const auto &FileIt : FilesToUpdate) {
211  auto Uri = FileIt.first();
212  auto IF = ShardedIndex.getShard(Uri);
213  assert(IF && "no shard for file in Index.Sources?");
214  PathRef Path = FileIt.getValue().first;
215 
216  // Only store command line hash for main files of the TU, since our
217  // current model keeps only one version of a header file.
218  if (Path != MainFile)
219  IF->Cmd.reset();
220 
221  // We need to store shards before updating the index, since the latter
222  // consumes slabs.
223  // FIXME: Also skip serializing the shard if it is already up-to-date.
224  if (auto Error = IndexStorageFactory(Path)->storeShard(Path, *IF))
225  elog("Failed to write background-index shard for file {0}: {1}", Path,
226  std::move(Error));
227 
228  {
229  std::lock_guard<std::mutex> Lock(ShardVersionsMu);
230  const auto &Hash = FileIt.getValue().second;
231  auto DigestIt = ShardVersions.try_emplace(Path);
232  ShardVersion &SV = DigestIt.first->second;
233  // Skip if file is already up to date, unless previous index was broken
234  // and this one is not.
235  if (!DigestIt.second && SV.Digest == Hash && SV.HadErrors && !HadErrors)
236  continue;
237  SV.Digest = Hash;
238  SV.HadErrors = HadErrors;
239 
240  // This can override a newer version that is added in another thread, if
241  // this thread sees the older version but finishes later. This should be
242  // rare in practice.
243  IndexedSymbols.update(
244  Path, std::make_unique<SymbolSlab>(std::move(*IF->Symbols)),
245  std::make_unique<RefSlab>(std::move(*IF->Refs)),
246  std::make_unique<RelationSlab>(std::move(*IF->Relations)),
247  Path == MainFile);
248  }
249  }
250 }
251 
252 llvm::Error BackgroundIndex::index(tooling::CompileCommand Cmd) {
253  trace::Span Tracer("BackgroundIndex");
254  SPAN_ATTACH(Tracer, "file", Cmd.Filename);
255  auto AbsolutePath = getAbsolutePath(Cmd);
256 
257  auto FS = TFS.view(Cmd.Directory);
258  auto Buf = FS->getBufferForFile(AbsolutePath);
259  if (!Buf)
260  return llvm::errorCodeToError(Buf.getError());
261  auto Hash = digest(Buf->get()->getBuffer());
262 
263  // Take a snapshot of the versions to avoid locking for each file in the TU.
264  llvm::StringMap<ShardVersion> ShardVersionsSnapshot;
265  {
266  std::lock_guard<std::mutex> Lock(ShardVersionsMu);
267  ShardVersionsSnapshot = ShardVersions;
268  }
269 
270  vlog("Indexing {0} (digest:={1})", Cmd.Filename, llvm::toHex(Hash));
272  Inputs.TFS = &TFS;
273  Inputs.CompileCommand = std::move(Cmd);
275  auto CI = buildCompilerInvocation(Inputs, IgnoreDiags);
276  if (!CI)
277  return llvm::createStringError(llvm::inconvertibleErrorCode(),
278  "Couldn't build compiler invocation");
279 
280  auto Clang =
281  prepareCompilerInstance(std::move(CI), /*Preamble=*/nullptr,
282  std::move(*Buf), std::move(FS), IgnoreDiags);
283  if (!Clang)
284  return llvm::createStringError(llvm::inconvertibleErrorCode(),
285  "Couldn't build compiler instance");
286 
287  SymbolCollector::Options IndexOpts;
288  // Creates a filter to not collect index results from files with unchanged
289  // digests.
290  IndexOpts.FileFilter = [&ShardVersionsSnapshot](const SourceManager &SM,
291  FileID FID) {
292  const auto *F = SM.getFileEntryForID(FID);
293  if (!F)
294  return false; // Skip invalid files.
295  auto AbsPath = getCanonicalPath(F, SM);
296  if (!AbsPath)
297  return false; // Skip files without absolute path.
298  auto Digest = digestFile(SM, FID);
299  if (!Digest)
300  return false;
301  auto D = ShardVersionsSnapshot.find(*AbsPath);
302  if (D != ShardVersionsSnapshot.end() && D->second.Digest == Digest &&
303  !D->second.HadErrors)
304  return false; // Skip files that haven't changed, without errors.
305  return true;
306  };
307 
308  IndexFileIn Index;
310  IndexOpts, [&](SymbolSlab S) { Index.Symbols = std::move(S); },
311  [&](RefSlab R) { Index.Refs = std::move(R); },
312  [&](RelationSlab R) { Index.Relations = std::move(R); },
313  [&](IncludeGraph IG) { Index.Sources = std::move(IG); });
314 
315  // We're going to run clang here, and it could potentially crash.
316  // We could use CrashRecoveryContext to try to make indexing crashes nonfatal,
317  // but the leaky "recovery" is pretty scary too in a long-running process.
318  // If crashes are a real problem, maybe we should fork a child process.
319 
320  const FrontendInputFile &Input = Clang->getFrontendOpts().Inputs.front();
321  if (!Action->BeginSourceFile(*Clang, Input))
322  return llvm::createStringError(llvm::inconvertibleErrorCode(),
323  "BeginSourceFile() failed");
324  if (llvm::Error Err = Action->Execute())
325  return Err;
326 
327  Action->EndSourceFile();
328 
329  Index.Cmd = Inputs.CompileCommand;
330  assert(Index.Symbols && Index.Refs && Index.Sources &&
331  "Symbols, Refs and Sources must be set.");
332 
333  log("Indexed {0} ({1} symbols, {2} refs, {3} files)",
334  Inputs.CompileCommand.Filename, Index.Symbols->size(),
335  Index.Refs->numRefs(), Index.Sources->size());
336  SPAN_ATTACH(Tracer, "symbols", int(Index.Symbols->size()));
337  SPAN_ATTACH(Tracer, "refs", int(Index.Refs->numRefs()));
338  SPAN_ATTACH(Tracer, "sources", int(Index.Sources->size()));
339 
340  bool HadErrors = Clang->hasDiagnostics() &&
341  Clang->getDiagnostics().hasUncompilableErrorOccurred();
342  if (HadErrors) {
343  log("Failed to compile {0}, index may be incomplete", AbsolutePath);
344  for (auto &It : *Index.Sources)
345  It.second.Flags |= IncludeGraphNode::SourceFlag::HadErrors;
346  }
347  update(AbsolutePath, std::move(Index), ShardVersionsSnapshot, HadErrors);
348 
349  Rebuilder.indexedTU();
350  return llvm::Error::success();
351 }
352 
353 // Restores shards for \p MainFiles from index storage. Then checks staleness of
354 // those shards and returns a list of TUs that needs to be indexed to update
355 // staleness.
356 std::vector<std::string>
357 BackgroundIndex::loadProject(std::vector<std::string> MainFiles) {
358  // Drop files where background indexing is disabled in config.
359  if (ContextProvider)
360  llvm::erase_if(MainFiles, [&](const std::string &TU) {
361  // Load the config for each TU, as indexing may be selectively enabled.
362  WithContext WithProvidedContext(ContextProvider(TU));
363  return Config::current().Index.Background ==
365  });
366  Rebuilder.startLoading();
367  // Load shards for all of the mainfiles.
368  const std::vector<LoadedShard> Result =
369  loadIndexShards(MainFiles, IndexStorageFactory, CDB);
370  size_t LoadedShards = 0;
371  {
372  // Update in-memory state.
373  std::lock_guard<std::mutex> Lock(ShardVersionsMu);
374  for (auto &LS : Result) {
375  if (!LS.Shard)
376  continue;
377  auto SS =
378  LS.Shard->Symbols
379  ? std::make_unique<SymbolSlab>(std::move(*LS.Shard->Symbols))
380  : nullptr;
381  auto RS = LS.Shard->Refs
382  ? std::make_unique<RefSlab>(std::move(*LS.Shard->Refs))
383  : nullptr;
384  auto RelS =
385  LS.Shard->Relations
386  ? std::make_unique<RelationSlab>(std::move(*LS.Shard->Relations))
387  : nullptr;
388  ShardVersion &SV = ShardVersions[LS.AbsolutePath];
389  SV.Digest = LS.Digest;
390  SV.HadErrors = LS.HadErrors;
391  ++LoadedShards;
392 
393  IndexedSymbols.update(LS.AbsolutePath, std::move(SS), std::move(RS),
394  std::move(RelS), LS.CountReferences);
395  }
396  }
397  Rebuilder.loadedShard(LoadedShards);
398  Rebuilder.doneLoading();
399 
400  auto FS = TFS.view(/*CWD=*/llvm::None);
401  llvm::DenseSet<PathRef> TUsToIndex;
402  // We'll accept data from stale shards, but ensure the files get reindexed
403  // soon.
404  for (auto &LS : Result) {
405  if (!shardIsStale(LS, FS.get()))
406  continue;
407  PathRef TUForFile = LS.DependentTU;
408  assert(!TUForFile.empty() && "File without a TU!");
409 
410  // FIXME: Currently, we simply schedule indexing on a TU whenever any of
411  // its dependencies needs re-indexing. We might do it smarter by figuring
412  // out a minimal set of TUs that will cover all the stale dependencies.
413  // FIXME: Try looking at other TUs if no compile commands are available
414  // for this TU, i.e TU was deleted after we performed indexing.
415  TUsToIndex.insert(TUForFile);
416  }
417 
418  return {TUsToIndex.begin(), TUsToIndex.end()};
419 }
420 
421 } // namespace clangd
422 } // namespace clang
llvm::Optional< SymbolSlab > Symbols
Definition: Serialization.h:43
An immutable symbol container that stores a set of symbols.
Definition: Symbol.h:177
llvm::Optional< tooling::CompileCommand > Cmd
Definition: Serialization.h:49
const ThreadsafeFS * TFS
Definition: Compiler.h:49
llvm::unique_function< BackgroundIndexStorage *(PathRef)> Factory
Definition: Background.h:56
An efficient structure of storing large set of symbol references in memory.
Definition: Ref.h:104
void boostRelated(llvm::StringRef Path)
Boosts priority of indexing related to Path.
Definition: Background.cpp:175
llvm::Optional< IndexFileIn > getShard(llvm::StringRef Uri) const
Generates index shard for the Uri.
Definition: FileIndex.cpp:178
virtual llvm::Optional< tooling::CompileCommand > getCompileCommand(PathRef File) const =0
If there are any known-good commands for building this file, returns one.
HTMLTag Tag
ParseInputs Inputs
MockFS FS
BackgroundPolicy Background
Whether this TU should be indexed.
Definition: Config.h:63
static llvm::StringRef filenameWithoutExtension(llvm::StringRef Path)
Definition: Background.cpp:153
llvm::StringRef PathRef
A typedef to represent a ref to file path.
Definition: Path.h:23
std::unique_ptr< CompilerInstance > prepareCompilerInstance(std::unique_ptr< clang::CompilerInvocation > CI, const PrecompiledPreamble *Preamble, std::unique_ptr< llvm::MemoryBuffer > Buffer, llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS, DiagnosticConsumer &DiagsClient)
Definition: Compiler.cpp:91
Documents should not be synced at all.
llvm::Optional< RelationSlab > Relations
Definition: Serialization.h:45
void vlog(const char *Fmt, Ts &&... Vals)
Definition: Logger.h:67
void elog(const char *Fmt, Ts &&... Vals)
Definition: Logger.h:56
llvm::Optional< IncludeGraph > Sources
Definition: Serialization.h:47
llvm::IntrusiveRefCntPtr< llvm::vfs::FileSystem > view(llvm::NoneType CWD) const
Obtain a vfs::FileSystem with an arbitrary initial working directory.
Definition: ThreadsafeFS.h:34
std::unique_ptr< CompilerInvocation > CI
std::string MainFile
void boost(llvm::StringRef Tag, unsigned NewPriority)
Provides compilation arguments used for parsing C and C++ files.
void update(llvm::StringRef Key, std::unique_ptr< SymbolSlab > Symbols, std::unique_ptr< RefSlab > Refs, std::unique_ptr< RelationSlab > Relations, bool CountReferences)
Updates all slabs associated with the Key.
Definition: FileIndex.cpp:226
Context Ctx
llvm::StringMap< IncludeGraphNode > IncludeGraph
Definition: Headers.h:86
Context clone() const
Clone this context object.
Definition: Context.cpp:20
void runAsync(const llvm::Twine &Name, llvm::unique_function< void()> Action)
Definition: Threading.cpp:72
IgnoringDiagConsumer IgnoreDiags
llvm::unique_function< void()> Action
MemIndex is a naive in-memory index suitable for a small set of symbols.
Definition: MemIndex.h:19
void log(const char *Fmt, Ts &&... Vals)
Definition: Logger.h:62
std::string Path
A typedef to represent a file path.
Definition: Path.h:20
std::vector< LoadedShard > loadIndexShards(llvm::ArrayRef< Path > MainFiles, BackgroundIndexStorage::Factory &IndexStorageFactory, const GlobalCompilationDatabase &CDB)
Loads all shards for the TU MainFile from Storage.
tooling::CompileCommand CompileCommand
Definition: Compiler.h:48
void enqueue(const std::vector< std::string > &ChangedFiles)
Definition: Background.h:148
llvm::Optional< FileDigest > digestFile(const SourceManager &SM, FileID FID)
Definition: SourceCode.cpp:570
struct clang::clangd::Config::@1 Index
Controls background-index behavior.
A context is an immutable container for per-request data that must be propagated through layers that ...
Definition: Context.h:69
std::function< bool(const SourceManager &, FileID)> FileFilter
If this is set, only collect symbols/references from a file if FileFilter(SM, FID) is true...
WithContext replaces Context::current() with a provided scope.
Definition: Context.h:189
FileDigest digest(llvm::StringRef Content)
Definition: SourceCode.cpp:560
llvm::Optional< RefSlab > Refs
Definition: Serialization.h:44
Takes slabs coming from a TU (multiple files) and shards them per declaration location.
Definition: FileIndex.h:165
Information required to run clang, e.g. to parse AST or do code completion.
Definition: Compiler.h:47
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Wrapper for vfs::FileSystem for use in multithreaded programs like clangd.
Definition: ThreadsafeFS.h:28
std::unique_ptr< FrontendAction > createStaticIndexingAction(SymbolCollector::Options Opts, std::function< void(SymbolSlab)> SymbolsCallback, std::function< void(RefSlab)> RefsCallback, std::function< void(RelationSlab)> RelationsCallback, std::function< void(IncludeGraph)> IncludeGraphCallback)
std::unique_ptr< trace::EventTracer > Tracer
Definition: TraceTests.cpp:163
llvm::Optional< std::string > getCanonicalPath(const FileEntry *F, const SourceManager &SourceMgr)
Get the canonical path of F.
Definition: SourceCode.cpp:512
std::unique_ptr< CompilerInvocation > buildCompilerInvocation(const ParseInputs &Inputs, clang::DiagnosticConsumer &D, std::vector< std::string > *CC1Args)
Builds compiler invocation that could be used to build AST or preamble.
Definition: Compiler.cpp:45
BackgroundIndex(Context BackgroundContext, const ThreadsafeFS &, const GlobalCompilationDatabase &CDB, BackgroundIndexStorage::Factory IndexStorageFactory, size_t ThreadPoolSize=4, std::function< void(BackgroundQueue::Stats)> OnProgress=nullptr, std::function< Context(PathRef)> ContextProvider=nullptr)
If BuildIndexPeriodMs is greater than 0, the symbol index will only be rebuilt periodically (one per ...
Definition: Background.cpp:93
bool isHeaderFile(llvm::StringRef FileName, llvm::Optional< LangOptions > LangOpts)
Infers whether this is a header from the FileName and LangOpts (if presents).
static llvm::Expected< std::string > resolve(const URI &U, llvm::StringRef HintPath="")
Resolves the absolute path of U.
Definition: URI.cpp:232
void append(std::vector< Task >)
A work item on the thread pool&#39;s queue.
Definition: Background.h:70
static const Config & current()
Returns the Config of the current Context, or an empty configuration.
Definition: Config.cpp:17
Records an event whose duration is the lifetime of the Span object.
Definition: Trace.h:135
#define SPAN_ATTACH(S, Name, Expr)
Attach a key-value pair to a Span event.
Definition: Trace.h:154
void work(std::function< void()> OnIdle=nullptr)