[clangd] Add missing GoToStmt in FindTarget.

Summary: so that go-to-def on label can work.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77715
This commit is contained in:
Haojian Wu 2020-04-08 11:03:50 +02:00
parent 7e62684251
commit a533b03028
2 changed files with 24 additions and 0 deletions

View File

@ -331,6 +331,14 @@ public:
break;
}
}
void VisitGotoStmt(const GotoStmt *Goto) {
if (auto *LabelDecl = Goto->getLabel())
Outer.add(LabelDecl, Flags);
}
void VisitLabelStmt(const LabelStmt *Label) {
if (auto *LabelDecl = Label->getDecl())
Outer.add(LabelDecl, Flags);
}
void
VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
const Type *BaseType = E->getBaseType().getTypePtrOrNull();

View File

@ -130,6 +130,22 @@ TEST_F(TargetDeclTest, Exprs) {
}
)cpp";
EXPECT_DECLS("CXXOperatorCallExpr", "void operator()(int n)");
Code = R"cpp(
void test() {
goto [[label]];
label:
return;
}
)cpp";
EXPECT_DECLS("GotoStmt", "label:");
Code = R"cpp(
void test() {
[[label]]:
return;
}
)cpp";
EXPECT_DECLS("LabelStmt", "label:");
}
TEST_F(TargetDeclTest, Recovery) {