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