[clangd] FindTarget resolves base specifier

FindTarget on the virtual keyword or access specifier of a base specifier will now resolve to type of the base specifier.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D95338
This commit is contained in:
Nathan James 2021-01-26 18:59:29 +00:00
parent d92413a45e
commit 7730599c41
No known key found for this signature in database
GPG Key ID: CC007AFCDA90AA5F
2 changed files with 20 additions and 1 deletions

View File

@ -710,7 +710,8 @@ allTargetDecls(const DynTypedNode &N) {
Finder.add(CCI, Flags); Finder.add(CCI, Flags);
else if (const TemplateArgumentLoc *TAL = N.get<TemplateArgumentLoc>()) else if (const TemplateArgumentLoc *TAL = N.get<TemplateArgumentLoc>())
Finder.add(TAL->getArgument(), Flags); Finder.add(TAL->getArgument(), Flags);
else if (const CXXBaseSpecifier *CBS = N.get<CXXBaseSpecifier>())
Finder.add(CBS->getTypeSourceInfo()->getType(), Flags);
return Finder.takeDecls(); return Finder.takeDecls();
} }

View File

@ -230,6 +230,24 @@ TEST_F(TargetDeclTest, UsingDecl) {
{"void waldo()"}); {"void waldo()"});
} }
TEST_F(TargetDeclTest, BaseSpecifier) {
Code = R"cpp(
struct X {};
struct Y : [[private]] X {};
)cpp";
EXPECT_DECLS("CXXBaseSpecifier", "struct X");
Code = R"cpp(
struct X {};
struct Y : [[private X]] {};
)cpp";
EXPECT_DECLS("CXXBaseSpecifier", "struct X");
Code = R"cpp(
struct X {};
struct Y : private [[X]] {};
)cpp";
EXPECT_DECLS("RecordTypeLoc", "struct X");
}
TEST_F(TargetDeclTest, ConstructorInitList) { TEST_F(TargetDeclTest, ConstructorInitList) {
Code = R"cpp( Code = R"cpp(
struct X { struct X {