clang-tools 24.0.0git
ClangdMain.cpp
Go to the documentation of this file.
1//===--- ClangdMain.cpp - clangd server loop ------------------------------===//
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 "ClangdMain.h"
10#include "ClangdLSPServer.h"
11#include "CodeComplete.h"
12#include "Compiler.h"
13#include "Config.h"
14#include "ConfigProvider.h"
15#include "Feature.h"
16#include "FeatureModule.h"
17#include "IncludeCleaner.h"
18#include "PathMapping.h"
19#include "Protocol.h"
20#include "TidyProvider.h"
21#include "Transport.h"
22#include "index/Background.h"
23#include "index/Index.h"
24#include "index/MemIndex.h"
25#include "index/Merge.h"
26#include "index/ProjectAware.h"
27#include "index/remote/Client.h"
28#include "support/Path.h"
29#include "support/Shutdown.h"
32#include "support/Trace.h"
33#include "clang/Basic/Stack.h"
34#include "clang/Format/Format.h"
35#include "llvm/ADT/SmallString.h"
36#include "llvm/ADT/StringRef.h"
37#include "llvm/Support/CommandLine.h"
38#include "llvm/Support/FileSystem.h"
39#include "llvm/Support/InitLLVM.h"
40#include "llvm/Support/Path.h"
41#include "llvm/Support/Process.h"
42#include "llvm/Support/Program.h"
43#include "llvm/Support/Signals.h"
44#include "llvm/Support/TargetSelect.h"
45#include "llvm/Support/raw_ostream.h"
46#include <chrono>
47#include <cstdlib>
48#include <memory>
49#include <mutex>
50#include <optional>
51#include <string>
52#include <thread>
53#include <utility>
54#include <vector>
55
56#ifndef _WIN32
57#include <unistd.h>
58#endif
59
60#ifdef __GLIBC__
61#include <malloc.h>
62#endif
63
64namespace clang {
65namespace clangd {
66
67// Implemented in Check.cpp.
68bool check(const llvm::StringRef File, const ThreadsafeFS &TFS,
70
71namespace {
72
73using llvm::cl::cat;
74using llvm::cl::CommaSeparated;
75using llvm::cl::desc;
76using llvm::cl::Hidden;
77using llvm::cl::init;
78using llvm::cl::list;
79using llvm::cl::opt;
80using llvm::cl::OptionCategory;
81using llvm::cl::ValueOptional;
82using llvm::cl::values;
83
84// All flags must be placed in a category, or they will be shown neither in
85// --help, nor --help-hidden!
86OptionCategory CompileCommands("clangd compilation flags options");
87OptionCategory Features("clangd feature options");
88OptionCategory Misc("clangd miscellaneous options");
89OptionCategory Protocol("clangd protocol and logging options");
90OptionCategory Retired("clangd flags no longer in use");
91const OptionCategory *ClangdCategories[] = {&Features, &Protocol,
92 &CompileCommands, &Misc, &Retired};
93
94std::vector<const llvm::cl::Option *> RetiredOptions;
95
96template <typename T> class RetiredFlag {
97 opt<T> Option;
98
99public:
100 RetiredFlag(llvm::StringRef Name)
101 : Option(Name, cat(Retired), desc("Obsolete flag, ignored"), Hidden) {
102 RetiredOptions.push_back(&Option);
103 }
104};
105
106enum CompileArgsFrom { LSPCompileArgs, FilesystemCompileArgs };
107opt<CompileArgsFrom> CompileArgsFrom{
108 "compile_args_from",
109 cat(CompileCommands),
110 desc("The source of compile commands"),
111 values(clEnumValN(LSPCompileArgs, "lsp",
112 "All compile commands come from LSP and "
113 "'compile_commands.json' files are ignored"),
114 clEnumValN(FilesystemCompileArgs, "filesystem",
115 "All compile commands come from the "
116 "'compile_commands.json' files")),
117 init(FilesystemCompileArgs),
118 Hidden,
119};
120
121opt<Path> CompileCommandsDir{
122 "compile-commands-dir",
123 cat(CompileCommands),
124 desc("Specify a path to look for compile_commands.json. If path "
125 "is invalid, clangd will look in the current directory and "
126 "parent paths of each source file"),
127};
128
129opt<Path> ResourceDir{
130 "resource-dir",
131 cat(CompileCommands),
132 desc("Directory for system clang headers"),
133 init(""),
134 Hidden,
135};
136
137list<std::string> QueryDriverGlobs{
138 "query-driver",
139 cat(CompileCommands),
140 desc(
141 "Comma separated list of globs for white-listing gcc-compatible "
142 "drivers that are safe to execute. Drivers matching any of these globs "
143 "will be used to extract system includes. e.g. "
144 "/usr/bin/**/clang-*,/path/to/repo/**/g++-*"),
145 CommaSeparated,
146};
147
148// FIXME: Flags are the wrong mechanism for user preferences.
149// We should probably read a dotfile or similar.
150opt<bool> AllScopesCompletion{
151 "all-scopes-completion",
152 cat(Features),
153 desc("If set to true, code completion will include index symbols that are "
154 "not defined in the scopes (e.g. "
155 "namespaces) visible from the code completion point. Such completions "
156 "can insert scope qualifiers"),
157 init(true),
158};
159
160opt<bool> ShowOrigins{
161 "debug-origin",
162 cat(Features),
163 desc("Show origins of completion items"),
164 init(CodeCompleteOptions().ShowOrigins),
165 Hidden,
166};
167
168opt<bool> EnableBackgroundIndex{
169 "background-index",
170 cat(Features),
171 desc("Index project code in the background and persist index on disk."),
172 init(true),
173};
174
175opt<llvm::ThreadPriority> BackgroundIndexPriority{
176 "background-index-priority",
177 cat(Features),
178 desc("Thread priority for building the background index. "
179 "The effect of this flag is OS-specific."),
180 values(clEnumValN(llvm::ThreadPriority::Background, "background",
181 "Minimum priority, runs on idle CPUs. "
182 "May leave 'performance' cores unused."),
183 clEnumValN(llvm::ThreadPriority::Low, "low",
184 "Reduced priority compared to interactive work."),
185 clEnumValN(llvm::ThreadPriority::Default, "normal",
186 "Same priority as other clangd work.")),
187 init(llvm::ThreadPriority::Low),
188};
189
190opt<bool> EnableClangTidy{
191 "clang-tidy",
192 cat(Features),
193 desc("Enable clang-tidy diagnostics"),
194 init(true),
195};
196
197opt<CodeCompleteOptions::CodeCompletionParse> CodeCompletionParse{
198 "completion-parse",
199 cat(Features),
200 desc("Whether the clang-parser is used for code-completion"),
201 values(clEnumValN(CodeCompleteOptions::AlwaysParse, "always",
202 "Block until the parser can be used"),
203 clEnumValN(CodeCompleteOptions::ParseIfReady, "auto",
204 "Use text-based completion if the parser "
205 "is not ready"),
206 clEnumValN(CodeCompleteOptions::NeverParse, "never",
207 "Always used text-based completion")),
208 init(CodeCompleteOptions().RunParser),
209 Hidden,
210};
211
212opt<CodeCompleteOptions::CodeCompletionRankingModel> RankingModel{
213 "ranking-model",
214 cat(Features),
215 desc("Model to use to rank code-completion items"),
216 values(clEnumValN(CodeCompleteOptions::Heuristics, "heuristics",
217 "Use heuristics to rank code completion items"),
218 clEnumValN(CodeCompleteOptions::DecisionForest, "decision_forest",
219 "Use Decision Forest model to rank completion items")),
220 init(CodeCompleteOptions().RankingModel),
221 Hidden,
222};
223
224// FIXME: also support "plain" style where signatures are always omitted.
225enum CompletionStyleFlag { Detailed, Bundled };
226opt<CompletionStyleFlag> CompletionStyle{
227 "completion-style",
228 cat(Features),
229 desc("Granularity of code completion suggestions"),
230 values(clEnumValN(Detailed, "detailed",
231 "One completion item for each semantically distinct "
232 "completion, with full type information"),
233 clEnumValN(Bundled, "bundled",
234 "Similar completion items (e.g. function overloads) are "
235 "combined. Type information shown where possible")),
236};
237
238opt<std::string> FallbackStyle{
239 "fallback-style",
240 cat(Features),
241 desc("clang-format style to apply by default when "
242 "no .clang-format file is found"),
243 init(clang::format::DefaultFallbackStyle),
244};
245
246opt<std::string> EnableFunctionArgSnippets{
247 "function-arg-placeholders",
248 cat(Features),
249 desc("When disabled (0), completions contain only parentheses for "
250 "function calls. When enabled (1), completions also contain "
251 "placeholders for method parameters"),
252 init("-1"),
253};
254
255opt<Config::HeaderInsertionPolicy> HeaderInsertion{
256 "header-insertion",
257 cat(Features),
258 desc("Add #include directives when accepting code completions"),
259 init(CodeCompleteOptions().InsertIncludes),
260 values(
261 clEnumValN(Config::HeaderInsertionPolicy::IWYU, "iwyu",
262 "Include what you use. "
263 "Insert the owning header for top-level symbols, unless the "
264 "header is already directly included or the symbol is "
265 "forward-declared"),
266 clEnumValN(
268 "Never insert #include directives as part of code completion")),
269};
270
271opt<bool> ImportInsertions{
272 "import-insertions",
273 cat(Features),
274 desc("If header insertion is enabled, add #import directives when "
275 "accepting code completions or fixing includes in Objective-C code"),
276 init(CodeCompleteOptions().ImportInsertions),
277};
278
279opt<bool> HeaderInsertionDecorators{
280 "header-insertion-decorators",
281 cat(Features),
282 desc("Prepend a circular dot or space before the completion "
283 "label, depending on whether "
284 "an include line will be inserted or not"),
285 init(true),
286};
287
288opt<bool> HiddenFeatures{
289 "hidden-features",
290 cat(Features),
291 desc("Enable hidden features mostly useful to clangd developers"),
292 init(false),
293 Hidden,
294};
295
296opt<bool> IncludeIneligibleResults{
297 "include-ineligible-results",
298 cat(Features),
299 desc("Include ineligible completion results (e.g. private members)"),
300 init(CodeCompleteOptions().IncludeIneligibleResults),
301 Hidden,
302};
303
304RetiredFlag<bool> EnableIndex("index");
305RetiredFlag<bool> SuggestMissingIncludes("suggest-missing-includes");
306RetiredFlag<bool> RecoveryAST("recovery-ast");
307RetiredFlag<bool> RecoveryASTType("recovery-ast-type");
308RetiredFlag<bool> AsyncPreamble("async-preamble");
309RetiredFlag<bool> CollectMainFileRefs("collect-main-file-refs");
310RetiredFlag<bool> CrossFileRename("cross-file-rename");
311RetiredFlag<std::string> ClangTidyChecks("clang-tidy-checks");
312RetiredFlag<bool> InlayHints("inlay-hints");
313RetiredFlag<bool> FoldingRanges("folding-ranges");
314RetiredFlag<bool> IncludeCleanerStdlib("include-cleaner-stdlib");
315
316opt<int> LimitResults{
317 "limit-results",
318 cat(Features),
319 desc("Limit the number of results returned by clangd. "
320 "0 means no limit (default=100)"),
321 init(100),
322};
323
324opt<int> ReferencesLimit{
325 "limit-references",
326 cat(Features),
327 desc("Limit the number of references returned by clangd. "
328 "0 means no limit (default=1000)"),
329 init(1000),
330};
331
332opt<int> RenameFileLimit{
333 "rename-file-limit",
334 cat(Features),
335 desc("Limit the number of files to be affected by symbol renaming. "
336 "0 means no limit (default=50)"),
337 init(50),
338};
339
340list<std::string> TweakList{
341 "tweaks",
342 cat(Features),
343 desc("Specify a list of Tweaks to enable (only for clangd developers)."),
344 Hidden,
345 CommaSeparated,
346};
347
348opt<unsigned> WorkerThreadsCount{
349 "j",
350 cat(Misc),
351 desc("Number of async workers used by clangd. Background index also "
352 "uses this many workers."),
354};
355
356opt<Path> IndexFile{
357 "index-file",
358 cat(Misc),
359 desc(
360 "Index file to build the static index. The file must have been created "
361 "by a compatible clangd-indexer\n"
362 "WARNING: This option is experimental only, and will be removed "
363 "eventually. Don't rely on it"),
364 init(""),
365 Hidden,
366};
367
368opt<bool> Test{
369 "lit-test",
370 cat(Misc),
371 desc("Abbreviation for -input-style=delimited -pretty -sync "
372 "-enable-test-scheme -enable-config=0 -log=verbose -crash-pragmas. "
373 "Also sets config options: Index.StandardLibrary=false. "
374 "Intended to simplify lit tests"),
375 init(false),
376 Hidden,
377};
378
379opt<bool> CrashPragmas{
380 "crash-pragmas",
381 cat(Misc),
382 desc("Respect `#pragma clang __debug crash` and friends."),
383 init(false),
384 Hidden,
385};
386
387opt<Path> CheckFile{
388 "check",
389 cat(Misc),
390 desc("Parse one file in isolation instead of acting as a language server. "
391 "Useful to investigate/reproduce crashes or configuration problems. "
392 "With --check=<filename>, attempts to parse a particular file."),
393 init(""),
394 ValueOptional,
395};
396
397enum PCHStorageFlag { Disk, Memory };
398opt<PCHStorageFlag> PCHStorage{
399 "pch-storage",
400 cat(Misc),
401 desc("Storing PCHs in memory increases memory usages, but may "
402 "improve performance"),
403 values(
404 clEnumValN(PCHStorageFlag::Disk, "disk", "store PCHs on disk"),
405 clEnumValN(PCHStorageFlag::Memory, "memory", "store PCHs in memory")),
406 init(PCHStorageFlag::Disk),
407};
408
409opt<bool> Sync{
410 "sync",
411 cat(Misc),
412 desc("Handle client requests on main thread. Background index still uses "
413 "its own thread."),
414 init(false),
415 Hidden,
416};
417
418opt<JSONStreamStyle> InputStyle{
419 "input-style",
420 cat(Protocol),
421 desc("Input JSON stream encoding"),
422 values(
423 clEnumValN(JSONStreamStyle::Standard, "standard", "usual LSP protocol"),
424 clEnumValN(JSONStreamStyle::Delimited, "delimited",
425 "messages delimited by --- lines, with # comment support")),
427 Hidden,
428};
429
430opt<bool> EnableTestScheme{
431 "enable-test-uri-scheme",
432 cat(Protocol),
433 desc("Enable 'test:' URI scheme. Only use in lit tests"),
434 init(false),
435 Hidden,
436};
437
438opt<std::string> PathMappingsArg{
439 "path-mappings",
440 cat(Protocol),
441 desc(
442 "Translates between client paths (as seen by a remote editor) and "
443 "server paths (where clangd sees files on disk). "
444 "Comma separated list of '<client_path>=<server_path>' pairs, the "
445 "first entry matching a given path is used. "
446 "e.g. /home/project/incl=/opt/include,/home/project=/workarea/project"),
447 init(""),
448};
449
450opt<Path> InputMirrorFile{
451 "input-mirror-file",
452 cat(Protocol),
453 desc("Mirror all LSP input to the specified file. Useful for debugging"),
454 init(""),
455 Hidden,
456};
457
458opt<Logger::Level> LogLevel{
459 "log",
460 cat(Protocol),
461 desc("Verbosity of log messages written to stderr"),
462 values(clEnumValN(Logger::Error, "error", "Error messages only"),
463 clEnumValN(Logger::Info, "info", "High level execution tracing"),
464 clEnumValN(Logger::Debug, "verbose", "Low level details")),
465 init(Logger::Info),
466};
467
468opt<OffsetEncoding> ForceOffsetEncoding{
469 "offset-encoding",
470 cat(Protocol),
471 desc("Force the offsetEncoding used for character positions. "
472 "This bypasses negotiation via client capabilities"),
473 values(
474 clEnumValN(OffsetEncoding::UTF8, "utf-8", "Offsets are in UTF-8 bytes"),
475 clEnumValN(OffsetEncoding::UTF16, "utf-16",
476 "Offsets are in UTF-16 code units"),
477 clEnumValN(OffsetEncoding::UTF32, "utf-32",
478 "Offsets are in unicode codepoints")),
480};
481
482opt<bool> PrettyPrint{
483 "pretty",
484 cat(Protocol),
485 desc("Pretty-print JSON output"),
486 init(false),
487};
488
489opt<bool> EnableConfig{
490 "enable-config",
491 cat(Misc),
493 init(true),
494};
495
496opt<bool> StrongWorkspaceMode{
497 "strong-workspace-mode",
498 cat(Features),
499 desc("An alternate mode of operation for clangd, where the clangd instance "
500 "is used to edit a single workspace.\n"
501 "When enabled, fallback commands use the workspace directory as their "
502 "working directory instead of the parent folder."),
503 init(false),
504 Hidden,
505};
506
507opt<bool> UseDirtyHeaders{"use-dirty-headers", cat(Misc),
508 desc("Use files open in the editor when parsing "
509 "headers instead of reading from the disk"),
510 Hidden,
511 init(ClangdServer::Options().UseDirtyHeaders)};
512
513opt<bool> PreambleParseForwardingFunctions{
514 "parse-forwarding-functions",
515 cat(Misc),
516 desc("Parse all emplace-like functions in included headers"),
517 Hidden,
518 init(ParseOptions().PreambleParseForwardingFunctions),
519};
520
521opt<bool> SkipPreambleBuild{
522 "skip-preamble-build",
523 cat(Misc),
524 desc("If ture, skip preamble build"),
525 Hidden,
526 init(ParseOptions().SkipPreambleBuild),
527};
528
529#if defined(__GLIBC__) && CLANGD_MALLOC_TRIM
530opt<bool> EnableMallocTrim{
531 "malloc-trim",
532 cat(Misc),
533 desc("Release memory periodically via malloc_trim(3)."),
534 init(true),
535};
536
537std::function<void()> getMemoryCleanupFunction() {
538 if (!EnableMallocTrim)
539 return nullptr;
540 // Leave a few MB at the top of the heap: it is insignificant
541 // and will most likely be needed by the main thread
542 constexpr size_t MallocTrimPad = 20'000'000;
543 return []() {
544 if (malloc_trim(MallocTrimPad))
545 vlog("Released memory via malloc_trim");
546 };
547}
548#else
549std::function<void()> getMemoryCleanupFunction() { return nullptr; }
550#endif
551
552#if CLANGD_ENABLE_REMOTE
553opt<std::string> RemoteIndexAddress{
554 "remote-index-address",
555 cat(Features),
556 desc("Address of the remote index server"),
557};
558
559// FIXME(kirillbobyrev): Should this be the location of compile_commands.json?
560opt<std::string> ProjectRoot{
561 "project-root",
562 cat(Features),
563 desc("Path to the project root. Requires remote-index-address to be set."),
564};
565#endif
566
567opt<bool> ExperimentalModulesSupport{
568 "experimental-modules-support",
569 cat(Features),
570 desc("Experimental support for standard c++ modules"),
571 init(false),
572};
573
574/// Supports a test URI scheme with relaxed constraints for lit tests.
575/// The path in a test URI will be combined with a platform-specific fake
576/// directory to form an absolute path. For example, test:///a.cpp is resolved
577/// C:\clangd-test\a.cpp on Windows and /clangd-test/a.cpp on Unix.
578class TestScheme : public URIScheme {
579public:
580 llvm::Expected<std::string>
581 getAbsolutePath(llvm::StringRef /*Authority*/, llvm::StringRef Body,
582 llvm::StringRef /*HintPath*/) const override {
583 using namespace llvm::sys;
584 // Still require "/" in body to mimic file scheme, as we want lengths of an
585 // equivalent URI in both schemes to be the same.
586 if (!Body.starts_with("/"))
587 return error(
588 "Expect URI body to be an absolute path starting with '/': {0}",
589 Body);
590 Body = Body.ltrim('/');
591 llvm::SmallString<16> Path(Body);
592 path::native(Path);
593 path::make_absolute(testDir(), Path);
594 return std::string(Path);
595 }
596
597 llvm::Expected<URI>
598 uriFromAbsolutePath(llvm::StringRef AbsolutePath) const override {
599 llvm::StringRef Body = AbsolutePath;
600 if (!Body.consume_front(testDir()))
601 return error("Path {0} doesn't start with root {1}", AbsolutePath,
602 testDir());
603
604 return URI("test", /*Authority=*/"",
605 llvm::sys::path::convert_to_slash(Body));
606 }
607
608private:
609 static llvm::StringRef testDir() {
610#ifdef _WIN32
611 static const std::string TestDir = llvm::sys::path::native("C:/clangd-test");
612 return TestDir;
613#else
614 return "/clangd-test";
615#endif
616 }
617};
618
619std::unique_ptr<SymbolIndex>
620loadExternalIndex(const Config::ExternalIndexSpec &External,
621 AsyncTaskRunner *Tasks, bool SupportContainedRefs) {
622 static const trace::Metric RemoteIndexUsed("used_remote_index",
623 trace::Metric::Value, "address");
624 switch (External.Kind) {
626 break;
628 RemoteIndexUsed.record(1, External.Location);
629 log("Associating {0} with remote index at {1}.", External.MountPoint,
630 External.Location);
631 return remote::getClient(External.Location, External.MountPoint);
633 log("Associating {0} with monolithic index at {1}.", External.MountPoint,
634 External.Location);
635 auto NewIndex = std::make_unique<SwapIndex>(std::make_unique<MemIndex>());
636 auto IndexLoadTask = [File = External.Location,
637 PlaceHolder = NewIndex.get(), SupportContainedRefs] {
638 if (auto Idx = loadIndex(File, SymbolOrigin::Static, /*UseDex=*/true,
639 SupportContainedRefs))
640 PlaceHolder->reset(std::move(Idx));
641 };
642 if (Tasks) {
643 Tasks->runAsync("Load-index:" + External.Location,
644 std::move(IndexLoadTask));
645 } else {
646 IndexLoadTask();
647 }
648 return std::move(NewIndex);
649 }
650 llvm_unreachable("Invalid ExternalIndexKind.");
651}
652
653std::optional<bool> shouldEnableFunctionArgSnippets() {
654 std::string Val = EnableFunctionArgSnippets;
655 // Accept the same values that a bool option parser would, but also accept
656 // -1 to indicate "unspecified", in which case the ArgumentListsPolicy
657 // config option will be respected.
658 if (Val == "1" || Val == "true" || Val == "True" || Val == "TRUE")
659 return true;
660 if (Val == "0" || Val == "false" || Val == "False" || Val == "FALSE")
661 return false;
662 if (Val != "-1")
663 elog("Value specified by --function-arg-placeholders is invalid. Provide a "
664 "boolean value or leave unspecified to use ArgumentListsPolicy from "
665 "config instead.");
666 return std::nullopt;
667}
668
669class FlagsConfigProvider : public config::Provider {
670private:
672
673 std::vector<config::CompiledFragment>
674 getFragments(const config::Params &,
675 config::DiagnosticCallback) const override {
676 return {Frag};
677 }
678
679public:
680 FlagsConfigProvider() {
681 std::optional<Config::CDBSearchSpec> CDBSearch;
682 std::optional<Config::ExternalIndexSpec> IndexSpec;
683 std::optional<Config::BackgroundPolicy> BGPolicy;
684 std::optional<Config::ArgumentListsPolicy> ArgumentLists;
685
686 // If --compile-commands-dir arg was invoked, check value and override
687 // default path.
688 if (!CompileCommandsDir.empty()) {
689 if (llvm::sys::fs::exists(CompileCommandsDir)) {
690 // We support passing both relative and absolute paths to the
691 // --compile-commands-dir argument, but we assume the path is absolute
692 // in the rest of clangd so we make sure the path is absolute before
693 // continuing.
694 llvm::SmallString<128> Path(CompileCommandsDir);
695 if (std::error_code EC = llvm::sys::fs::make_absolute(Path)) {
696 elog("Error while converting the relative path specified by "
697 "--compile-commands-dir to an absolute path: {0}. The argument "
698 "will be ignored.",
699 EC.message());
700 } else {
701 CDBSearch = {Config::CDBSearchSpec::FixedDir, Path.str().str()};
702 }
703 } else {
704 elog("Path specified by --compile-commands-dir does not exist. The "
705 "argument will be ignored.");
706 }
707 }
708 if (!IndexFile.empty()) {
709 Config::ExternalIndexSpec Spec;
710 Spec.Kind = Spec.File;
711 Spec.Location = IndexFile;
712 IndexSpec = std::move(Spec);
713 }
714#if CLANGD_ENABLE_REMOTE
715 if (!RemoteIndexAddress.empty()) {
716 assert(!ProjectRoot.empty() && IndexFile.empty());
717 Config::ExternalIndexSpec Spec;
718 Spec.Kind = Spec.Server;
719 Spec.Location = RemoteIndexAddress;
720 Spec.MountPoint = ProjectRoot;
721 IndexSpec = std::move(Spec);
723 }
724#endif
725 if (!EnableBackgroundIndex) {
727 }
728
729 if (std::optional<bool> Enable = shouldEnableFunctionArgSnippets()) {
730 ArgumentLists = *Enable ? Config::ArgumentListsPolicy::FullPlaceholders
732 }
733
734 Frag = [=](const config::Params &, Config &C) {
735 if (CDBSearch)
736 C.CompileFlags.CDBSearch = *CDBSearch;
737 if (IndexSpec)
738 C.Index.External = *IndexSpec;
739 if (BGPolicy)
740 C.Index.Background = *BGPolicy;
741 if (ArgumentLists)
742 C.Completion.ArgumentLists = *ArgumentLists;
743 if (HeaderInsertion.getNumOccurrences())
744 C.Completion.HeaderInsertion = HeaderInsertion;
745 if (AllScopesCompletion.getNumOccurrences())
746 C.Completion.AllScopes = AllScopesCompletion;
747
748 if (Test)
749 C.Index.StandardLibrary = false;
750 return true;
751 };
752 }
753};
754} // namespace
755
761
762int clangdMain(int argc, char *argv[]) {
763 // Clang could run on the main thread. e.g., when the flag '-check' or '-sync'
764 // is enabled.
765 clang::noteBottomOfStack();
766 llvm::InitLLVM X(argc, argv);
767 llvm::InitializeAllTargetInfos();
768 llvm::sys::AddSignalHandler(
769 [](void *) {
771 // Ensure ThreadCrashReporter and PrintStackTrace output is visible.
772 llvm::errs().flush();
773 },
774 nullptr);
775 llvm::sys::SetInterruptFunction(&requestShutdown);
776 llvm::cl::SetVersionPrinter([](llvm::raw_ostream &OS) {
777 OS << versionString() << "\n"
778 << "Features: " << featureString() << "\n"
779 << "Platform: " << platformString() << "\n";
780 });
781 const char *FlagsEnvVar = "CLANGD_FLAGS";
782 const char *Overview =
783 R"(clangd is a language server that provides IDE-like features to editors.
784
785It should be used via an editor plugin rather than invoked directly. For more information, see:
786 https://clangd.llvm.org/
787 https://microsoft.github.io/language-server-protocol/
788
789clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment variable.
790)";
791 llvm::cl::HideUnrelatedOptions(ClangdCategories);
792 llvm::cl::ParseCommandLineOptions(argc, argv, Overview, /*Errs=*/nullptr,
793 /*VFS=*/nullptr, FlagsEnvVar);
794 for (const llvm::cl::Option *O : RetiredOptions)
795 if (O->getNumOccurrences())
796 llvm::errs() << "The flag `-" << O->ArgStr
797 << "` is obsolete and ignored.\n";
798 if (Test) {
799 if (!Sync.getNumOccurrences())
800 Sync = true;
801 if (!CrashPragmas.getNumOccurrences())
802 CrashPragmas = true;
803 InputStyle = JSONStreamStyle::Delimited;
804 LogLevel = Logger::Verbose;
805 PrettyPrint = true;
806 // Disable config system by default to avoid external reads.
807 if (!EnableConfig.getNumOccurrences())
808 EnableConfig = false;
809 // Disable background index on lit tests by default to prevent disk writes.
810 if (!EnableBackgroundIndex.getNumOccurrences())
811 EnableBackgroundIndex = false;
812 // Ensure background index makes progress.
813 else if (EnableBackgroundIndex)
815 }
816 if (Test || EnableTestScheme) {
817 static URISchemeRegistry::Add<TestScheme> X(
818 "test", "Test scheme for clangd lit tests.");
819 }
820 if (CrashPragmas)
822
823 if (!Sync && WorkerThreadsCount == 0) {
824 llvm::errs() << "A number of worker threads cannot be 0. Did you mean to "
825 "specify -sync?";
826 return 1;
827 }
828
829 if (Sync) {
830 if (WorkerThreadsCount.getNumOccurrences())
831 llvm::errs() << "Ignoring -j because -sync is set.\n";
832 WorkerThreadsCount = 0;
833 }
834 if (FallbackStyle.getNumOccurrences())
835 clang::format::DefaultFallbackStyle = FallbackStyle.c_str();
836
837 // Validate command line arguments.
838 std::optional<llvm::raw_fd_ostream> InputMirrorStream;
839 if (!InputMirrorFile.empty()) {
840 std::error_code EC;
841 InputMirrorStream.emplace(InputMirrorFile, /*ref*/ EC,
842 llvm::sys::fs::FA_Read | llvm::sys::fs::FA_Write);
843 if (EC) {
844 InputMirrorStream.reset();
845 llvm::errs() << "Error while opening an input mirror file: "
846 << EC.message();
847 } else {
848 InputMirrorStream->SetUnbuffered();
849 }
850 }
851
852#if !CLANGD_DECISION_FOREST
853 if (RankingModel == clangd::CodeCompleteOptions::DecisionForest) {
854 llvm::errs() << "Clangd was compiled without decision forest support.\n";
855 return 1;
856 }
857#endif
858
859 // Setup tracing facilities if CLANGD_TRACE is set. In practice enabling a
860 // trace flag in your editor's config is annoying, launching with
861 // `CLANGD_TRACE=trace.json vim` is easier.
862 std::optional<llvm::raw_fd_ostream> TracerStream;
863 std::unique_ptr<trace::EventTracer> Tracer;
864 const char *JSONTraceFile = getenv("CLANGD_TRACE");
865 const char *MetricsCSVFile = getenv("CLANGD_METRICS");
866 const char *TracerFile = JSONTraceFile ? JSONTraceFile : MetricsCSVFile;
867 if (TracerFile) {
868 std::error_code EC;
869 TracerStream.emplace(TracerFile, /*ref*/ EC,
870 llvm::sys::fs::FA_Read | llvm::sys::fs::FA_Write);
871 if (EC) {
872 TracerStream.reset();
873 llvm::errs() << "Error while opening trace file " << TracerFile << ": "
874 << EC.message();
875 } else {
876 Tracer = (TracerFile == JSONTraceFile)
877 ? trace::createJSONTracer(*TracerStream, PrettyPrint)
878 : trace::createCSVMetricTracer(*TracerStream);
879 }
880 }
881
882 std::optional<trace::Session> TracingSession;
883 if (Tracer)
884 TracingSession.emplace(*Tracer);
885
886 // If a user ran `clangd` in a terminal without redirecting anything,
887 // it's somewhat likely they're confused about how to use clangd.
888 // Show them the help overview, which explains.
889 if (llvm::outs().is_displayed() && llvm::errs().is_displayed() &&
890 !CheckFile.getNumOccurrences())
891 llvm::errs() << Overview << "\n";
892 // Use buffered stream to stderr (we still flush each log message). Unbuffered
893 // stream can cause significant (non-deterministic) latency for the logger.
894 llvm::errs().SetBuffered();
895 StreamLogger Logger(llvm::errs(), LogLevel);
897 // Write some initial logs before we start doing any real work.
898 log("{0}", versionString());
899 log("Features: {0}", featureString());
900 log("PID: {0}", llvm::sys::Process::getProcessId());
901 {
902 SmallString<128> CWD;
903 if (auto Err = llvm::sys::fs::current_path(CWD))
904 log("Working directory unknown: {0}", Err.message());
905 else
906 log("Working directory: {0}", CWD);
907 }
908 for (int I = 0; I < argc; ++I)
909 log("argv[{0}]: {1}", I, argv[I]);
910 if (auto EnvFlags = llvm::sys::Process::GetEnv(FlagsEnvVar))
911 log("{0}: {1}", FlagsEnvVar, *EnvFlags);
912 // Log environment variables that influence how clangd finds system headers.
913 // This helps diagnose missing-include issues, especially on Windows.
914 for (const char *EnvVar : {
915 // MSVC environment variables (set by vcvarsall.bat)
916 "INCLUDE",
917 "LIB",
918 "LIBPATH",
919 "CL",
920 "_CL_",
921 // GCC/Clang environment variables
922 "CPATH",
923 "C_INCLUDE_PATH",
924 "CPLUS_INCLUDE_PATH",
925 "OBJC_INCLUDE_PATH",
926 "LIBRARY_PATH",
927 "GCC_EXEC_PREFIX",
928 }) {
929 if (auto Val = llvm::sys::Process::GetEnv(EnvVar))
930 log("Env {0}: {1}", EnvVar, *Val);
931 }
932
935 Opts.UseDirBasedCDB = (CompileArgsFrom == FilesystemCompileArgs);
936 Opts.EnableExperimentalModulesSupport = ExperimentalModulesSupport;
937
938 switch (PCHStorage) {
939 case PCHStorageFlag::Memory:
940 Opts.StorePreamblesInMemory = true;
941 break;
942 case PCHStorageFlag::Disk:
943 Opts.StorePreamblesInMemory = false;
944 break;
945 }
946 if (!ResourceDir.empty())
947 Opts.ResourceDir = ResourceDir;
948 Opts.StrongWorkspaceMode = StrongWorkspaceMode;
949 Opts.BuildDynamicSymbolIndex = true;
950#if CLANGD_ENABLE_REMOTE
951 if (RemoteIndexAddress.empty() != ProjectRoot.empty()) {
952 llvm::errs() << "remote-index-address and project-path have to be "
953 "specified at the same time.";
954 return 1;
955 }
956 if (!RemoteIndexAddress.empty()) {
957 if (IndexFile.empty()) {
958 log("Connecting to remote index at {0}", RemoteIndexAddress);
959 } else {
960 elog("When enabling remote index, IndexFile should not be specified. "
961 "Only one can be used at time. Remote index will ignored.");
962 }
963 }
964#endif
965 Opts.BackgroundIndex = EnableBackgroundIndex;
966 Opts.BackgroundIndexPriority = BackgroundIndexPriority;
967 Opts.ReferencesLimit = ReferencesLimit;
968 Opts.Rename.LimitFiles = RenameFileLimit;
969 auto PAI = createProjectAwareIndex(
970 [SupportContainedRefs = Opts.EnableOutgoingCalls](
971 const Config::ExternalIndexSpec &External, AsyncTaskRunner *Tasks) {
972 return loadExternalIndex(External, Tasks, SupportContainedRefs);
973 },
974 Sync);
975 Opts.StaticIndex = PAI.get();
976 Opts.AsyncThreadsCount = WorkerThreadsCount;
977 Opts.MemoryCleanup = getMemoryCleanupFunction();
978
979 Opts.CodeComplete.IncludeIneligibleResults = IncludeIneligibleResults;
980 Opts.CodeComplete.Limit = LimitResults;
981 if (CompletionStyle.getNumOccurrences())
982 Opts.CodeComplete.BundleOverloads = CompletionStyle != Detailed;
983 Opts.CodeComplete.ShowOrigins = ShowOrigins;
984 Opts.CodeComplete.InsertIncludes = HeaderInsertion;
985 Opts.CodeComplete.ImportInsertions = ImportInsertions;
986 if (!HeaderInsertionDecorators) {
987 Opts.CodeComplete.IncludeIndicator.Insert.clear();
988 Opts.CodeComplete.IncludeIndicator.NoInsert.clear();
989 }
990 Opts.CodeComplete.RunParser = CodeCompletionParse;
991 Opts.CodeComplete.RankingModel = RankingModel;
992 // FIXME: If we're using C++20 modules, force the lookup process to load
993 // external decls, since currently the index doesn't support C++20 modules.
994 Opts.CodeComplete.ForceLoadPreamble = ExperimentalModulesSupport;
995
996 std::vector<std::unique_ptr<config::Provider>> ProviderStack;
997 if (EnableConfig)
998 ProviderStack = config::Provider::createDefaultProviders(TFS);
999 ProviderStack.push_back(std::make_unique<FlagsConfigProvider>());
1000 Opts.ConfigProvider = config::Provider::combine(std::move(ProviderStack));
1001
1002 // Create an empty clang-tidy option.
1003 TidyProvider ClangTidyOptProvider;
1004 if (EnableClangTidy) {
1005 std::vector<TidyProvider> Providers;
1006 Providers.reserve(4 + EnableConfig);
1007 Providers.push_back(provideEnvironment());
1008 Providers.push_back(provideClangTidyFiles(TFS));
1009 if (EnableConfig)
1010 Providers.push_back(provideClangdConfig());
1011 Providers.push_back(provideDefaultChecks());
1012 Providers.push_back(disableUnusableChecks());
1013 ClangTidyOptProvider = combine(std::move(Providers));
1014 Opts.ClangTidyProvider = ClangTidyOptProvider;
1015 }
1016 Opts.UseDirtyHeaders = UseDirtyHeaders;
1017 Opts.PreambleParseForwardingFunctions = PreambleParseForwardingFunctions;
1018 Opts.SkipPreambleBuild = SkipPreambleBuild;
1019 Opts.ImportInsertions = ImportInsertions;
1020 Opts.QueryDriverGlobs = std::move(QueryDriverGlobs);
1021 Opts.TweakFilter = [&](const Tweak &T) {
1022 if (T.hidden() && !HiddenFeatures)
1023 return false;
1024 if (TweakList.getNumOccurrences())
1025 return llvm::is_contained(TweakList, T.id());
1026 return true;
1027 };
1028 if (ForceOffsetEncoding != OffsetEncoding::UnsupportedEncoding)
1029 Opts.Encoding = ForceOffsetEncoding;
1030
1031 if (CheckFile.getNumOccurrences()) {
1032 llvm::SmallString<256> Path;
1033 if (auto Error =
1034 llvm::sys::fs::real_path(CheckFile, Path, /*expand_tilde=*/true)) {
1035 elog("Failed to resolve path {0}: {1}", CheckFile, Error.message());
1036 return 1;
1037 }
1038 log("Entering check mode (no LSP server)");
1039 return check(Path, TFS, std::move(Opts))
1040 ? 0
1041 : static_cast<int>(ErrorResultCode::CheckFailed);
1042 }
1043
1045 if (ModuleSet.begin() != ModuleSet.end())
1046 Opts.FeatureModules = &ModuleSet;
1047
1048 // Initialize and run ClangdLSPServer.
1049 // Change stdin to binary to not lose \r\n on windows.
1050 llvm::sys::ChangeStdinToBinary();
1051 std::unique_ptr<Transport> TransportLayer;
1052 if (getenv("CLANGD_AS_XPC_SERVICE")) {
1053#if CLANGD_BUILD_XPC
1054 log("Starting LSP over XPC service");
1055 TransportLayer = newXPCTransport();
1056#else
1057 llvm::errs() << "This clangd binary wasn't built with XPC support.\n";
1058 return static_cast<int>(ErrorResultCode::CantRunAsXPCService);
1059#endif
1060 } else {
1061 log("Starting LSP over stdin/stdout");
1062 TransportLayer = newJSONTransport(
1063 stdin, llvm::outs(), InputMirrorStream ? &*InputMirrorStream : nullptr,
1064 PrettyPrint, InputStyle);
1065 }
1066 if (!PathMappingsArg.empty()) {
1067 auto Mappings = parsePathMappings(PathMappingsArg);
1068 if (!Mappings) {
1069 elog("Invalid -path-mappings: {0}", Mappings.takeError());
1070 return 1;
1071 }
1072 TransportLayer = createPathMappingTransport(std::move(TransportLayer),
1073 std::move(*Mappings));
1074 }
1075
1076 ClangdLSPServer LSPServer(*TransportLayer, TFS, std::move(Opts));
1077 llvm::set_thread_name("clangd.main");
1078 int ExitCode = LSPServer.run()
1079 ? 0
1080 : static_cast<int>(ErrorResultCode::NoShutdownRequest);
1081 log("LSP finished, exiting with status {0}", ExitCode);
1082
1083 // There may still be lingering background threads (e.g. slow requests
1084 // whose results will be dropped, background index shutting down).
1085 //
1086 // These should terminate quickly, and ~ClangdLSPServer blocks on them.
1087 // However if a bug causes them to run forever, we want to ensure the process
1088 // eventually exits. As clangd isn't directly user-facing, an editor can
1089 // "leak" clangd processes. Crashing in this case contains the damage.
1090 abortAfterTimeout(std::chrono::minutes(5));
1091
1092 return ExitCode;
1093}
1094
1095} // namespace clangd
1096} // namespace clang
static cl::opt< std::string > Config("config", desc(R"( Specifies a configuration in YAML/JSON format: -config="{Checks:' *', CheckOptions:{x:y}}" When the value is empty, clang-tidy will attempt to find a file named .clang-tidy for each source file in its parent directories. )"), cl::init(""), cl::cat(ClangTidyCategory))
static cl::desc desc(StringRef Description)
Include Cleaner is clangd functionality for providing diagnostics for misuse of transitive headers an...
Runs tasks on separate (detached) threads and wait for all tasks to finish.
Definition Threading.h:108
This class exposes ClangdServer's capabilities via Language Server Protocol.
bool run()
Run LSP server loop, communicating with the Transport provided in the constructor.
A FeatureModuleSet is a collection of feature modules installed in clangd.
static FeatureModuleSet fromRegistry()
Interface to allow custom logging in clangd.
Definition Logger.h:22
Only one LoggingSession can be active at a time.
Definition Logger.h:106
llvm::Expected< std::string > getAbsolutePath(llvm::StringRef, llvm::StringRef Body, llvm::StringRef HintPath) const override
Returns the absolute path of the file corresponding to the URI authority+body in the file system.
Definition TestFS.cpp:112
llvm::Expected< URI > uriFromAbsolutePath(llvm::StringRef AbsolutePath) const override
Definition TestFS.cpp:125
static void runCrashHandlers()
Calls all currently-active ThreadCrashReporters for the current thread.
Wrapper for vfs::FileSystem for use in multithreaded programs like clangd.
An interface base for small context-sensitive refactoring actions.
Definition Tweak.h:46
URIScheme is an extension point for teaching clangd to recognize a custom URI scheme.
Definition URI.h:108
A source of configuration fragments.
static const char *const EnableConfigFlagDesc
Help text for the –enable-config flag, shared by clangd tools that expose createDefaultProviders() on...
static std::vector< std::unique_ptr< Provider > > createDefaultProviders(const ThreadsafeFS &)
Returns providers for the configuration files that clangd tools read by default: project config (ance...
static std::unique_ptr< Provider > combine(std::vector< std::unique_ptr< Provider > >)
A provider that includes fragments from all the supplied providers.
std::function< bool(const Params &, Config &)> CompiledFragment
A chunk of configuration that has been fully analyzed and is ready to apply.
llvm::function_ref< void(const llvm::SMDiagnostic &)> DiagnosticCallback
Used to report problems in parsing or interpreting a config.
std::unique_ptr< clangd::SymbolIndex > getClient(llvm::StringRef Address, llvm::StringRef ProjectRoot)
Returns an SymbolIndex client that passes requests to remote index located at Address.
Definition Client.cpp:203
std::unique_ptr< EventTracer > createJSONTracer(llvm::raw_ostream &OS, bool Pretty)
Create an instance of EventTracer that produces an output in the Trace Event format supported by Chro...
Definition Trace.cpp:268
std::unique_ptr< EventTracer > createCSVMetricTracer(llvm::raw_ostream &OS)
Create an instance of EventTracer that outputs metric measurements as CSV.
Definition Trace.cpp:273
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
Definition AST.cpp:44
llvm::unique_function< void(tidy::ClangTidyOptions &, llvm::StringRef) const > TidyProvider
A factory to modify a tidy::ClangTidyOptions.
@ Error
An error message.
Definition Protocol.h:751
TidyProvider combine(std::vector< TidyProvider > Providers)
bool check(llvm::StringRef File, const ThreadsafeFS &TFS, ClangdLSPServer::Options &&Opts)
Definition Check.cpp:465
unsigned getDefaultAsyncThreadsCount()
Returns a number of a default async threads to use for TUScheduler.
void vlog(const char *Fmt, Ts &&... Vals)
Definition Logger.h:72
std::string platformString()
Definition Feature.cpp:20
llvm::Error error(std::error_code EC, const char *Fmt, Ts &&... Vals)
Definition Logger.h:79
llvm::Expected< PathMappings > parsePathMappings(llvm::StringRef RawPathMappings)
Parse the command line RawPathMappings (e.g.
std::string featureString()
Definition Feature.cpp:33
static URISchemeRegistry::Add< TestScheme > X(TestScheme::Scheme, "Test schema")
std::unique_ptr< Transport > createPathMappingTransport(std::unique_ptr< Transport > Transp, PathMappings Mappings)
Creates a wrapping transport over Transp that applies the Mappings to all inbound and outbound LSP me...
std::unique_ptr< Transport > newXPCTransport()
void log(const char *Fmt, Ts &&... Vals)
Definition Logger.h:67
TidyProvider provideClangTidyFiles(ThreadsafeFS &TFS)
Provider that searches for .clang-tidy configuration files in the directory tree.
void allowCrashPragmasForTest()
Respect #pragma clang __debug crash etc, which are usually disabled.
Definition Compiler.cpp:45
std::unique_ptr< SymbolIndex > createProjectAwareIndex(IndexFactory Gen, bool Sync)
Returns an index that answers queries using external indices.
int clangdMain(int argc, char *argv[])
void requestShutdown()
Sets a flag to indicate that clangd was sent a shutdown signal, and the transport loop should exit at...
Definition Shutdown.cpp:28
TidyProvider disableUnusableChecks(llvm::ArrayRef< std::string > ExtraBadChecks)
Provider that will disable checks known to not work with clangd.
std::string Path
A typedef to represent a file path.
Definition Path.h:26
std::unique_ptr< Transport > newJSONTransport(std::FILE *In, llvm::raw_ostream &Out, llvm::raw_ostream *InMirror, bool Pretty, JSONStreamStyle Style)
TidyProvider provideDefaultChecks()
Provider that will enable a nice set of default checks if none are specified.
TidyProvider provideClangdConfig()
void abortAfterTimeout(std::chrono::seconds Timeout)
Causes this process to crash if still running after Timeout.
Definition Shutdown.cpp:18
void elog(const char *Fmt, Ts &&... Vals)
Definition Logger.h:61
std::string versionString()
Definition Feature.cpp:18
std::unique_ptr< SymbolIndex > loadIndex(llvm::StringRef SymbolFilename, SymbolOrigin Origin, bool UseDex, bool SupportContainedRefs)
TidyProvider provideEnvironment()
Provider that just sets the defaults.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
bool EnableExperimentalModulesSupport
Flag to hint the experimental modules support is enabled.
size_t ReferencesLimit
Limit the number of references returned (0 means no limit).
bool UseDirBasedCDB
Look for compilation databases, rather than using compile commands set via LSP (extensions) only.
std::function< void()> MemoryCleanup
If set, periodically called to release memory.
std::unique_ptr< config::Provider > ConfigProvider
Supplies configuration (overrides ClangdServer::ContextProvider).
clangd::CodeCompleteOptions CodeComplete
Per-feature options.
std::function< bool(const Tweak &)> TweakFilter
Returns true if the tweak should be enabled.
std::optional< OffsetEncoding > Encoding
The offset-encoding to use, or std::nullopt to negotiate it over LSP.
bool BuildDynamicSymbolIndex
If true, ClangdServer builds a dynamic in-memory index for symbols in opened files and uses the index...
std::vector< std::string > QueryDriverGlobs
Clangd will execute compiler drivers matching one of these globs to fetch system include path.
bool UseDirtyHeaders
If true, use the dirty buffer contents when building Preambles.
bool StorePreamblesInMemory
Cached preambles are potentially large. If false, store them on disk.
TidyProviderRef ClangTidyProvider
The Options provider to use when running clang-tidy.
SymbolIndex * StaticIndex
If set, use this index to augment code completion results.
llvm::ThreadPriority BackgroundIndexPriority
bool BackgroundIndex
If true, ClangdServer automatically indexes files in the current project on background threads.
unsigned AsyncThreadsCount
To process requests asynchronously, ClangdServer spawns worker threads.
bool ImportInsertions
Whether include fixer insertions for Objective-C code should use import instead of include.
bool StrongWorkspaceMode
Sets an alternate mode of operation.
std::optional< std::string > ResourceDir
The resource directory is used to find internal headers, overriding defaults and -resource-dir compil...
bool EnableOutgoingCalls
Call hierarchy's outgoing calls feature requires additional index serving structures which increase m...
Describes an external index configuration.
Definition Config.h:79
@ Delimiters
empty pair of delimiters "()" or "<>".
Definition Config.h:147
@ FullPlaceholders
full name of both type and variable.
Definition Config.h:149
size_t LimitFiles
The maximum number of affected files (0 means no limit), only meaningful when AllowCrossFile = true.
Definition Rename.h:29
Represents measurements of clangd events, e.g.
Definition Trace.h:38
@ Value
A number whose value is meaningful, and may vary over time.
Definition Trace.h:42