22 #include "clang/AST/Decl.h" 23 #include "clang/Basic/SourceLocation.h" 24 #include "clang/Index/IndexingAction.h" 25 #include "llvm/ADT/None.h" 26 #include "llvm/ADT/StringRef.h" 27 #include "llvm/Support/Casting.h" 28 #include "llvm/Support/Error.h" 29 #include "llvm/Support/Path.h" 30 #include "llvm/Support/ScopedPrinter.h" 31 #include "gmock/gmock.h" 32 #include "gtest/gtest.h" 40 using ::testing::ElementsAre;
41 using ::testing::IsEmpty;
42 using ::testing::Matcher;
43 using ::testing::UnorderedElementsAreArray;
45 class IgnoreDiagnostics :
public DiagnosticsConsumer {
47 std::vector<Diag> Diagnostics)
override {}
56 Matcher<const std::vector<DocumentHighlight> &>
57 HighlightsFrom(
const Annotations &Test) {
58 std::vector<DocumentHighlight>
Expected;
60 Expected.emplace_back();
61 Expected.back().range = R;
62 Expected.back().kind = K;
64 for (
const auto &
Range : Test.ranges())
66 for (
const auto &
Range : Test.ranges(
"read"))
68 for (
const auto &
Range : Test.ranges(
"write"))
70 return UnorderedElementsAreArray(Expected);
74 const char *Tests[] = {
75 R
"cpp(// Local variable 78 $write[[^bonjour]] = 2; 79 int test1 = $read[[bonjour]]; 86 static void foo([[MyClass]]*) {} 90 ns1::[[My^Class]]* Params; 102 R"cpp(// Function parameter in decl 103 void foo(int [[^bar]]); 106 for (
const char *Test : Tests) {
114 MATCHER_P3(Sym,
Name,
Decl, DefOrNone,
"") {
115 llvm::Optional<Range> Def = DefOrNone;
116 if (
Name != arg.Name) {
117 *result_listener <<
"Name is " << arg.Name;
120 if (
Decl != arg.PreferredDeclaration.range) {
121 *result_listener <<
"Declaration is " 122 << llvm::to_string(arg.PreferredDeclaration);
125 if (Def && !arg.Definition) {
126 *result_listener <<
"Has no definition";
129 if (Def && arg.Definition->range != *Def) {
130 *result_listener <<
"Definition is " << llvm::to_string(arg.Definition);
135 ::testing::Matcher<LocatedSymbol> Sym(std::string
Name,
Range Decl) {
140 MATCHER_P(RangeIs, R,
"") {
return arg.range == R; }
142 TEST(LocateSymbol, WithIndex) {
143 Annotations SymbolHeader(R
"cpp( 144 class $forward[[Forward]]; 145 class $foo[[Foo]] {}; 149 inline void $f2[[f2]]() {} 151 Annotations SymbolCpp(R"cpp( 152 class $forward[[forward]] {}; 157 TU.Code = SymbolCpp.code(); 158 TU.HeaderCode = SymbolHeader.code(); 159 auto Index = TU.index();
160 auto LocateWithIndex = [&
Index](
const Annotations &Main) {
165 Annotations Test(R
"cpp(// only declaration in AST. 171 EXPECT_THAT(LocateWithIndex(Test), 172 ElementsAre(Sym("f1", Test.range(), SymbolCpp.range(
"f1"))));
174 Test = Annotations(R
"cpp(// definition in AST. 180 EXPECT_THAT(LocateWithIndex(Test), 181 ElementsAre(Sym("f1", SymbolHeader.range(
"f1"), Test.range())));
183 Test = Annotations(R
"cpp(// forward declaration in AST. 187 EXPECT_THAT(LocateWithIndex(Test), 188 ElementsAre(Sym("Foo", Test.range(), SymbolHeader.range(
"foo"))));
190 Test = Annotations(R
"cpp(// definition in AST. 191 class [[Forward]] {}; 195 LocateWithIndex(Test), 196 ElementsAre(Sym("Forward", SymbolHeader.range(
"forward"), Test.range())));
199 TEST(LocateSymbol, WithIndexPreferredLocation) {
200 Annotations SymbolHeader(R
"cpp( 201 class $p[[Proto]] {}; 202 void $f[[func]]() {}; 205 TU.HeaderCode = SymbolHeader.code(); 206 TU.HeaderFilename = "x.proto";
207 auto Index = TU.index();
209 Annotations Test(R
"cpp(// only declaration in AST. 210 // Shift to make range different. 222 auto CodeGenLoc = SymbolHeader.range(
"p");
223 EXPECT_THAT(Locs, ElementsAre(Sym(
"Proto", CodeGenLoc, CodeGenLoc)));
227 auto CodeGenLoc = SymbolHeader.range(
"f");
228 EXPECT_THAT(Locs, ElementsAre(Sym(
"func", CodeGenLoc, CodeGenLoc)));
237 const char *Tests[] = {
238 R
"cpp(// Local variable 248 struct [[MyClass]] {}; 251 ns1::My^Class* Params; 255 R"cpp(// Function definition via pointer 262 R"cpp(// Function declaration via call 263 int $decl[[foo]](int); 270 struct Foo { int [[x]]; }; 277 R"cpp(// Field, member initializer 284 R"cpp(// Field, field designator 285 struct Foo { int [[x]]; }; 287 Foo bar = { .^x = 2 }; 292 struct Foo { int $decl[[x]](); }; 300 typedef int $decl[[Foo]]; 306 R"cpp(// Template type parameter 307 template <typename [[T]]> 311 R"cpp(// Template template type parameter 312 template <template<typename> class [[T]]> 313 void foo() { ^T<int> t; } 317 namespace $decl[[ns]] { 318 struct Foo { static void bar(); }; 320 int main() { ^ns::Foo::bar(); } 324 class TTT { public: int a; }; 325 #define [[FF]](S) if (int b = S.a) {} 332 R"cpp(// Macro argument 334 #define ADDRESSOF(X) &X; 335 int *j = ADDRESSOF(^i); 338 R"cpp(// Symbol concatenated inside macro (not supported) 340 #define POINTER(X) p ## X; 341 int i = *POINTER(^i); 344 R"cpp(// Forward class declaration 350 R"cpp(// Function declaration 357 #define FF(name) class name##_Test {}; 359 void f() { my^_Test a; } 363 #define FF() class [[Test]] {}; 365 void f() { T^est a; } 368 R"cpp(// explicit template specialization 369 template <typename T> 370 struct Foo { void bar() {} }; 373 struct [[Foo]]<int> { void bar() {} }; 381 R"cpp(// implicit template specialization 382 template <typename T> 383 struct [[Foo]] { void bar() {} }; 385 struct Foo<int> { void bar() {} }; 392 R"cpp(// partial template specialization 393 template <typename T> 394 struct Foo { void bar() {} }; 395 template <typename T> 396 struct [[Foo]]<T*> { void bar() {} }; 400 R"cpp(// function template specializations 410 R"cpp(// variable template decls 415 double [[var]]<int> = 10; 417 double y = va^r<int>; 420 R"cpp(// No implicit constructors 432 X& $decl[[operator]]++(); 439 R"cpp(// Declaration of explicit template specialization 440 template <typename T> 441 struct $decl[[Foo]] {}; 447 R"cpp(// Declaration of partial template specialization 448 template <typename T> 449 struct $decl[[Foo]] {}; 451 template <typename T> 455 R"cpp(// Heuristic resolution of dependent method 456 template <typename T> 461 template <typename T> 467 R"cpp(// Heuristic resolution of dependent method via this-> 468 template <typename T> 476 R"cpp(// Heuristic resolution of dependent static method 477 template <typename T> 479 static void [[bar]]() {} 482 template <typename T> 488 R"cpp(// Heuristic resolution of dependent method 489 // invoked via smart pointer 490 template <typename> struct S { void [[foo]]() {} }; 491 template <typename T> struct unique_ptr { 494 template <typename T> 495 void test(unique_ptr<S<T>>& V) { 499 for (
const char *Test : Tests) {
501 llvm::Optional<Range> WantDecl;
502 llvm::Optional<Range> WantDef;
503 if (!T.ranges().empty())
504 WantDecl = WantDef = T.range();
505 if (!T.ranges(
"decl").empty())
506 WantDecl = T.range(
"decl");
507 if (!T.ranges(
"def").empty())
508 WantDef = T.range(
"def");
515 TU.ExtraArgs.push_back(
"-fno-delayed-template-parsing");
517 auto AST = TU.build();
518 for (
auto &D :
AST.getDiagnostics())
520 ASSERT_TRUE(
AST.getDiagnostics().empty()) << Test;
525 EXPECT_THAT(Results, IsEmpty()) << Test;
527 ASSERT_THAT(Results, ::testing::SizeIs(1)) << Test;
528 EXPECT_EQ(Results[0].PreferredDeclaration.range, *WantDecl) << Test;
529 llvm::Optional<Range> GotDef;
531 GotDef = Results[0].Definition->range;
532 EXPECT_EQ(WantDef, GotDef) << Test;
540 TEST(LocateSymbol, Warnings) {
541 const char *Tests[] = {
542 R
"cpp(// Field, GNU old-style field designator 543 struct Foo { int [[x]]; }; 545 Foo bar = { ^x : 1 }; 552 int main() { return ^MACRO; } 558 for (
const char *Test : Tests) {
560 llvm::Optional<Range> WantDecl;
561 llvm::Optional<Range> WantDef;
562 if (!T.ranges().empty())
563 WantDecl = WantDef = T.range();
564 if (!T.ranges(
"decl").empty())
565 WantDecl = T.range(
"decl");
566 if (!T.ranges(
"def").empty())
567 WantDef = T.range(
"def");
572 auto AST = TU.build();
576 EXPECT_THAT(Results, IsEmpty()) << Test;
578 ASSERT_THAT(Results, ::testing::SizeIs(1)) << Test;
579 EXPECT_EQ(Results[0].PreferredDeclaration.range, *WantDecl) << Test;
580 llvm::Optional<Range> GotDef;
582 GotDef = Results[0].Definition->range;
583 EXPECT_EQ(WantDef, GotDef) << Test;
588 TEST(LocateSymbol, Ambiguous) {
589 auto T = Annotations(R
"cpp( 593 $ConstructorLoc[[Foo]](const char*); 601 const char* str = "123"; 609 Foo foox = Fo$9^o("asdf"); 610 Foo abcde$10^("asdf"); 611 Foo foox2 = Foo$11^("asdf"); 614 template <typename T> 616 void $NonstaticOverload1[[bar]](int); 617 void $NonstaticOverload2[[bar]](float); 619 static void $StaticOverload1[[baz]](int); 620 static void $StaticOverload2[[baz]](float); 623 template <typename T, typename U> 624 void dependent_call(S<T> s, U u) { 632 TU.
ExtraArgs.push_back(
"-fno-delayed-template-parsing");
633 auto AST = TU.build();
648 ElementsAre(Sym(
"Foo", T.range(
"ConstructorLoc"))));
650 ElementsAre(Sym(
"Foo", T.range(
"ConstructorLoc"))));
655 UnorderedElementsAre(Sym(
"bar", T.range(
"NonstaticOverload1")),
656 Sym(
"bar", T.range(
"NonstaticOverload2"))));
658 UnorderedElementsAre(Sym(
"baz", T.range(
"StaticOverload1")),
659 Sym(
"baz", T.range(
"StaticOverload2"))));
662 TEST(LocateSymbol, TemplateTypedefs) {
663 auto T = Annotations(R
"cpp( 664 template <class T> struct function {}; 665 template <class T> using callback = function<T()>; 673 TEST(LocateSymbol, RelPathsInCompileCommand) {
677 Annotations SourceAnnotations(R
"cpp( 678 #include "header_in_preamble.h" 680 #include "header_not_in_preamble.h" 681 int baz = f$p1^oo + bar_pre$p2^amble + bar_not_pre$p3^amble; 684 Annotations HeaderInPreambleAnnotations(R"cpp( 685 int [[bar_preamble]]; 688 Annotations HeaderNotInPreambleAnnotations(R"cpp( 689 int [[bar_not_preamble]]; 694 SmallString<32> RelPathPrefix(
"..");
695 llvm::sys::path::append(RelPathPrefix,
"src");
696 std::string BuildDir =
testPath(
"build");
697 MockCompilationDatabase CDB(BuildDir, RelPathPrefix);
704 auto FooCpp =
testPath(
"src/foo.cpp");
705 FS.Files[FooCpp] =
"";
706 auto HeaderInPreambleH =
testPath(
"src/header_in_preamble.h");
707 FS.Files[HeaderInPreambleH] = HeaderInPreambleAnnotations.code();
708 auto HeaderNotInPreambleH =
testPath(
"src/header_not_in_preamble.h");
709 FS.Files[HeaderNotInPreambleH] = HeaderNotInPreambleAnnotations.code();
716 EXPECT_TRUE(
bool(Locations)) <<
"findDefinitions returned an error";
717 EXPECT_THAT(*Locations, ElementsAre(Sym(
"foo", SourceAnnotations.range())));
721 EXPECT_TRUE(
bool(Locations)) <<
"findDefinitions returned an error";
724 ElementsAre(Sym(
"bar_preamble", HeaderInPreambleAnnotations.range())));
728 EXPECT_TRUE(
bool(Locations)) <<
"findDefinitions returned an error";
729 EXPECT_THAT(*Locations,
730 ElementsAre(Sym(
"bar_not_preamble",
731 HeaderNotInPreambleAnnotations.range())));
737 MockCompilationDatabase CDB;
741 const char *SourceContents = R
"cpp( 742 #include ^"$2^foo.h$3^" 743 #include "$4^invalid.h" 747 #in$5^clude "$6^foo.h"$7^ 749 Annotations SourceAnnotations(SourceContents); 750 FS.Files[FooCpp] = SourceAnnotations.code(); 756 Annotations HeaderAnnotations(HeaderContents); 757 FS.Files[FooH] = HeaderAnnotations.code(); 759 Server.addDocument(FooH, HeaderAnnotations.code()); 760 Server.addDocument(FooCpp, SourceAnnotations.code()); 764 ASSERT_TRUE(
bool(Locations)) <<
"locateSymbolAt returned an error";
765 EXPECT_THAT(*Locations, ElementsAre(Sym(
"foo.h", HeaderAnnotations.range())));
769 ASSERT_TRUE(
bool(Locations)) <<
"locateSymbolAt returned an error";
770 EXPECT_THAT(*Locations, ElementsAre(Sym(
"foo.h", HeaderAnnotations.range())));
773 ASSERT_TRUE(
bool(Locations)) <<
"locateSymbolAt returned an error";
774 EXPECT_THAT(*Locations, ElementsAre(Sym(
"foo.h", HeaderAnnotations.range())));
778 ASSERT_TRUE(
bool(Locations)) <<
"locateSymbolAt returned an error";
779 EXPECT_THAT(*Locations, ElementsAre(Sym(
"foo.h", HeaderAnnotations.range())));
783 ASSERT_TRUE(
bool(Locations)) <<
"locateSymbolAt returned an error";
784 EXPECT_THAT(*Locations, IsEmpty());
787 ASSERT_TRUE(
bool(Locations)) <<
"locateSymbolAt returned an error";
788 EXPECT_THAT(*Locations, ElementsAre(Sym(
"foo.h", HeaderAnnotations.range())));
791 ASSERT_TRUE(
bool(Locations)) <<
"locateSymbolAt returned an error";
792 EXPECT_THAT(*Locations, ElementsAre(Sym(
"foo.h", HeaderAnnotations.range())));
795 Annotations ObjC(R
"objc( 799 FS.Files[FooM] = ObjC.code();
801 Server.addDocument(FooM, ObjC.code());
803 ASSERT_TRUE(
bool(Locations)) <<
"locateSymbolAt returned an error";
804 EXPECT_THAT(*Locations, ElementsAre(Sym(
"foo.h", HeaderAnnotations.range())));
807 TEST(LocateSymbol, WithPreamble) {
812 MockCompilationDatabase CDB;
817 Annotations FooWithHeader(R
"cpp(#include "fo^o.h")cpp"); 818 Annotations FooWithoutHeader(R"cpp(double [[fo^o]]();)cpp"); 820 FS.Files[FooCpp] = FooWithHeader.code(); 823 Annotations FooHeader(R
"cpp([[]])cpp"); 824 FS.Files[FooH] = FooHeader.code(); 830 ElementsAre(Sym(
"foo.h", FooHeader.range())));
838 ElementsAre(Sym(
"foo", FooWithoutHeader.range())));
847 ElementsAre(Sym(
"foo", FooWithoutHeader.range())));
850 TEST(FindReferences, WithinAST) {
851 const char *Tests[] = {
852 R
"cpp(// Local variable 865 ns1::[[Fo^o]]* Params; 869 R"cpp(// Forward declaration 888 Foo() : [[foo]](0) {} 897 struct Foo { int [[foo]](); }; 898 int Foo::[[foo]]() {} 925 int main() { [[^ns]]::Foo foo; } 931 #define CAT(X, Y) X##Y 936 TYPE(TYPE([[Foo]])) foo3; 942 #define [[MA^CRO]](X) (X+1) 944 int x = [[MACRO]]([[MACRO]](1)); 948 for (
const char *Test : Tests) {
951 std::vector<Matcher<Location>> ExpectedLocations;
952 for (
const auto &R : T.ranges())
953 ExpectedLocations.push_back(RangeIs(R));
955 ElementsAreArray(ExpectedLocations))
960 TEST(FindReferences, ExplicitSymbols) {
961 const char *Tests[] = {
963 struct Foo { Foo* [[self]]() const; }; 966 if (Foo* T = foo.[[^self]]()) {} // Foo member call expr. 971 struct Foo { Foo(int); }; 974 return [[^b]]; // Foo constructor expr. 983 g([[^f]]()); // Foo constructor expr. 989 void [[foo]](double); 1003 [[a]].operator bool(); 1004 if ([[a^]]) {} // ignore implicit conversion-operator AST node 1008 for (
const char *Test : Tests) {
1009 Annotations T(Test);
1011 std::vector<Matcher<Location>> ExpectedLocations;
1012 for (
const auto &R : T.ranges())
1013 ExpectedLocations.push_back(RangeIs(R));
1014 ASSERT_THAT(ExpectedLocations, Not(IsEmpty()));
1016 ElementsAreArray(ExpectedLocations))
1021 TEST(FindReferences, NeedsIndexForSymbols) {
1022 const char *Header =
"int foo();";
1023 Annotations Main(
"int main() { [[f^oo]](); }");
1025 TU.Code = Main.code();
1026 TU.HeaderCode = Header;
1027 auto AST = TU.build();
1032 ElementsAre(RangeIs(Main.range())));
1033 Annotations IndexedMain(R
"cpp( 1034 int main() { [[f^oo]](); } 1039 IndexedTU.Code = IndexedMain.code();
1040 IndexedTU.Filename =
"Indexed.cpp";
1041 IndexedTU.HeaderCode = Header;
1044 ElementsAre(RangeIs(Main.range()), RangeIs(IndexedMain.range())));
1047 EXPECT_EQ(1u, LimitRefs.References.size());
1048 EXPECT_TRUE(LimitRefs.HasMore);
1051 TU.Code = (
"\n\n" + Main.code()).str();
1053 ElementsAre(RangeIs(Main.range())));
1056 TEST(FindReferences, NeedsIndexForMacro) {
1057 const char *Header =
"#define MACRO(X) (X+1)";
1058 Annotations Main(R
"cpp( 1060 int a = [[MA^CRO]](1); 1064 TU.Code = Main.code(); 1065 TU.HeaderCode = Header; 1066 auto AST = TU.build();
1071 ElementsAre(RangeIs(Main.range())));
1073 Annotations IndexedMain(R
"cpp( 1074 int indexed_main() { 1075 int a = [[MACRO]](1); 1081 IndexedTU.Code = IndexedMain.code();
1082 IndexedTU.Filename =
"Indexed.cpp";
1083 IndexedTU.HeaderCode = Header;
1086 ElementsAre(RangeIs(Main.range()), RangeIs(IndexedMain.range())));
1089 EXPECT_EQ(1u, LimitRefs.References.size());
1090 EXPECT_TRUE(LimitRefs.HasMore);
1093 TEST(FindReferences, NoQueryForLocalSymbols) {
1094 struct RecordingIndex :
public MemIndex {
1095 mutable Optional<llvm::DenseSet<SymbolID>> RefIDs;
1096 bool refs(
const RefsRequest &Req,
1097 llvm::function_ref<
void(
const Ref &)>)
const override {
1109 {
"namespace { int ^x; }",
true},
1110 {
"static int ^x;",
true},
1112 {
"void foo() { int ^x; }",
false},
1113 {
"void foo() { struct ^x{}; }",
false},
1114 {
"auto lambda = []{ int ^x; };",
false},
1116 for (Test T : Tests) {
1117 Annotations
File(T.AnnotatedCode);
1122 EXPECT_NE(Rec.RefIDs,
None) << T.AnnotatedCode;
1124 EXPECT_EQ(Rec.RefIDs,
None) << T.AnnotatedCode;
1128 TEST(GetNonLocalDeclRefs,
All) {
1131 std::vector<llvm::StringRef> ExpectedDecls;
1137 void ^foo(int baz) { 1146 class Foo { public: void foo(); }; 1156 {"Bar",
"Bar::bar",
"Foo",
"Foo::foo"},
1162 class Foo { public: void foo() {} }; 1163 class Bar { public: void bar() {} }; 1174 template <typename T, template<typename> class Q> 1182 for (
const Case &C : Cases) {
1183 Annotations
File(C.AnnotatedCode);
1185 ASSERT_TRUE(
AST.getDiagnostics().empty())
1186 <<
AST.getDiagnostics().begin()->Message;
1187 SourceLocation SL = llvm::cantFail(
1190 const FunctionDecl *FD =
1191 llvm::dyn_cast<FunctionDecl>(&
findDecl(
AST, [SL](
const NamedDecl &ND) {
1192 return ND.getLocation() == SL && llvm::isa<FunctionDecl>(ND);
1194 ASSERT_NE(FD,
nullptr);
1197 std::vector<std::string> Names;
1198 for (
const Decl *D : NonLocalDeclRefs) {
1199 if (
const auto *ND = llvm::dyn_cast<NamedDecl>(D))
1200 Names.push_back(ND->getQualifiedNameAsString());
1202 EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls))
1208 Annotations MainCpp(R
"cpp( 1209 #include $foo[["foo.h"]] 1210 int end_of_preamble = 0; 1211 #include $bar[["bar.h"]] 1215 TU.Code = MainCpp.code(); 1216 TU.AdditionalFiles = {{"foo.h",
""}, {
"bar.h",
""}};
1217 auto AST = TU.build();
1222 DocumentLink({MainCpp.range(
"foo"),
1224 DocumentLink({MainCpp.range(
"bar"),
const FunctionDecl * Decl
Diagnostics must be generated for this snapshot.
std::vector< DocumentLink > getDocumentLinks(ParsedAST &AST)
Get all document links.
llvm::Expected< std::vector< LocatedSymbol > > runLocateSymbolAt(ClangdServer &Server, PathRef File, Position Pos)
llvm::StringRef PathRef
A typedef to represent a ref to file path.
std::vector< CodeCompletionResult > Results
ReferencesResult findReferences(ParsedAST &AST, Position Pos, uint32_t Limit, const SymbolIndex *Index)
Returns references of the symbol at a specified Pos.
static Options optsForTest()
Documents should not be synced at all.
llvm::Expected< SourceLocation > sourceLocationInMainFile(const SourceManager &SM, Position P)
Return the file location, corresponding to P.
std::vector< const char * > ExtraArgs
TEST(BackgroundQueueTest, Priority)
std::string testPath(PathRef File)
virtual void onDiagnosticsReady(PathRef File, std::vector< Diag > Diagnostics)=0
Called by ClangdServer when Diagnostics for File are ready.
static URIForFile canonicalize(llvm::StringRef AbsPath, llvm::StringRef TUPath)
Canonicalizes AbsPath via URI.
static constexpr llvm::StringLiteral Name
std::vector< DocumentHighlight > findDocumentHighlights(ParsedAST &AST, Position Pos)
Returns highlights for all usages of a symbol at Pos.
static TestTU withCode(llvm::StringRef Code)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
CharSourceRange Range
SourceRange for the file name.
std::vector< const char * > Expected
IgnoreDiagnostics DiagConsumer
std::vector< LocatedSymbol > locateSymbolAt(ParsedAST &AST, Position Pos, const SymbolIndex *Index)
Get definition of symbol at a specified Pos.
std::vector< HeaderEntry > HeaderContents
std::string AnnotatedCode
llvm::DenseSet< const Decl * > getNonLocalDeclRefs(ParsedAST &AST, const FunctionDecl *FD)
Returns all decls that are referenced in the FD except local symbols.
const NamedDecl & findDecl(ParsedAST &AST, llvm::StringRef QName)
void runAddDocument(ClangdServer &Server, PathRef File, llvm::StringRef Contents, WantDiagnostics WantDiags)
const SymbolIndex * Index