Skip to content

Commit ca50409

Browse files
authored
[clangd] Collect references in array designators (#140356)
1 parent ec21b0f commit ca50409

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

clang-tools-extra/clangd/unittests/XRefsTests.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,6 +2311,14 @@ TEST(FindReferences, WithinAST) {
23112311
$(S::deleteObject)[[de^lete]] S;
23122312
}
23132313
};
2314+
)cpp",
2315+
// Array designators
2316+
R"cpp(
2317+
const int $def[[F^oo]] = 0;
2318+
int Bar[] = {
2319+
[$(Bar)[[F^oo]]...$(Bar)[[Fo^o]] + 1] = 0,
2320+
[$(Bar)[[^Foo]] + 2] = 1
2321+
};
23142322
)cpp"};
23152323
for (const char *Test : Tests)
23162324
checkFindRefs(Test);

clang/lib/Index/IndexBody.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,13 @@ class BodyIndexer : public RecursiveASTVisitor<BodyIndexer> {
435435
ParentDC, SymbolRoleSet(),
436436
/*Relations=*/{}, E);
437437
}
438+
} else {
439+
if (D.isArrayDesignator())
440+
TraverseStmt(E->getArrayIndex(D));
441+
else if (D.isArrayRangeDesignator()) {
442+
TraverseStmt(E->getArrayRangeStart(D));
443+
TraverseStmt(E->getArrayRangeEnd(D));
444+
}
438445
}
439446
}
440447
return true;

0 commit comments

Comments
 (0)