clang-tools  14.0.0git
ConfigCompileTests.cpp
Go to the documentation of this file.
1 //===-- ConfigCompileTests.cpp --------------------------------------------===//
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 "Config.h"
10 #include "ConfigFragment.h"
11 #include "ConfigTesting.h"
12 #include "Feature.h"
13 #include "TestFS.h"
14 #include "clang/Basic/DiagnosticSema.h"
15 #include "llvm/ADT/None.h"
16 #include "llvm/ADT/Optional.h"
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/Support/Path.h"
19 #include "llvm/Support/SourceMgr.h"
20 #include "gmock/gmock.h"
21 #include "gtest/gtest.h"
22 #include <string>
23 
24 namespace clang {
25 namespace clangd {
26 namespace config {
27 namespace {
28 using ::testing::AllOf;
29 using ::testing::Contains;
30 using ::testing::ElementsAre;
31 using ::testing::IsEmpty;
32 using ::testing::SizeIs;
33 using ::testing::StartsWith;
34 using ::testing::UnorderedElementsAre;
35 
36 class ConfigCompileTests : public ::testing::Test {
37 protected:
38  CapturedDiags Diags;
40  Fragment Frag;
41  Params Parm;
42 
43  bool compileAndApply() {
44  Conf = Config();
45  Diags.Diagnostics.clear();
46  auto Compiled = std::move(Frag).compile(Diags.callback());
47  return Compiled(Parm, Conf);
48  }
49 };
50 
51 TEST_F(ConfigCompileTests, Condition) {
52  // No condition.
53  Frag = {};
54  Frag.CompileFlags.Add.emplace_back("X");
55  EXPECT_TRUE(compileAndApply()) << "Empty config";
56  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
57  EXPECT_THAT(Conf.CompileFlags.Edits, SizeIs(1));
58 
59  // Regex with no file.
60  Frag = {};
61  Frag.If.PathMatch.emplace_back("fo*");
62  EXPECT_FALSE(compileAndApply());
63  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
64  EXPECT_THAT(Conf.CompileFlags.Edits, SizeIs(0));
65 
66  // Following tests have a file path set.
67  Parm.Path = "bar";
68 
69  // Non-matching regex.
70  Frag = {};
71  Frag.If.PathMatch.emplace_back("fo*");
72  EXPECT_FALSE(compileAndApply());
73  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
74 
75  // Matching regex.
76  Frag = {};
77  Frag.If.PathMatch.emplace_back("fo*");
78  Frag.If.PathMatch.emplace_back("ba*r");
79  EXPECT_TRUE(compileAndApply());
80  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
81 
82  // Excluded regex.
83  Frag = {};
84  Frag.If.PathMatch.emplace_back("b.*");
85  Frag.If.PathExclude.emplace_back(".*r");
86  EXPECT_FALSE(compileAndApply()) << "Included but also excluded";
87  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
88 
89  // Invalid regex.
90  Frag = {};
91  Frag.If.PathMatch.emplace_back("**]@theu");
92  EXPECT_TRUE(compileAndApply());
93  EXPECT_THAT(Diags.Diagnostics, SizeIs(1));
94  EXPECT_THAT(Diags.Diagnostics.front().Message, StartsWith("Invalid regex"));
95 
96  // Valid regex and unknown key.
97  Frag = {};
99  Frag.If.PathMatch.emplace_back("ba*r");
100  EXPECT_FALSE(compileAndApply());
101  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
102 
103  // Only matches case-insensitively.
104  Frag = {};
105  Frag.If.PathMatch.emplace_back("B.*R");
106  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
107 #ifdef CLANGD_PATH_CASE_INSENSITIVE
108  EXPECT_TRUE(compileAndApply());
109 #else
110  EXPECT_FALSE(compileAndApply());
111 #endif
112 
113  Frag = {};
114  Frag.If.PathExclude.emplace_back("B.*R");
115  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
116 #ifdef CLANGD_PATH_CASE_INSENSITIVE
117  EXPECT_FALSE(compileAndApply());
118 #else
119  EXPECT_TRUE(compileAndApply());
120 #endif
121 }
122 
123 TEST_F(ConfigCompileTests, CompileCommands) {
124  Frag.CompileFlags.Add.emplace_back("-foo");
125  Frag.CompileFlags.Remove.emplace_back("--include-directory=");
126  std::vector<std::string> Argv = {"clang", "-I", "bar/", "--", "a.cc"};
127  EXPECT_TRUE(compileAndApply());
128  EXPECT_THAT(Conf.CompileFlags.Edits, SizeIs(2));
129  for (auto &Edit : Conf.CompileFlags.Edits)
130  Edit(Argv);
131  EXPECT_THAT(Argv, ElementsAre("clang", "-foo", "--", "a.cc"));
132 }
133 
134 TEST_F(ConfigCompileTests, CompilationDatabase) {
135  Frag.CompileFlags.CompilationDatabase.emplace("None");
136  EXPECT_TRUE(compileAndApply());
137  EXPECT_EQ(Conf.CompileFlags.CDBSearch.Policy,
139 
140  Frag.CompileFlags.CompilationDatabase.emplace("Ancestors");
141  EXPECT_TRUE(compileAndApply());
142  EXPECT_EQ(Conf.CompileFlags.CDBSearch.Policy,
144 
145  // Relative path not allowed without directory set.
146  Frag.CompileFlags.CompilationDatabase.emplace("Something");
147  EXPECT_TRUE(compileAndApply());
148  EXPECT_EQ(Conf.CompileFlags.CDBSearch.Policy,
150  << "default value";
151  EXPECT_THAT(Diags.Diagnostics,
152  ElementsAre(DiagMessage(
153  "CompilationDatabase must be an absolute path, because this "
154  "fragment is not associated with any directory.")));
155 
156  // Relative path allowed if directory is set.
158  EXPECT_TRUE(compileAndApply());
159  EXPECT_EQ(Conf.CompileFlags.CDBSearch.Policy,
161  EXPECT_EQ(Conf.CompileFlags.CDBSearch.FixedCDBPath, testPath("Something"));
162  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
163 
164  // Absolute path allowed.
165  Frag.Source.Directory.clear();
166  Frag.CompileFlags.CompilationDatabase.emplace(testPath("Something2"));
167  EXPECT_TRUE(compileAndApply());
168  EXPECT_EQ(Conf.CompileFlags.CDBSearch.Policy,
170  EXPECT_EQ(Conf.CompileFlags.CDBSearch.FixedCDBPath, testPath("Something2"));
171  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
172 }
173 
174 TEST_F(ConfigCompileTests, Index) {
175  Frag.Index.Background.emplace("Skip");
176  EXPECT_TRUE(compileAndApply());
177  EXPECT_EQ(Conf.Index.Background, Config::BackgroundPolicy::Skip);
178 
179  Frag = {};
180  Frag.Index.Background.emplace("Foo");
181  EXPECT_TRUE(compileAndApply());
182  EXPECT_EQ(Conf.Index.Background, Config::BackgroundPolicy::Build)
183  << "by default";
184  EXPECT_THAT(
186  ElementsAre(DiagMessage(
187  "Invalid Background value 'Foo'. Valid values are Build, Skip.")));
188 }
189 
190 TEST_F(ConfigCompileTests, PathSpecMatch) {
191  auto BarPath = llvm::sys::path::convert_to_slash(testPath("foo/bar.h"));
192  Parm.Path = BarPath;
193 
194  struct {
195  std::string Directory;
196  std::string PathSpec;
197  bool ShouldMatch;
198  } Cases[] = {
199  {
200  // Absolute path matches.
201  "",
202  llvm::sys::path::convert_to_slash(testPath("foo/bar.h")),
203  true,
204  },
205  {
206  // Absolute path fails.
207  "",
208  llvm::sys::path::convert_to_slash(testPath("bar/bar.h")),
209  false,
210  },
211  {
212  // Relative should fail to match as /foo/bar.h doesn't reside under
213  // /baz/.
214  testPath("baz"),
215  "bar\\.h",
216  false,
217  },
218  {
219  // Relative should pass with /foo as directory.
220  testPath("foo"),
221  "bar\\.h",
222  true,
223  },
224  };
225 
226  // PathMatch
227  for (const auto &Case : Cases) {
228  Frag = {};
229  Frag.If.PathMatch.emplace_back(Case.PathSpec);
230  Frag.Source.Directory = Case.Directory;
231  EXPECT_EQ(compileAndApply(), Case.ShouldMatch);
232  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
233  }
234 
235  // PathEclude
236  for (const auto &Case : Cases) {
237  SCOPED_TRACE(Case.Directory);
238  SCOPED_TRACE(Case.PathSpec);
239  Frag = {};
240  Frag.If.PathExclude.emplace_back(Case.PathSpec);
241  Frag.Source.Directory = Case.Directory;
242  EXPECT_NE(compileAndApply(), Case.ShouldMatch);
243  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
244  }
245 }
246 
247 TEST_F(ConfigCompileTests, DiagnosticSuppression) {
248  Frag.Diagnostics.Suppress.emplace_back("bugprone-use-after-move");
249  Frag.Diagnostics.Suppress.emplace_back("unreachable-code");
250  Frag.Diagnostics.Suppress.emplace_back("-Wunused-variable");
251  Frag.Diagnostics.Suppress.emplace_back("typecheck_bool_condition");
252  Frag.Diagnostics.Suppress.emplace_back("err_unexpected_friend");
253  Frag.Diagnostics.Suppress.emplace_back("warn_alloca");
254  EXPECT_TRUE(compileAndApply());
255  EXPECT_THAT(Conf.Diagnostics.Suppress.keys(),
256  UnorderedElementsAre("bugprone-use-after-move",
257  "unreachable-code", "unused-variable",
258  "typecheck_bool_condition",
259  "unexpected_friend", "warn_alloca"));
260  EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::warn_unreachable,
261  Conf.Diagnostics.Suppress));
262  // Subcategory not respected/suppressed.
263  EXPECT_FALSE(isBuiltinDiagnosticSuppressed(diag::warn_unreachable_break,
264  Conf.Diagnostics.Suppress));
265  EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::warn_unused_variable,
266  Conf.Diagnostics.Suppress));
267  EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::err_typecheck_bool_condition,
268  Conf.Diagnostics.Suppress));
269  EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::err_unexpected_friend,
270  Conf.Diagnostics.Suppress));
271  EXPECT_TRUE(isBuiltinDiagnosticSuppressed(diag::warn_alloca,
272  Conf.Diagnostics.Suppress));
273 
274  Frag.Diagnostics.Suppress.emplace_back("*");
275  EXPECT_TRUE(compileAndApply());
276  EXPECT_TRUE(Conf.Diagnostics.SuppressAll);
277  EXPECT_THAT(Conf.Diagnostics.Suppress, IsEmpty());
278 }
279 
280 TEST_F(ConfigCompileTests, Tidy) {
281  auto &Tidy = Frag.Diagnostics.ClangTidy;
282  Tidy.Add.emplace_back("bugprone-use-after-move");
283  Tidy.Add.emplace_back("llvm-*");
284  Tidy.Remove.emplace_back("llvm-include-order");
285  Tidy.Remove.emplace_back("readability-*");
286  Tidy.CheckOptions.emplace_back(
287  std::make_pair(std::string("StrictMode"), std::string("true")));
288  Tidy.CheckOptions.emplace_back(std::make_pair(
289  std::string("example-check.ExampleOption"), std::string("0")));
290  EXPECT_TRUE(compileAndApply());
291  EXPECT_EQ(Conf.Diagnostics.ClangTidy.CheckOptions.size(), 2U);
292  EXPECT_EQ(Conf.Diagnostics.ClangTidy.CheckOptions.lookup("StrictMode"),
293  "true");
294  EXPECT_EQ(Conf.Diagnostics.ClangTidy.CheckOptions.lookup(
295  "example-check.ExampleOption"),
296  "0");
297 #if CLANGD_TIDY_CHECKS
298  EXPECT_EQ(
299  Conf.Diagnostics.ClangTidy.Checks,
300  "bugprone-use-after-move,llvm-*,-llvm-include-order,-readability-*");
301  EXPECT_THAT(Diags.Diagnostics, IsEmpty());
302 #else // !CLANGD_TIDY_CHECKS
303  EXPECT_EQ(Conf.Diagnostics.ClangTidy.Checks, "llvm-*,-readability-*");
304  EXPECT_THAT(
306  ElementsAre(
307  DiagMessage(
308  "clang-tidy check 'bugprone-use-after-move' was not found"),
309  DiagMessage("clang-tidy check 'llvm-include-order' was not found")));
310 #endif
311 }
312 
313 TEST_F(ConfigCompileTests, TidyBadChecks) {
314  auto &Tidy = Frag.Diagnostics.ClangTidy;
315  Tidy.Add.emplace_back("unknown-check");
316  Tidy.Remove.emplace_back("*");
317  Tidy.Remove.emplace_back("llvm-includeorder");
318  EXPECT_TRUE(compileAndApply());
319  // Ensure bad checks are stripped from the glob.
320  EXPECT_EQ(Conf.Diagnostics.ClangTidy.Checks, "-*");
321  EXPECT_THAT(
323  ElementsAre(
324  AllOf(DiagMessage("clang-tidy check 'unknown-check' was not found"),
325  DiagKind(llvm::SourceMgr::DK_Warning)),
326  AllOf(
327  DiagMessage("clang-tidy check 'llvm-includeorder' was not found"),
328  DiagKind(llvm::SourceMgr::DK_Warning))));
329 }
330 
331 TEST_F(ConfigCompileTests, ExternalServerNeedsTrusted) {
332  Fragment::IndexBlock::ExternalBlock External;
333  External.Server.emplace("xxx");
334  Frag.Index.External = std::move(External);
335  compileAndApply();
336  EXPECT_THAT(
338  ElementsAre(DiagMessage(
339  "Remote index may not be specified by untrusted configuration. "
340  "Copy this into user config to use it.")));
341  EXPECT_EQ(Conf.Index.External.Kind, Config::ExternalIndexSpec::None);
342 }
343 
344 TEST_F(ConfigCompileTests, ExternalBlockWarnOnMultipleSource) {
345  Frag.Source.Trusted = true;
346  Fragment::IndexBlock::ExternalBlock External;
347  External.File.emplace("");
348  External.Server.emplace("");
349  Frag.Index.External = std::move(External);
350  compileAndApply();
351 #ifdef CLANGD_ENABLE_REMOTE
352  EXPECT_THAT(
354  Contains(
355  AllOf(DiagMessage("Exactly one of File, Server or None must be set."),
356  DiagKind(llvm::SourceMgr::DK_Error))));
357 #else
358  ASSERT_TRUE(Conf.Index.External.hasValue());
359  EXPECT_EQ(Conf.Index.External->Kind, Config::ExternalIndexSpec::File);
360 #endif
361 }
362 
363 TEST_F(ConfigCompileTests, ExternalBlockDisableWithNone) {
364  compileAndApply();
365  EXPECT_EQ(Conf.Index.External.Kind, Config::ExternalIndexSpec::None);
366 
367  Fragment::IndexBlock::ExternalBlock External;
368  External.IsNone = true;
369  Frag.Index.External = std::move(External);
370  compileAndApply();
371  EXPECT_EQ(Conf.Index.External.Kind, Config::ExternalIndexSpec::None);
372 }
373 
374 TEST_F(ConfigCompileTests, ExternalBlockErrOnNoSource) {
375  Frag.Index.External.emplace(Fragment::IndexBlock::ExternalBlock{});
376  compileAndApply();
377  EXPECT_THAT(
379  Contains(
380  AllOf(DiagMessage("Exactly one of File, Server or None must be set."),
381  DiagKind(llvm::SourceMgr::DK_Error))));
382 }
383 
384 TEST_F(ConfigCompileTests, ExternalBlockDisablesBackgroundIndex) {
385  auto BazPath = testPath("foo/bar/baz.h", llvm::sys::path::Style::posix);
386  Parm.Path = BazPath;
387  Frag.Index.Background.emplace("Build");
388  Fragment::IndexBlock::ExternalBlock External;
389  External.File.emplace(testPath("foo"));
390  External.MountPoint.emplace(
391  testPath("foo/bar", llvm::sys::path::Style::posix));
392  Frag.Index.External = std::move(External);
393  compileAndApply();
394  EXPECT_EQ(Conf.Index.Background, Config::BackgroundPolicy::Skip);
395 }
396 
397 TEST_F(ConfigCompileTests, ExternalBlockMountPoint) {
398  auto GetFrag = [](llvm::StringRef Directory,
399  llvm::Optional<const char *> MountPoint) {
400  Fragment Frag;
401  Frag.Source.Directory = Directory.str();
402  Fragment::IndexBlock::ExternalBlock External;
403  External.File.emplace(testPath("foo"));
404  if (MountPoint)
405  External.MountPoint.emplace(*MountPoint);
406  Frag.Index.External = std::move(External);
407  return Frag;
408  };
409 
410  auto BarPath = testPath("foo/bar.h", llvm::sys::path::Style::posix);
411  BarPath = llvm::sys::path::convert_to_slash(BarPath);
412  Parm.Path = BarPath;
413  // Non-absolute MountPoint without a directory raises an error.
414  Frag = GetFrag("", "foo");
415  compileAndApply();
416  ASSERT_THAT(
418  ElementsAre(
419  AllOf(DiagMessage("MountPoint must be an absolute path, because this "
420  "fragment is not associated with any directory."),
421  DiagKind(llvm::SourceMgr::DK_Error))));
422  EXPECT_EQ(Conf.Index.External.Kind, Config::ExternalIndexSpec::None);
423 
424  auto FooPath = testPath("foo/", llvm::sys::path::Style::posix);
425  FooPath = llvm::sys::path::convert_to_slash(FooPath);
426  // Ok when relative.
427  Frag = GetFrag(testRoot(), "foo/");
428  compileAndApply();
429  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
430  ASSERT_EQ(Conf.Index.External.Kind, Config::ExternalIndexSpec::File);
431  EXPECT_THAT(Conf.Index.External.MountPoint, FooPath);
432 
433  // None defaults to ".".
434  Frag = GetFrag(FooPath, llvm::None);
435  compileAndApply();
436  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
437  ASSERT_EQ(Conf.Index.External.Kind, Config::ExternalIndexSpec::File);
438  EXPECT_THAT(Conf.Index.External.MountPoint, FooPath);
439 
440  // Without a file, external index is empty.
441  Parm.Path = "";
442  Frag = GetFrag("", FooPath.c_str());
443  compileAndApply();
444  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
445  ASSERT_EQ(Conf.Index.External.Kind, Config::ExternalIndexSpec::None);
446 
447  // File outside MountPoint, no index.
448  auto BazPath = testPath("bar/baz.h", llvm::sys::path::Style::posix);
449  BazPath = llvm::sys::path::convert_to_slash(BazPath);
450  Parm.Path = BazPath;
451  Frag = GetFrag("", FooPath.c_str());
452  compileAndApply();
453  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
454  ASSERT_EQ(Conf.Index.External.Kind, Config::ExternalIndexSpec::None);
455 
456  // File under MountPoint, index should be set.
457  BazPath = testPath("foo/baz.h", llvm::sys::path::Style::posix);
458  BazPath = llvm::sys::path::convert_to_slash(BazPath);
459  Parm.Path = BazPath;
460  Frag = GetFrag("", FooPath.c_str());
461  compileAndApply();
462  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
463  ASSERT_EQ(Conf.Index.External.Kind, Config::ExternalIndexSpec::File);
464  EXPECT_THAT(Conf.Index.External.MountPoint, FooPath);
465 
466  // Only matches case-insensitively.
467  BazPath = testPath("fOo/baz.h", llvm::sys::path::Style::posix);
468  BazPath = llvm::sys::path::convert_to_slash(BazPath);
469  Parm.Path = BazPath;
470 
471  FooPath = testPath("FOO/", llvm::sys::path::Style::posix);
472  FooPath = llvm::sys::path::convert_to_slash(FooPath);
473  Frag = GetFrag("", FooPath.c_str());
474  compileAndApply();
475  ASSERT_THAT(Diags.Diagnostics, IsEmpty());
476 #ifdef CLANGD_PATH_CASE_INSENSITIVE
477  ASSERT_EQ(Conf.Index.External.Kind, Config::ExternalIndexSpec::File);
478  EXPECT_THAT(Conf.Index.External.MountPoint, FooPath);
479 #else
480  ASSERT_EQ(Conf.Index.External.Kind, Config::ExternalIndexSpec::None);
481 #endif
482 }
483 
484 TEST_F(ConfigCompileTests, AllScopes) {
485  // Defaults to true.
486  EXPECT_TRUE(compileAndApply());
487  EXPECT_TRUE(Conf.Completion.AllScopes);
488 
489  Frag = {};
490  Frag.Completion.AllScopes = false;
491  EXPECT_TRUE(compileAndApply());
492  EXPECT_FALSE(Conf.Completion.AllScopes);
493 
494  Frag = {};
495  Frag.Completion.AllScopes = true;
496  EXPECT_TRUE(compileAndApply());
497  EXPECT_TRUE(Conf.Completion.AllScopes);
498 }
499 } // namespace
500 } // namespace config
501 } // namespace clangd
502 } // namespace clang
clang::clangd::Config::BackgroundPolicy::Skip
@ Skip
clang::clangd::config::Fragment::CompileFlags
CompileFlagsBlock CompileFlags
Definition: ConfigFragment.h:165
clang::clangd::testPath
std::string testPath(PathRef File, llvm::sys::path::Style Style)
Definition: TestFS.cpp:82
clang::clangd::config::Fragment::IndexBlock::Background
llvm::Optional< Located< std::string > > Background
Whether files are built in the background to produce a project index.
Definition: ConfigFragment.h:174
Feature.h
clang::clangd::config::Fragment::IfBlock::PathMatch
std::vector< Located< std::string > > PathMatch
The file being processed must fully match a regular expression.
Definition: ConfigFragment.h:116
clang::clangd::Config::CDBSearchSpec::Ancestors
@ Ancestors
Definition: Config.h:56
clang::clangd::TEST_F
TEST_F(BackgroundIndexTest, NoCrashOnErrorFile)
Definition: BackgroundIndexTests.cpp:94
clang::clangd::Config::ExternalIndexSpec::File
@ File
Definition: Config.h:73
clang::clangd::config::Fragment::Completion
CompletionBlock Completion
Definition: ConfigFragment.h:254
clang::clangd::config::Fragment::Diagnostics
DiagnosticsBlock Diagnostics
Definition: ConfigFragment.h:236
clang::clangd::Config::CDBSearchSpec::FixedDir
@ FixedDir
Definition: Config.h:56
Condition
std::string Condition
Condition used after the preprocessor directive.
Definition: RedundantPreprocessorCheck.cpp:24
clang::clangd::config::Fragment::CompileFlagsBlock::CompilationDatabase
llvm::Optional< Located< std::string > > CompilationDatabase
Directory to search for compilation database (compile_comands.json etc).
Definition: ConfigFragment.h:163
clang::clangd::testRoot
const char * testRoot()
Definition: TestFS.cpp:74
clang::clangd::Config::CDBSearchSpec::NoCDBSearch
@ NoCDBSearch
Definition: Config.h:56
clang::clangd::config::Fragment::IndexBlock::External
llvm::Optional< Located< ExternalBlock > > External
Definition: ConfigFragment.h:193
Conf
Config Conf
Definition: ConfigCompileTests.cpp:39
clang::clangd::config::Fragment::DiagnosticsBlock::ClangTidyBlock::Add
std::vector< Located< std::string > > Add
Definition: ConfigFragment.h:218
clang::clangd::config::Fragment::Source
SourceInfo Source
Definition: ConfigFragment.h:101
TestFS.h
Directory
llvm::StringRef Directory
Definition: Serialization.cpp:419
clang::clangd::Config::ExternalIndexSpec::None
@ None
Definition: Config.h:73
clang::clangd::config::Fragment::Index
IndexBlock Index
Definition: ConfigFragment.h:195
ConfigTesting.h
Parm
Params Parm
Definition: ConfigCompileTests.cpp:41
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))
Index
const SymbolIndex * Index
Definition: Dexp.cpp:99
clang::clangd::config::Fragment::SourceInfo::Directory
std::string Directory
Absolute path to directory the fragment is associated with.
Definition: ConfigFragment.h:96
clang::clangd::config::Fragment::DiagnosticsBlock::Suppress
std::vector< Located< std::string > > Suppress
Diagnostic codes that should be suppressed.
Definition: ConfigFragment.h:211
Config.h
Frag
Fragment Frag
Definition: ConfigCompileTests.cpp:40
clang::clangd::config::Fragment::CompletionBlock::AllScopes
llvm::Optional< Located< bool > > AllScopes
Whether code completion should include suggestions from scopes that are not visible.
Definition: ConfigFragment.h:252
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::clangd::config::Params::Path
llvm::StringRef Path
Absolute path to a source file we're applying the config to.
Definition: ConfigProvider.h:38
clang::clangd::config::Fragment::IfBlock::HasUnrecognizedCondition
bool HasUnrecognizedCondition
An unrecognized key was found while parsing the condition.
Definition: ConfigFragment.h:122
Diags
CapturedDiags Diags
Definition: ConfigCompileTests.cpp:38
clang::clangd::config::CapturedDiags::Diagnostics
std::vector< Diag > Diagnostics
Definition: ConfigTesting.h:59
clang::clangd::config::Fragment::IfBlock::PathExclude
std::vector< Located< std::string > > PathExclude
The file being processed must not fully match a regular expression.
Definition: ConfigFragment.h:118
clang::clangd::config::Fragment::DiagnosticsBlock::ClangTidy
ClangTidyBlock ClangTidy
Definition: ConfigFragment.h:234
clang::clangd::config::Fragment::SourceInfo::Trusted
bool Trusted
Whether this fragment is allowed to make critical security/privacy decisions.
Definition: ConfigFragment.h:99
ConfigFragment.h
clang::clangd::config::Fragment::If
IfBlock If
Definition: ConfigFragment.h:124
clang::clangd::config::Fragment::CompileFlagsBlock::Remove
std::vector< Located< std::string > > Remove
List of flags to remove from the compile command.
Definition: ConfigFragment.h:156
clang::clangd::Config::BackgroundPolicy::Build
@ Build
clang::clangd::config::Fragment::CompileFlagsBlock::Add
std::vector< Located< std::string > > Add
List of flags to append to the compile command.
Definition: ConfigFragment.h:138
clang::clangd::isBuiltinDiagnosticSuppressed
bool isBuiltinDiagnosticSuppressed(unsigned ID, const llvm::StringSet<> &Suppress)
Determine whether a (non-clang-tidy) diagnostic is suppressed by config.
Definition: Diagnostics.cpp:865