clang-tools  14.0.0git
ConfigCompile.cpp
Go to the documentation of this file.
1 //===--- ConfigCompile.cpp - Translating Fragments into Config ------------===//
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 // Fragments are applied to Configs in two steps:
10 //
11 // 1. (When the fragment is first loaded)
12 // FragmentCompiler::compile() traverses the Fragment and creates
13 // function objects that know how to apply the configuration.
14 // 2. (Every time a config is required)
15 // CompiledFragment() executes these functions to populate the Config.
16 //
17 // Work could be split between these steps in different ways. We try to
18 // do as much work as possible in the first step. For example, regexes are
19 // compiled in stage 1 and captured by the apply function. This is because:
20 //
21 // - it's more efficient, as the work done in stage 1 must only be done once
22 // - problems can be reported in stage 1, in stage 2 we must silently recover
23 //
24 //===----------------------------------------------------------------------===//
25 
26 #include "CompileCommands.h"
27 #include "Config.h"
28 #include "ConfigFragment.h"
29 #include "ConfigProvider.h"
30 #include "Diagnostics.h"
31 #include "Feature.h"
32 #include "TidyProvider.h"
33 #include "support/Logger.h"
34 #include "support/Path.h"
35 #include "support/Trace.h"
36 #include "llvm/ADT/None.h"
37 #include "llvm/ADT/Optional.h"
38 #include "llvm/ADT/STLExtras.h"
39 #include "llvm/ADT/SmallString.h"
40 #include "llvm/ADT/StringRef.h"
41 #include "llvm/ADT/StringSwitch.h"
42 #include "llvm/Support/Error.h"
43 #include "llvm/Support/FileSystem.h"
44 #include "llvm/Support/Format.h"
45 #include "llvm/Support/FormatVariadic.h"
46 #include "llvm/Support/Path.h"
47 #include "llvm/Support/Regex.h"
48 #include "llvm/Support/SMLoc.h"
49 #include "llvm/Support/SourceMgr.h"
50 #include <algorithm>
51 #include <string>
52 
53 namespace clang {
54 namespace clangd {
55 namespace config {
56 namespace {
57 
58 // Returns an empty stringref if Path is not under FragmentDir. Returns Path
59 // as-is when FragmentDir is empty.
60 llvm::StringRef configRelative(llvm::StringRef Path,
61  llvm::StringRef FragmentDir) {
62  if (FragmentDir.empty())
63  return Path;
64  if (!Path.consume_front(FragmentDir))
65  return llvm::StringRef();
66  return Path.empty() ? "." : Path;
67 }
68 
69 struct CompiledFragmentImpl {
70  // The independent conditions to check before using settings from this config.
71  // The following fragment has *two* conditions:
72  // If: { Platform: [mac, linux], PathMatch: foo/.* }
73  // All of them must be satisfied: the platform and path conditions are ANDed.
74  // The OR logic for the platform condition is implemented inside the function.
75  std::vector<llvm::unique_function<bool(const Params &) const>> Conditions;
76  // Mutations that this fragment will apply to the configuration.
77  // These are invoked only if the conditions are satisfied.
78  std::vector<llvm::unique_function<void(const Params &, Config &) const>>
80 
81  bool operator()(const Params &P, Config &C) const {
82  for (const auto &C : Conditions) {
83  if (!C(P)) {
84  dlog("Config fragment {0}: condition not met", this);
85  return false;
86  }
87  }
88  dlog("Config fragment {0}: applying {1} rules", this, Apply.size());
89  for (const auto &A : Apply)
90  A(P, C);
91  return true;
92  }
93 };
94 
95 // Wrapper around condition compile() functions to reduce arg-passing.
96 struct FragmentCompiler {
97  FragmentCompiler(CompiledFragmentImpl &Out, DiagnosticCallback D,
98  llvm::SourceMgr *SM)
99  : Out(Out), Diagnostic(D), SourceMgr(SM) {}
100  CompiledFragmentImpl &Out;
103  // Normalized Fragment::SourceInfo::Directory.
104  std::string FragmentDirectory;
105  bool Trusted = false;
106 
107  llvm::Optional<llvm::Regex>
108  compileRegex(const Located<std::string> &Text,
109  llvm::Regex::RegexFlags Flags = llvm::Regex::NoFlags) {
110  std::string Anchored = "^(" + *Text + ")$";
111  llvm::Regex Result(Anchored, Flags);
112  std::string RegexError;
113  if (!Result.isValid(RegexError)) {
114  diag(Error, "Invalid regex " + Anchored + ": " + RegexError, Text.Range);
115  return llvm::None;
116  }
117  return Result;
118  }
119 
120  llvm::Optional<std::string> makeAbsolute(Located<std::string> Path,
121  llvm::StringLiteral Description,
122  llvm::sys::path::Style Style) {
123  if (llvm::sys::path::is_absolute(*Path))
124  return *Path;
125  if (FragmentDirectory.empty()) {
126  diag(Error,
127  llvm::formatv(
128  "{0} must be an absolute path, because this fragment is not "
129  "associated with any directory.",
130  Description)
131  .str(),
132  Path.Range);
133  return llvm::None;
134  }
135  llvm::SmallString<256> AbsPath = llvm::StringRef(*Path);
137  llvm::sys::path::native(AbsPath, Style);
138  return AbsPath.str().str();
139  }
140 
141  // Helper with similar API to StringSwitch, for parsing enum values.
142  template <typename T> class EnumSwitch {
143  FragmentCompiler &Outer;
144  llvm::StringRef EnumName;
145  const Located<std::string> &Input;
146  llvm::Optional<T> Result;
147  llvm::SmallVector<llvm::StringLiteral> ValidValues;
148 
149  public:
150  EnumSwitch(llvm::StringRef EnumName, const Located<std::string> &In,
151  FragmentCompiler &Outer)
152  : Outer(Outer), EnumName(EnumName), Input(In) {}
153 
154  EnumSwitch &map(llvm::StringLiteral Name, T Value) {
155  assert(!llvm::is_contained(ValidValues, Name) && "Duplicate value!");
156  ValidValues.push_back(Name);
157  if (!Result && *Input == Name)
158  Result = Value;
159  return *this;
160  }
161 
162  llvm::Optional<T> value() {
163  if (!Result)
164  Outer.diag(
165  Warning,
166  llvm::formatv("Invalid {0} value '{1}'. Valid values are {2}.",
167  EnumName, *Input, llvm::join(ValidValues, ", "))
168  .str(),
169  Input.Range);
170  return Result;
171  };
172  };
173 
174  // Attempt to parse a specified string into an enum.
175  // Yields llvm::None and produces a diagnostic on failure.
176  //
177  // Optional<T> Value = compileEnum<En>("Foo", Frag.Foo)
178  // .map("Foo", Enum::Foo)
179  // .map("Bar", Enum::Bar)
180  // .value();
181  template <typename T>
182  EnumSwitch<T> compileEnum(llvm::StringRef EnumName,
183  const Located<std::string> &In) {
184  return EnumSwitch<T>(EnumName, In, *this);
185  }
186 
187  void compile(Fragment &&F) {
188  Trusted = F.Source.Trusted;
189  if (!F.Source.Directory.empty()) {
190  FragmentDirectory = llvm::sys::path::convert_to_slash(F.Source.Directory);
191  if (FragmentDirectory.back() != '/')
192  FragmentDirectory += '/';
193  }
194  compile(std::move(F.If));
195  compile(std::move(F.CompileFlags));
196  compile(std::move(F.Index));
197  compile(std::move(F.Diagnostics));
198  compile(std::move(F.Completion));
199  }
200 
201  void compile(Fragment::IfBlock &&F) {
202  if (F.HasUnrecognizedCondition)
203  Out.Conditions.push_back([&](const Params &) { return false; });
204 
205 #ifdef CLANGD_PATH_CASE_INSENSITIVE
206  llvm::Regex::RegexFlags Flags = llvm::Regex::IgnoreCase;
207 #else
208  llvm::Regex::RegexFlags Flags = llvm::Regex::NoFlags;
209 #endif
210 
211  auto PathMatch = std::make_unique<std::vector<llvm::Regex>>();
212  for (auto &Entry : F.PathMatch) {
213  if (auto RE = compileRegex(Entry, Flags))
214  PathMatch->push_back(std::move(*RE));
215  }
216  if (!PathMatch->empty()) {
217  Out.Conditions.push_back(
218  [PathMatch(std::move(PathMatch)),
219  FragmentDir(FragmentDirectory)](const Params &P) {
220  if (P.Path.empty())
221  return false;
222  llvm::StringRef Path = configRelative(P.Path, FragmentDir);
223  // Ignore the file if it is not nested under Fragment.
224  if (Path.empty())
225  return false;
226  return llvm::any_of(*PathMatch, [&](const llvm::Regex &RE) {
227  return RE.match(Path);
228  });
229  });
230  }
231 
232  auto PathExclude = std::make_unique<std::vector<llvm::Regex>>();
233  for (auto &Entry : F.PathExclude) {
234  if (auto RE = compileRegex(Entry, Flags))
235  PathExclude->push_back(std::move(*RE));
236  }
237  if (!PathExclude->empty()) {
238  Out.Conditions.push_back(
239  [PathExclude(std::move(PathExclude)),
240  FragmentDir(FragmentDirectory)](const Params &P) {
241  if (P.Path.empty())
242  return false;
243  llvm::StringRef Path = configRelative(P.Path, FragmentDir);
244  // Ignore the file if it is not nested under Fragment.
245  if (Path.empty())
246  return true;
247  return llvm::none_of(*PathExclude, [&](const llvm::Regex &RE) {
248  return RE.match(Path);
249  });
250  });
251  }
252  }
253 
254  void compile(Fragment::CompileFlagsBlock &&F) {
255  if (!F.Remove.empty()) {
256  auto Remove = std::make_shared<ArgStripper>();
257  for (auto &A : F.Remove)
258  Remove->strip(*A);
259  Out.Apply.push_back([Remove(std::shared_ptr<const ArgStripper>(
260  std::move(Remove)))](const Params &, Config &C) {
261  C.CompileFlags.Edits.push_back(
262  [Remove](std::vector<std::string> &Args) {
263  Remove->process(Args);
264  });
265  });
266  }
267 
268  if (!F.Add.empty()) {
269  std::vector<std::string> Add;
270  for (auto &A : F.Add)
271  Add.push_back(std::move(*A));
272  Out.Apply.push_back([Add(std::move(Add))](const Params &, Config &C) {
273  C.CompileFlags.Edits.push_back([Add](std::vector<std::string> &Args) {
274  // The point to insert at. Just append when `--` isn't present.
275  auto It = llvm::find(Args, "--");
276  Args.insert(It, Add.begin(), Add.end());
277  });
278  });
279  }
280 
281  if (F.CompilationDatabase) {
282  llvm::Optional<Config::CDBSearchSpec> Spec;
283  if (**F.CompilationDatabase == "Ancestors") {
284  Spec.emplace();
285  Spec->Policy = Config::CDBSearchSpec::Ancestors;
286  } else if (**F.CompilationDatabase == "None") {
287  Spec.emplace();
288  Spec->Policy = Config::CDBSearchSpec::NoCDBSearch;
289  } else {
290  if (auto Path =
291  makeAbsolute(*F.CompilationDatabase, "CompilationDatabase",
292  llvm::sys::path::Style::native)) {
293  // Drop trailing slash to put the path in canonical form.
294  // Should makeAbsolute do this?
295  llvm::StringRef Rel = llvm::sys::path::relative_path(*Path);
296  if (!Rel.empty() && llvm::sys::path::is_separator(Rel.back()))
297  Path->pop_back();
298 
299  Spec.emplace();
300  Spec->Policy = Config::CDBSearchSpec::FixedDir;
301  Spec->FixedCDBPath = std::move(Path);
302  }
303  }
304  if (Spec)
305  Out.Apply.push_back(
306  [Spec(std::move(*Spec))](const Params &, Config &C) {
307  C.CompileFlags.CDBSearch = Spec;
308  });
309  }
310  }
311 
312  void compile(Fragment::IndexBlock &&F) {
313  if (F.Background) {
314  if (auto Val = compileEnum<Config::BackgroundPolicy>("Background",
315  **F.Background)
316  .map("Build", Config::BackgroundPolicy::Build)
317  .map("Skip", Config::BackgroundPolicy::Skip)
318  .value())
319  Out.Apply.push_back(
320  [Val](const Params &, Config &C) { C.Index.Background = *Val; });
321  }
322  if (F.External)
323  compile(std::move(**F.External), F.External->Range);
324  }
325 
326  void compile(Fragment::IndexBlock::ExternalBlock &&External,
327  llvm::SMRange BlockRange) {
328  if (External.Server && !Trusted) {
329  diag(Error,
330  "Remote index may not be specified by untrusted configuration. "
331  "Copy this into user config to use it.",
332  External.Server->Range);
333  return;
334  }
335 #ifndef CLANGD_ENABLE_REMOTE
336  if (External.Server) {
337  elog("Clangd isn't compiled with remote index support, ignoring Server: "
338  "{0}",
339  *External.Server);
340  External.Server.reset();
341  }
342 #endif
343  // Make sure exactly one of the Sources is set.
344  unsigned SourceCount = External.File.hasValue() +
345  External.Server.hasValue() + *External.IsNone;
346  if (SourceCount != 1) {
347  diag(Error, "Exactly one of File, Server or None must be set.",
348  BlockRange);
349  return;
350  }
351  Config::ExternalIndexSpec Spec;
352  if (External.Server) {
354  Spec.Location = std::move(**External.Server);
355  } else if (External.File) {
357  auto AbsPath = makeAbsolute(std::move(*External.File), "File",
358  llvm::sys::path::Style::native);
359  if (!AbsPath)
360  return;
361  Spec.Location = std::move(*AbsPath);
362  } else {
363  assert(*External.IsNone);
365  }
366  if (Spec.Kind != Config::ExternalIndexSpec::None) {
367  // Make sure MountPoint is an absolute path with forward slashes.
368  if (!External.MountPoint)
369  External.MountPoint.emplace(FragmentDirectory);
370  if ((**External.MountPoint).empty()) {
371  diag(Error, "A mountpoint is required.", BlockRange);
372  return;
373  }
374  auto AbsPath = makeAbsolute(std::move(*External.MountPoint), "MountPoint",
375  llvm::sys::path::Style::posix);
376  if (!AbsPath)
377  return;
378  Spec.MountPoint = std::move(*AbsPath);
379  }
380  Out.Apply.push_back([Spec(std::move(Spec))](const Params &P, Config &C) {
381  if (Spec.Kind == Config::ExternalIndexSpec::None) {
382  C.Index.External = Spec;
383  return;
384  }
385  if (P.Path.empty() || !pathStartsWith(Spec.MountPoint, P.Path,
386  llvm::sys::path::Style::posix))
387  return;
388  C.Index.External = Spec;
389  // Disable background indexing for the files under the mountpoint.
390  // Note that this will overwrite statements in any previous fragments
391  // (including the current one).
392  C.Index.Background = Config::BackgroundPolicy::Skip;
393  });
394  }
395 
396  void compile(Fragment::DiagnosticsBlock &&F) {
397  std::vector<std::string> Normalized;
398  for (const auto &Suppressed : F.Suppress) {
399  if (*Suppressed == "*") {
400  Out.Apply.push_back([&](const Params &, Config &C) {
401  C.Diagnostics.SuppressAll = true;
402  C.Diagnostics.Suppress.clear();
403  });
404  return;
405  }
406  Normalized.push_back(normalizeSuppressedCode(*Suppressed).str());
407  }
408  if (!Normalized.empty())
409  Out.Apply.push_back(
410  [Normalized(std::move(Normalized))](const Params &, Config &C) {
411  if (C.Diagnostics.SuppressAll)
412  return;
413  for (llvm::StringRef N : Normalized)
414  C.Diagnostics.Suppress.insert(N);
415  });
416 
417  compile(std::move(F.ClangTidy));
418  }
419 
420  void compile(Fragment::StyleBlock &&F) {
421  if (!F.FullyQualifiedNamespaces.empty()) {
422  std::vector<std::string> FullyQualifiedNamespaces;
423  for (auto &N : F.FullyQualifiedNamespaces) {
424  // Normalize the data by dropping both leading and trailing ::
425  StringRef Namespace(*N);
426  Namespace.consume_front("::");
427  Namespace.consume_back("::");
428  FullyQualifiedNamespaces.push_back(Namespace.str());
429  }
430  Out.Apply.push_back([FullyQualifiedNamespaces(
431  std::move(FullyQualifiedNamespaces))](
432  const Params &, Config &C) {
433  C.Style.FullyQualifiedNamespaces.insert(
434  C.Style.FullyQualifiedNamespaces.begin(),
435  FullyQualifiedNamespaces.begin(), FullyQualifiedNamespaces.end());
436  });
437  }
438  }
439 
440  void appendTidyCheckSpec(std::string &CurSpec,
441  const Located<std::string> &Arg, bool IsPositive) {
442  StringRef Str = StringRef(*Arg).trim();
443  // Don't support negating here, its handled if the item is in the Add or
444  // Remove list.
445  if (Str.startswith("-") || Str.contains(',')) {
446  diag(Error, "Invalid clang-tidy check name", Arg.Range);
447  return;
448  }
449  if (!Str.contains('*') && !isRegisteredTidyCheck(Str)) {
450  diag(Warning,
451  llvm::formatv("clang-tidy check '{0}' was not found", Str).str(),
452  Arg.Range);
453  return;
454  }
455  CurSpec += ',';
456  if (!IsPositive)
457  CurSpec += '-';
458  CurSpec += Str;
459  }
460 
461  void compile(Fragment::DiagnosticsBlock::ClangTidyBlock &&F) {
462  std::string Checks;
463  for (auto &CheckGlob : F.Add)
464  appendTidyCheckSpec(Checks, CheckGlob, true);
465 
466  for (auto &CheckGlob : F.Remove)
467  appendTidyCheckSpec(Checks, CheckGlob, false);
468 
469  if (!Checks.empty())
470  Out.Apply.push_back(
471  [Checks = std::move(Checks)](const Params &, Config &C) {
472  C.Diagnostics.ClangTidy.Checks.append(
473  Checks,
474  C.Diagnostics.ClangTidy.Checks.empty() ? /*skip comma*/ 1 : 0,
475  std::string::npos);
476  });
477  if (!F.CheckOptions.empty()) {
478  std::vector<std::pair<std::string, std::string>> CheckOptions;
479  for (auto &Opt : F.CheckOptions)
480  CheckOptions.emplace_back(std::move(*Opt.first),
481  std::move(*Opt.second));
482  Out.Apply.push_back(
483  [CheckOptions = std::move(CheckOptions)](const Params &, Config &C) {
484  for (auto &StringPair : CheckOptions)
485  C.Diagnostics.ClangTidy.CheckOptions.insert_or_assign(
486  StringPair.first, StringPair.second);
487  });
488  }
489  }
490 
491  void compile(Fragment::CompletionBlock &&F) {
492  if (F.AllScopes) {
493  Out.Apply.push_back(
494  [AllScopes(**F.AllScopes)](const Params &, Config &C) {
495  C.Completion.AllScopes = AllScopes;
496  });
497  }
498  }
499 
500  constexpr static llvm::SourceMgr::DiagKind Error = llvm::SourceMgr::DK_Error;
501  constexpr static llvm::SourceMgr::DiagKind Warning =
502  llvm::SourceMgr::DK_Warning;
503  void diag(llvm::SourceMgr::DiagKind Kind, llvm::StringRef Message,
504  llvm::SMRange Range) {
505  if (Range.isValid() && SourceMgr != nullptr)
506  Diagnostic(SourceMgr->GetMessage(Range.Start, Kind, Message, Range));
507  else
508  Diagnostic(llvm::SMDiagnostic("", Kind, Message));
509  }
510 };
511 
512 } // namespace
513 
515  llvm::StringRef ConfigFile = "<unknown>";
516  std::pair<unsigned, unsigned> LineCol = {0, 0};
517  if (auto *SM = Source.Manager.get()) {
518  unsigned BufID = SM->getMainFileID();
519  LineCol = SM->getLineAndColumn(Source.Location, BufID);
520  ConfigFile = SM->getBufferInfo(BufID).Buffer->getBufferIdentifier();
521  }
522  trace::Span Tracer("ConfigCompile");
523  SPAN_ATTACH(Tracer, "ConfigFile", ConfigFile);
524  auto Result = std::make_shared<CompiledFragmentImpl>();
525  vlog("Config fragment: compiling {0}:{1} -> {2} (trusted={3})", ConfigFile,
526  LineCol.first, Result.get(), Source.Trusted);
527 
528  FragmentCompiler{*Result, D, Source.Manager.get()}.compile(std::move(*this));
529  // Return as cheaply-copyable wrapper.
530  return [Result(std::move(Result))](const Params &P, Config &C) {
531  return (*Result)(P, C);
532  };
533 }
534 
535 } // namespace config
536 } // namespace clangd
537 } // namespace clang
dlog
#define dlog(...)
Definition: Logger.h:102
Range
CharSourceRange Range
SourceRange for the file name.
Definition: IncludeOrderCheck.cpp:38
Flags
MixFlags Flags
Definition: EasilySwappableParametersCheck.cpp:1086
Apply
std::vector< llvm::unique_function< void(const Params &, Config &) const > > Apply
Definition: ConfigCompile.cpp:79
clang::clangd::Config::BackgroundPolicy::Skip
@ Skip
clang::clangd::Path
std::string Path
A typedef to represent a file path.
Definition: Path.h:26
Tracer
std::unique_ptr< trace::EventTracer > Tracer
Definition: TraceTests.cpp:164
Path.h
Checks
static cl::opt< std::string > Checks("checks", cl::desc(R"( Comma-separated list of globs with optional '-' prefix. Globs are processed in order of appearance in the list. Globs without '-' prefix add checks with matching names to the set, globs with the '-' prefix remove checks with matching names from the set of enabled checks. This option's value is appended to the value of the 'Checks' option in .clang-tidy file, if any. )"), cl::init(""), cl::cat(ClangTidyCategory))
clang::tidy::bugprone::Message
static const char Message[]
Definition: ReservedIdentifierCheck.cpp:31
Kind
BindArgumentKind Kind
Definition: AvoidBindCheck.cpp:59
Feature.h
Text
std::string Text
Definition: HTMLGenerator.cpp:80
ConfigProvider.h
Trace.h
Outer
std::pair< Context, Canceler > Outer
Definition: CancellationTests.cpp:49
clang::clangd::Config
Settings that express user/project preferences and control clangd behavior.
Definition: Config.h:43
clang::clangd::config::Fragment::compile
CompiledFragment compile(DiagnosticCallback) &&
Analyzes and consumes this fragment, possibly yielding more diagnostics.
Definition: ConfigCompile.cpp:514
clang::tidy::cppcoreguidelines::join
static std::string join(ArrayRef< SpecialMemberFunctionsCheck::SpecialMemberFunctionKind > SMFS, llvm::StringRef AndOr)
Definition: SpecialMemberFunctionsCheck.cpp:78
clang::clangd::Config::CDBSearchSpec::Ancestors
@ Ancestors
Definition: Config.h:56
ConfigFile
static cl::opt< std::string > ConfigFile("config-file", cl::desc(R"( Specify the path of .clang-tidy or custom config file: e.g. --config-file=/some/path/myTidyConfigFile This option internally works exactly the same way as --config option after reading specified config file. Use either --config-file or --config, not both. )"), cl::init(""), cl::cat(ClangTidyCategory))
Trusted
bool Trusted
Definition: ConfigCompile.cpp:105
SourceMgr
llvm::SourceMgr * SourceMgr
Definition: ConfigCompile.cpp:102
clang::clangd::Config::ExternalIndexSpec::File
@ File
Definition: Config.h:73
clang::clangd::Config::CDBSearchSpec::FixedDir
@ FixedDir
Definition: Config.h:56
run-clang-tidy.make_absolute
def make_absolute(f, directory)
Definition: run-clang-tidy.py:76
Error
constexpr static llvm::SourceMgr::DiagKind Error
Definition: ConfigCompile.cpp:500
ns1::ns2::A
@ A
Definition: CategoricalFeature.h:3
ns1::ns2::D
@ D
Definition: CategoricalFeature.h:3
Diagnostic
DiagnosticCallback Diagnostic
Definition: ConfigCompile.cpp:101
clang::clangd::Config::CDBSearchSpec::NoCDBSearch
@ NoCDBSearch
Definition: Config.h:56
TidyProvider.h
CompileCommands.h
Logger.h
Args
llvm::json::Object Args
Definition: Trace.cpp:139
if
if(CLANGD_ENABLE_REMOTE) generate_protos(RemoteIndexProto "Index.proto") generate_protos(MonitoringServiceProto "MonitoringService.proto" GRPC) generate_protos(RemoteIndexServiceProto "Service.proto" DEPENDS "Index.proto" GRPC) target_link_libraries(RemoteIndexServiceProto PRIVATE RemoteIndexProto MonitoringServiceProto) include_directories($
Definition: clangd/index/remote/CMakeLists.txt:1
Description
const char * Description
Definition: Dexp.cpp:361
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:27
clang::clangd::Config::ExternalIndexSpec::None
@ None
Definition: Config.h:73
SPAN_ATTACH
#define SPAN_ATTACH(S, Name, Expr)
Attach a key-value pair to a Span event.
Definition: Trace.h:164
clang::clangd::pathStartsWith
bool pathStartsWith(PathRef Ancestor, PathRef Path, llvm::sys::path::Style Style)
Checks if Ancestor is a proper ancestor of Path.
Definition: Path.cpp:36
clang::clangd::vlog
void vlog(const char *Fmt, Ts &&... Vals)
Definition: Logger.h:73
Diagnostics.h
clang::clangd::isRegisteredTidyCheck
bool isRegisteredTidyCheck(llvm::StringRef Check)
Returns if Check is a registered clang-tidy check.
Definition: TidyProvider.cpp:286
clang::clangd::config::CompiledFragment
std::function< bool(const Params &, Config &)> CompiledFragment
A chunk of configuration that has been fully analyzed and is ready to apply.
Definition: ConfigProvider.h:58
Config
static cl::opt< std::string > Config("config", cl::desc(R"( Specifies a configuration in YAML/JSON format: -config="{Checks:' *', CheckOptions:[{key:x, value: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))
Entry
Definition: Modularize.cpp:428
clang::clangd::Config::ExternalIndexSpec::Server
@ Server
Definition: Config.h:73
Config.h
FragmentDirectory
std::string FragmentDirectory
Definition: ConfigCompile.cpp:104
Conditions
std::vector< llvm::unique_function< bool(const Params &) const > > Conditions
Definition: ConfigCompile.cpp:75
C
const Criteria C
Definition: FunctionCognitiveComplexityCheck.cpp:93
clang::clangd::config::Params
Describes the context used to evaluate configuration fragments.
Definition: ConfigProvider.h:35
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::clangd::normalizeSuppressedCode
llvm::StringRef normalizeSuppressedCode(llvm::StringRef Code)
Take a user-specified diagnostic code, and convert it to a normalized form stored in the config and c...
Definition: Diagnostics.cpp:877
clang::clangd::SymbolKind::Namespace
@ Namespace
Out
CompiledFragmentImpl & Out
Definition: ConfigCompile.cpp:100
ConfigFragment.h
clang::clangd::elog
void elog(const char *Fmt, Ts &&... Vals)
Definition: Logger.h:62
clang::clangd::Config::BackgroundPolicy::Build
@ Build
Warning
constexpr static llvm::SourceMgr::DiagKind Warning
Definition: ConfigCompile.cpp:501
clang::clangd::config::DiagnosticCallback
llvm::function_ref< void(const llvm::SMDiagnostic &)> DiagnosticCallback
Used to report problems in parsing or interpreting a config.
Definition: ConfigProvider.h:51
clang::clangd::trace::Span
Records an event whose duration is the lifetime of the Span object.
Definition: Trace.h:143