return V.Refs;
}
-llvm::SmallVector<ReferenceLoc, 2> refInExpr(const Expr *E) {
+llvm::SmallVector<ReferenceLoc, 2> refInStmt(const Stmt *S) {
struct Visitor : ConstStmtVisitor<Visitor> {
// FIXME: handle more complicated cases: more ObjC, designated initializers.
llvm::SmallVector<ReferenceLoc, 2> Refs;
/*IsDecl=*/false, std::move(Targets)});
}
}
+
+ void VisitGotoStmt(const GotoStmt *GS) {
+ llvm::SmallVector<const NamedDecl *, 1> Targets;
+ if (const auto *L = GS->getLabel())
+ Targets.push_back(L);
+ Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(), GS->getLabelLoc(),
+ /*IsDecl=*/false, std::move(Targets)});
+ }
+
+ void VisitLabelStmt(const LabelStmt *LS) {
+ Refs.push_back(ReferenceLoc{NestedNameSpecifierLoc(),
+ LS->getIdentLoc(),
+ /*IsDecl=*/true,
+ {LS->getDecl()}});
+ }
};
Visitor V;
- V.Visit(E);
+ V.Visit(S);
return V.Refs;
}
return RecursiveASTVisitor::TraverseElaboratedTypeLoc(L);
}
- bool VisitExpr(Expr *E) {
- visitNode(DynTypedNode::create(*E));
+ bool VisitStmt(Stmt *S) {
+ visitNode(DynTypedNode::create(*S));
return true;
}
llvm::SmallVector<ReferenceLoc, 2> explicitReference(DynTypedNode N) {
if (auto *D = N.get<Decl>())
return refInDecl(D);
- if (auto *E = N.get<Expr>())
- return refInExpr(E);
+ if (auto *S = N.get<Stmt>())
+ return refInStmt(S);
if (auto *NNSL = N.get<NestedNameSpecifierLoc>()) {
// (!) 'DeclRelation::Alias' ensures we do not loose namespace aliases.
return {ReferenceLoc{
"6: targets = {a::b::S}\n"
"7: targets = {a::b::S::type}, qualifier = 'struct S::'\n"
"8: targets = {y}, decl\n"},
+ {R"cpp(
+ void foo() {
+ $0^ten: // PRINT "HELLO WORLD!"
+ goto $1^ten;
+ }
+ )cpp",
+ "0: targets = {ten}, decl\n"
+ "1: targets = {ten}\n"},
// Simple templates.
{R"cpp(
template <class T> struct vector { using value_type = T; };