clang-tools  14.0.0git
TUScheduler.h
Go to the documentation of this file.
1 //===--- TUScheduler.h -------------------------------------------*-C++-*-===//
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 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TUSCHEDULER_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TUSCHEDULER_H
11 
12 #include "ASTSignals.h"
13 #include "Compiler.h"
14 #include "Diagnostics.h"
17 #include "support/Function.h"
18 #include "support/MemoryTree.h"
19 #include "support/Path.h"
20 #include "support/Threading.h"
21 #include "llvm/ADT/Optional.h"
22 #include "llvm/ADT/STLExtras.h"
23 #include "llvm/ADT/StringMap.h"
24 #include "llvm/ADT/StringRef.h"
25 #include <chrono>
26 #include <string>
27 
28 namespace clang {
29 namespace clangd {
30 class ParsedAST;
31 struct PreambleData;
32 
33 /// Returns a number of a default async threads to use for TUScheduler.
34 /// Returned value is always >= 1 (i.e. will not cause requests to be processed
35 /// synchronously).
37 
38 struct InputsAndAST {
41 };
42 
44  llvm::StringRef Contents;
45  const tooling::CompileCommand &Command;
46  // This can be nullptr if no preamble is available.
48  // This can be nullptr if no ASTSignals are available.
50 };
51 
52 /// Determines whether diagnostics should be generated for a file snapshot.
53 enum class WantDiagnostics {
54  Yes, /// Diagnostics must be generated for this snapshot.
55  No, /// Diagnostics must not be generated for this snapshot.
56  Auto, /// Diagnostics must be generated for this snapshot or a subsequent one,
57  /// within a bounded amount of time.
58 };
59 
60 /// Configuration of the AST retention policy. This only covers retention of
61 /// *idle* ASTs. If queue has operations requiring the AST, they might be
62 /// kept in memory.
64  /// Maximum number of ASTs to be retained in memory when there are no pending
65  /// requests for them.
66  unsigned MaxRetainedASTs = 3;
67 };
68 
69 /// Clangd may wait after an update to see if another one comes along.
70 /// This is so we rebuild once the user stops typing, not when they start.
71 /// Debounce may be disabled/interrupted if we must build this version.
72 /// The debounce time is responsive to user preferences and rebuild time.
73 /// In the future, we could also consider different types of edits.
75  using clock = std::chrono::steady_clock;
76 
77  /// The minimum time that we always debounce for.
78  clock::duration Min = /*zero*/ {};
79  /// The maximum time we may debounce for.
80  clock::duration Max = /*zero*/ {};
81  /// Target debounce, as a fraction of file rebuild time.
82  /// e.g. RebuildRatio = 2, recent builds took 200ms => debounce for 400ms.
83  float RebuildRatio = 1;
84 
85  /// Compute the time to debounce based on this policy and recent build times.
86  clock::duration compute(llvm::ArrayRef<clock::duration> History) const;
87  /// A policy that always returns the same duration, useful for tests.
88  static DebouncePolicy fixed(clock::duration);
89 };
90 
91 enum class PreambleAction {
92  Idle,
93  Building,
94 };
95 
96 struct ASTAction {
97  enum Kind {
98  Queued, // The action is pending in the thread task queue to be run.
99  RunningAction, // Started running actions on the TU.
100  Building, // The AST is being built.
101  Idle, // Indicates the worker thread is idle, and ready to run any upcoming
102  // actions.
103  };
104  ASTAction() = default;
105  ASTAction(Kind K, llvm::StringRef Name) : K(K), Name(Name) {}
107  /// The name of the action currently running, e.g. Update, GoToDef, Hover.
108  /// Empty if we are in the idle state.
109  std::string Name;
110 };
111 
112 // Internal status of the TU in TUScheduler.
113 struct TUStatus {
114  struct BuildDetails {
115  /// Indicates whether clang failed to build the TU.
116  bool BuildFailed = false;
117  /// Indicates whether we reused the prebuilt AST.
118  bool ReuseAST = false;
119  };
120  /// Serialize this to an LSP file status item.
121  FileStatus render(PathRef File) const;
122 
125  /// Stores status of the last build for the translation unit.
127 };
128 
130 public:
131  virtual ~ParsingCallbacks() = default;
132 
133  /// Called on the AST that was built for emitting the preamble. The built AST
134  /// contains only AST nodes from the #include directives at the start of the
135  /// file. AST node in the current file should be observed on onMainAST call.
136  virtual void onPreambleAST(PathRef Path, llvm::StringRef Version,
137  ASTContext &Ctx,
138  std::shared_ptr<clang::Preprocessor> PP,
139  const CanonicalIncludes &) {}
140 
141  /// The argument function is run under the critical section guarding against
142  /// races when closing the files.
143  using PublishFn = llvm::function_ref<void(llvm::function_ref<void()>)>;
144  /// Called on the AST built for the file itself. Note that preamble AST nodes
145  /// are not deserialized and should be processed in the onPreambleAST call
146  /// instead.
147  /// The \p AST always contains all AST nodes for the main file itself, and
148  /// only a portion of the AST nodes deserialized from the preamble. Note that
149  /// some nodes from the preamble may have been deserialized and may also be
150  /// accessed from the main file AST, e.g. redecls of functions from preamble,
151  /// etc. Clients are expected to process only the AST nodes from the main file
152  /// in this callback (obtained via ParsedAST::getLocalTopLevelDecls) to obtain
153  /// optimal performance.
154  ///
155  /// When information about the file (e.g. diagnostics) is
156  /// published to clients, this should be wrapped in Publish, e.g.
157  /// void onMainAST(...) {
158  /// Diags = renderDiagnostics();
159  /// Publish([&] { notifyDiagnostics(Path, Diags); });
160  /// }
161  /// This guarantees that clients will see results in the correct sequence if
162  /// the file is concurrently closed and/or reopened. (The lambda passed to
163  /// Publish() may never run in this case).
164  virtual void onMainAST(PathRef Path, ParsedAST &AST, PublishFn Publish) {}
165 
166  /// Called whenever the AST fails to build. \p Diags will have the diagnostics
167  /// that led to failure.
168  virtual void onFailedAST(PathRef Path, llvm::StringRef Version,
169  std::vector<Diag> Diags, PublishFn Publish) {}
170 
171  /// Called whenever the TU status is updated.
172  virtual void onFileUpdated(PathRef File, const TUStatus &Status) {}
173 
174  /// Preamble for the TU have changed. This might imply new semantics (e.g.
175  /// different highlightings). Any actions on the file are guranteed to see new
176  /// preamble after the callback.
177  virtual void onPreamblePublished(PathRef File) {}
178 };
179 
180 /// Handles running tasks for ClangdServer and managing the resources (e.g.,
181 /// preambles and ASTs) for opened files.
182 /// TUScheduler is not thread-safe, only one thread should be providing updates
183 /// and scheduling tasks.
184 /// Callbacks are run on a threadpool and it's appropriate to do slow work in
185 /// them. Each task has a name, used for tracing (should be UpperCamelCase).
186 class TUScheduler {
187 public:
188  struct Options {
189  /// Number of concurrent actions.
190  /// Governs per-file worker threads and threads spawned for other tasks.
191  /// (This does not prevent threads being spawned, but rather blocks them).
192  /// If 0, executes actions synchronously on the calling thread.
194 
195  /// Cache (large) preamble data in RAM rather than temporary files on disk.
197 
198  /// Time to wait after an update to see if another one comes along.
199  /// This tries to ensure we rebuild once the user stops typing.
201 
202  /// Determines when to keep idle ASTs in memory for future use.
204 
205  /// Used to create a context that wraps each single operation.
206  /// Typically to inject per-file configuration.
207  /// If the path is empty, context sholud be "generic".
208  std::function<Context(PathRef)> ContextProvider;
209  };
210 
211  TUScheduler(const GlobalCompilationDatabase &CDB, const Options &Opts,
212  std::unique_ptr<ParsingCallbacks> ASTCallbacks = nullptr);
213  ~TUScheduler();
214 
215  struct FileStats {
216  std::size_t UsedBytesAST = 0;
217  std::size_t UsedBytesPreamble = 0;
218  unsigned PreambleBuilds = 0;
219  unsigned ASTBuilds = 0;
220  };
221  /// Returns resources used for each of the currently open files.
222  /// Results are inherently racy as they measure activity of other threads.
223  llvm::StringMap<FileStats> fileStats() const;
224 
225  /// Returns a list of files with ASTs currently stored in memory. This method
226  /// is not very reliable and is only used for test. E.g., the results will not
227  /// contain files that currently run something over their AST.
228  std::vector<Path> getFilesWithCachedAST() const;
229 
230  /// Schedule an update for \p File.
231  /// The compile command in \p Inputs is ignored; worker queries CDB to get
232  /// the actual compile command.
233  /// If diagnostics are requested (Yes), and the context is cancelled
234  /// before they are prepared, they may be skipped if eventual-consistency
235  /// permits it (i.e. WantDiagnostics is downgraded to Auto).
236  /// Returns true if the file was not previously tracked.
238 
239  /// Remove \p File from the list of tracked files and schedule removal of its
240  /// resources. Pending diagnostics for closed files may not be delivered, even
241  /// if requested with WantDiags::Auto or WantDiags::Yes.
242  void remove(PathRef File);
243 
244  /// Schedule an async task with no dependencies.
245  /// Path may be empty (it is used only to set the Context).
246  void run(llvm::StringRef Name, llvm::StringRef Path,
247  llvm::unique_function<void()> Action);
248 
249  /// Similar to run, except the task is expected to be quick.
250  /// This function will not honor AsyncThreadsCount (except
251  /// if threading is disabled with AsyncThreadsCount=0)
252  /// It is intended to run quick tasks that need to run ASAP
253  void runQuick(llvm::StringRef Name, llvm::StringRef Path,
254  llvm::unique_function<void()> Action);
255 
256  /// Defines how a runWithAST action is implicitly cancelled by other actions.
258  /// The request will run unless explicitly cancelled.
260  /// The request will be implicitly cancelled by a subsequent update().
261  /// (Only if the request was not yet cancelled).
262  /// Useful for requests that are generated by clients, without any explicit
263  /// user action. These can otherwise e.g. force every version to be built.
265  };
266 
267  /// Schedule an async read of the AST. \p Action will be called when AST is
268  /// ready. The AST passed to \p Action refers to the version of \p File
269  /// tracked at the time of the call, even if new updates are received before
270  /// \p Action is executed.
271  /// If an error occurs during processing, it is forwarded to the \p Action
272  /// callback.
273  /// If the context is cancelled before the AST is ready, or the invalidation
274  /// policy is triggered, the callback will receive a CancelledError.
275  void runWithAST(llvm::StringRef Name, PathRef File,
278 
279  /// Controls whether preamble reads wait for the preamble to be up-to-date.
281  /// The preamble may be generated from an older version of the file.
282  /// Reading from locations in the preamble may cause files to be re-read.
283  /// This gives callers two options:
284  /// - validate that the preamble is still valid, and only use it if so
285  /// - accept that the preamble contents may be outdated, and try to avoid
286  /// reading source code from headers.
287  /// This is the fastest option, usually a preamble is available immediately.
289  /// Besides accepting stale preamble, this also allow preamble to be absent
290  /// (not ready or failed to build).
292  };
293 
294  /// Schedule an async read of the preamble.
295  /// If there's no up-to-date preamble, we follow the PreambleConsistency
296  /// policy.
297  /// If an error occurs, it is forwarded to the \p Action callback.
298  /// Context cancellation is ignored and should be handled by the Action.
299  /// (In practice, the Action is almost always executed immediately).
300  void runWithPreamble(llvm::StringRef Name, PathRef File,
301  PreambleConsistency Consistency,
303 
304  /// Wait until there are no scheduled or running tasks.
305  /// Mostly useful for synchronizing tests.
306  bool blockUntilIdle(Deadline D) const;
307 
308 private:
309  /// This class stores per-file data in the Files map.
310  struct FileData;
311 
312 public:
313  /// Responsible for retaining and rebuilding idle ASTs. An implementation is
314  /// an LRU cache.
315  class ASTCache;
316  /// Tracks headers included by open files, to get known-good compile commands.
317  class HeaderIncluderCache;
318 
319  // The file being built/processed in the current thread. This is a hack in
320  // order to get the file name into the index implementations. Do not depend on
321  // this inside clangd.
322  // FIXME: remove this when there is proper index support via build system
323  // integration.
324  // FIXME: move to ClangdServer via createProcessingContext.
325  static llvm::Optional<llvm::StringRef> getFileBeingProcessedInContext();
326 
327  void profile(MemoryTree &MT) const;
328 
329 private:
330  void runWithSemaphore(llvm::StringRef Name, llvm::StringRef Path,
331  llvm::unique_function<void()> Action, Semaphore &Sem);
332 
333  const GlobalCompilationDatabase &CDB;
334  Options Opts;
335  std::unique_ptr<ParsingCallbacks> Callbacks; // not nullptr
336  Semaphore Barrier;
337  Semaphore QuickRunBarrier;
338  llvm::StringMap<std::unique_ptr<FileData>> Files;
339  std::unique_ptr<ASTCache> IdleASTs;
340  std::unique_ptr<HeaderIncluderCache> HeaderIncluders;
341  // None when running tasks synchronously and non-None when running tasks
342  // asynchronously.
343  llvm::Optional<AsyncTaskRunner> PreambleTasks;
344  llvm::Optional<AsyncTaskRunner> WorkerThreads;
345  // Used to create contexts for operations that are not bound to a particular
346  // file (e.g. index queries).
347  std::string LastActiveFile;
348 };
349 
350 } // namespace clangd
351 } // namespace clang
352 
353 #endif
clang::clangd::ParsingCallbacks::~ParsingCallbacks
virtual ~ParsingCallbacks()=default
clang::clangd::TUScheduler::runWithPreamble
void runWithPreamble(llvm::StringRef Name, PathRef File, PreambleConsistency Consistency, Callback< InputsAndPreamble > Action)
Schedule an async read of the preamble.
Definition: TUScheduler.cpp:1577
clang::clangd::getDefaultAsyncThreadsCount
unsigned getDefaultAsyncThreadsCount()
Returns a number of a default async threads to use for TUScheduler.
Definition: TUScheduler.cpp:1432
clang::clangd::ParsingCallbacks::PublishFn
llvm::function_ref< void(llvm::function_ref< void()>)> PublishFn
The argument function is run under the critical section guarding against races when closing the files...
Definition: TUScheduler.h:143
clang::clangd::Path
std::string Path
A typedef to represent a file path.
Definition: Path.h:26
clang::clangd::ASTRetentionPolicy
Configuration of the AST retention policy.
Definition: TUScheduler.h:63
clang::clangd::TUScheduler::~TUScheduler
~TUScheduler()
Definition: TUScheduler.cpp:1471
Path.h
clang::clangd::ParsingCallbacks::onFailedAST
virtual void onFailedAST(PathRef Path, llvm::StringRef Version, std::vector< Diag > Diags, PublishFn Publish)
Called whenever the AST fails to build.
Definition: TUScheduler.h:168
clang::clangd::WantDiagnostics::Yes
@ Yes
clang::clangd::TUScheduler::blockUntilIdle
bool blockUntilIdle(Deadline D) const
Wait until there are no scheduled or running tasks.
Definition: TUScheduler.cpp:1482
clang::clangd::InputsAndAST
Definition: TUScheduler.h:38
clang::clangd::ParsingCallbacks::onMainAST
virtual void onMainAST(PathRef Path, ParsedAST &AST, PublishFn Publish)
Called on the AST built for the file itself.
Definition: TUScheduler.h:164
clang::clangd::TUScheduler::FileStats::ASTBuilds
unsigned ASTBuilds
Definition: TUScheduler.h:219
clang::clangd::WantDiagnostics::Auto
@ Auto
Diagnostics must not be generated for this snapshot.
clang::clangd::TUStatus::BuildDetails
Definition: TUScheduler.h:114
clang::clangd::InputsAndPreamble::Preamble
const PreambleData * Preamble
Definition: TUScheduler.h:47
clang::clangd::DebouncePolicy::clock
std::chrono::steady_clock clock
Definition: TUScheduler.h:75
clang::clangd::PreambleAction
PreambleAction
Definition: TUScheduler.h:91
clang::clangd::ASTAction
Definition: TUScheduler.h:96
Ctx
Context Ctx
Definition: TUScheduler.cpp:454
clang::clangd::TUScheduler::run
void run(llvm::StringRef Name, llvm::StringRef Path, llvm::unique_function< void()> Action)
Schedule an async task with no dependencies.
Definition: TUScheduler.cpp:1529
clang::clangd::ParsingCallbacks::onFileUpdated
virtual void onFileUpdated(PathRef File, const TUStatus &Status)
Called whenever the TU status is updated.
Definition: TUScheduler.h:172
clang::clangd::TUScheduler::getFilesWithCachedAST
std::vector< Path > getFilesWithCachedAST() const
Returns a list of files with ASTs currently stored in memory.
Definition: TUScheduler.cpp:1639
clang::clangd::TUScheduler::Options::RetentionPolicy
ASTRetentionPolicy RetentionPolicy
Determines when to keep idle ASTs in memory for future use.
Definition: TUScheduler.h:203
clang::clangd::ParsingCallbacks::onPreambleAST
virtual void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext &Ctx, std::shared_ptr< clang::Preprocessor > PP, const CanonicalIncludes &)
Called on the AST that was built for emitting the preamble.
Definition: TUScheduler.h:136
clang::clangd::TUScheduler::TUScheduler
TUScheduler(const GlobalCompilationDatabase &CDB, const Options &Opts, std::unique_ptr< ParsingCallbacks > ASTCallbacks=nullptr)
Definition: TUScheduler.cpp:1449
clang::clangd::TUScheduler::update
bool update(PathRef File, ParseInputs Inputs, WantDiagnostics WD)
Schedule an update for File.
Definition: TUScheduler.cpp:1492
clang::clangd::ASTAction::Name
std::string Name
The name of the action currently running, e.g.
Definition: TUScheduler.h:109
clang::clangd::GlobalCompilationDatabase
Provides compilation arguments used for parsing C and C++ files.
Definition: GlobalCompilationDatabase.h:36
Action
llvm::unique_function< void()> Action
Definition: TUScheduler.cpp:596
clang::clangd::TUScheduler::FileStats::PreambleBuilds
unsigned PreambleBuilds
Definition: TUScheduler.h:218
clang::clangd::TUScheduler::FileStats::UsedBytesPreamble
std::size_t UsedBytesPreamble
Definition: TUScheduler.h:217
clang::clangd::TUScheduler::Options::ContextProvider
std::function< Context(PathRef)> ContextProvider
Used to create a context that wraps each single operation.
Definition: TUScheduler.h:208
clang::clangd::TUScheduler::Stale
@ Stale
The preamble may be generated from an older version of the file.
Definition: TUScheduler.h:288
clang::clangd::TUScheduler::FileStats
Definition: TUScheduler.h:215
clang::clangd::Semaphore
Limits the number of threads that can acquire the lock at the same time.
Definition: Threading.h:42
clang::clangd::TUScheduler::StaleOrAbsent
@ StaleOrAbsent
Besides accepting stale preamble, this also allow preamble to be absent (not ready or failed to build...
Definition: TUScheduler.h:291
clang::clangd::Deadline
A point in time we can wait for.
Definition: Threading.h:59
clang::clangd::WantDiagnostics
WantDiagnostics
Determines whether diagnostics should be generated for a file snapshot.
Definition: TUScheduler.h:53
clang::clangd::TUStatus::ASTActivity
ASTAction ASTActivity
Definition: TUScheduler.h:124
Inputs
ParseInputs Inputs
Definition: TUScheduler.cpp:451
clang::clangd::TUStatus
Definition: TUScheduler.h:113
clang::clangd::ParsingCallbacks::onPreamblePublished
virtual void onPreamblePublished(PathRef File)
Preamble for the TU have changed.
Definition: TUScheduler.h:177
clang::clangd::ParseInputs
Information required to run clang, e.g. to parse AST or do code completion.
Definition: Compiler.h:47
CanonicalIncludes.h
ns1::ns2::D
@ D
Definition: CategoricalFeature.h:3
clang::clangd::InputsAndPreamble::Contents
llvm::StringRef Contents
Definition: TUScheduler.h:44
clang::clangd::ASTAction::Kind
Kind
Definition: TUScheduler.h:97
clang::clangd::ParsingCallbacks
Definition: TUScheduler.h:129
clang::clangd::InputsAndPreamble::Command
const tooling::CompileCommand & Command
Definition: TUScheduler.h:45
clang::clangd::PreambleData
The parsed preamble and associated data.
Definition: Preamble.h:49
clang::clangd::MemoryTree
A tree that can be used to represent memory usage of nested components while preserving the hierarchy...
Definition: MemoryTree.h:32
GlobalCompilationDatabase.h
clang::clangd::CanonicalIncludes
Maps a definition location onto an #include file, based on a set of filename rules.
Definition: CanonicalIncludes.h:36
clang::clangd::PreambleAction::Idle
@ Idle
clang::clangd::TUScheduler::Options::AsyncThreadsCount
unsigned AsyncThreadsCount
Number of concurrent actions.
Definition: TUScheduler.h:193
Threading.h
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:27
Diagnostics.h
clang::clangd::TUScheduler::remove
void remove(PathRef File)
Remove File from the list of tracked files and schedule removal of its resources.
Definition: TUScheduler.cpp:1518
clang::clangd::InputsAndPreamble::Signals
const ASTSignals * Signals
Definition: TUScheduler.h:49
clang::clangd::ASTAction::Idle
@ Idle
Definition: TUScheduler.h:101
clang::clangd::TUScheduler::FileStats::UsedBytesAST
std::size_t UsedBytesAST
Definition: TUScheduler.h:216
clang::clangd::TUScheduler::fileStats
llvm::StringMap< FileStats > fileStats() const
Returns resources used for each of the currently open files.
Definition: TUScheduler.cpp:1631
clang::clangd::TUStatus::render
FileStatus render(PathRef File) const
Serialize this to an LSP file status item.
Definition: TUScheduler.cpp:1436
clang::clangd::DebouncePolicy::Min
clock::duration Min
The minimum time that we always debounce for.
Definition: TUScheduler.h:78
clang::clangd::ASTAction::RunningAction
@ RunningAction
Definition: TUScheduler.h:99
clang::tidy::bugprone::PP
static Preprocessor * PP
Definition: BadSignalToKillThreadCheck.cpp:29
ASTSignals.h
clang::clangd::ASTAction::ASTAction
ASTAction()=default
Compiler.h
clang::clangd::TUScheduler::runQuick
void runQuick(llvm::StringRef Name, llvm::StringRef Path, llvm::unique_function< void()> Action)
Similar to run, except the task is expected to be quick.
Definition: TUScheduler.cpp:1534
clang::clangd::ASTSignals
Signals derived from a valid AST of a file.
Definition: ASTSignals.h:26
clang::clangd::TUScheduler::Options::UpdateDebounce
DebouncePolicy UpdateDebounce
Time to wait after an update to see if another one comes along.
Definition: TUScheduler.h:200
clang::clangd::TUStatus::Details
BuildDetails Details
Stores status of the last build for the translation unit.
Definition: TUScheduler.h:126
clang::clangd::TUScheduler::profile
void profile(MemoryTree &MT) const
Definition: TUScheduler.cpp:1677
clang::clangd::PathRef
llvm::StringRef PathRef
A typedef to represent a ref to file path.
Definition: Path.h:29
clang::clangd::TUScheduler::ASTActionInvalidation
ASTActionInvalidation
Defines how a runWithAST action is implicitly cancelled by other actions.
Definition: TUScheduler.h:257
clang::clangd::InputsAndPreamble
Definition: TUScheduler.h:43
clang::clangd::TUScheduler::Options
Definition: TUScheduler.h:188
clang::clangd::InputsAndAST::AST
ParsedAST & AST
Definition: TUScheduler.h:40
clang::clangd::TUScheduler::runWithAST
void runWithAST(llvm::StringRef Name, PathRef File, Callback< InputsAndAST > Action, ASTActionInvalidation=NoInvalidation)
Schedule an async read of the AST.
Definition: TUScheduler.cpp:1562
clang::clangd::DebouncePolicy
Clangd may wait after an update to see if another one comes along.
Definition: TUScheduler.h:74
MemoryTree.h
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::clangd::ASTAction::Queued
@ Queued
Definition: TUScheduler.h:98
Function.h
clang::clangd::TUScheduler::NoInvalidation
@ NoInvalidation
The request will run unless explicitly cancelled.
Definition: TUScheduler.h:259
clang::clangd::TUStatus::PreambleActivity
PreambleAction PreambleActivity
Definition: TUScheduler.h:123
clang::clangd::FileStatus
Clangd extension: indicates the current state of the file in clangd, sent from server via the textDoc...
Definition: Protocol.h:1566
Diags
CapturedDiags Diags
Definition: ConfigCompileTests.cpp:38
clang::clangd::InputsAndAST::Inputs
const ParseInputs & Inputs
Definition: TUScheduler.h:39
clang::clangd::DebouncePolicy::RebuildRatio
float RebuildRatio
Target debounce, as a fraction of file rebuild time.
Definition: TUScheduler.h:83
clang::clangd::DebouncePolicy::Max
clock::duration Max
The maximum time we may debounce for.
Definition: TUScheduler.h:80
clang::clangd::TUScheduler::PreambleConsistency
PreambleConsistency
Controls whether preamble reads wait for the preamble to be up-to-date.
Definition: TUScheduler.h:280
clang::clangd::ASTAction::Building
@ Building
Definition: TUScheduler.h:100
clang::clangd::TUScheduler
Handles running tasks for ClangdServer and managing the resources (e.g., preambles and ASTs) for open...
Definition: TUScheduler.h:186
clang::clangd::Callback
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
Definition: Function.h:28
clang::clangd::DebouncePolicy::fixed
static DebouncePolicy fixed(clock::duration)
A policy that always returns the same duration, useful for tests.
Definition: TUScheduler.cpp:1671
clang::clangd::ParsedAST
Stores and provides access to parsed AST.
Definition: ParsedAST.h:49
clang::clangd::PreambleAction::Building
@ Building
clang::clangd::WantDiagnostics::No
@ No
Diagnostics must be generated for this snapshot.
clang::clangd::TUStatus::BuildDetails::ReuseAST
bool ReuseAST
Indicates whether we reused the prebuilt AST.
Definition: TUScheduler.h:118
clang::clangd::ASTAction::K
Kind K
Definition: TUScheduler.h:106
clang::clangd::TUStatus::BuildDetails::BuildFailed
bool BuildFailed
Indicates whether clang failed to build the TU.
Definition: TUScheduler.h:116
clang::clangd::ASTAction::ASTAction
ASTAction(Kind K, llvm::StringRef Name)
Definition: TUScheduler.h:105
clang::clangd::TUScheduler::Options::StorePreamblesInMemory
bool StorePreamblesInMemory
Cache (large) preamble data in RAM rather than temporary files on disk.
Definition: TUScheduler.h:196
clang::clangd::ASTRetentionPolicy::MaxRetainedASTs
unsigned MaxRetainedASTs
Maximum number of ASTs to be retained in memory when there are no pending requests for them.
Definition: TUScheduler.h:66
clang::clangd::DebouncePolicy::compute
clock::duration compute(llvm::ArrayRef< clock::duration > History) const
Compute the time to debounce based on this policy and recent build times.
Definition: TUScheduler.cpp:1650
clang::clangd::Context
A context is an immutable container for per-request data that must be propagated through layers that ...
Definition: Context.h:69
clang::clangd::TUScheduler::getFileBeingProcessedInContext
static llvm::Optional< llvm::StringRef > getFileBeingProcessedInContext()
Definition: TUScheduler.cpp:103
clang::clangd::TUScheduler::InvalidateOnUpdate
@ InvalidateOnUpdate
The request will be implicitly cancelled by a subsequent update().
Definition: TUScheduler.h:264