Building on the new TraverseOffsetOfNode hook in RecursiveASTVisitor and
the OffsetOfNode DynTypedNode kind, teach SelectionTree, FindTarget, and
the explicit-references collector to address each designator component
individually. Cursor positions inside a nested designator (for example
the 'B' in __builtin_offsetof(A, B.c)) now resolve to the corresponding
field instead of always picking the innermost component.
- SelectionTree: wrap each OffsetOfNode visit in traverseNode so it
becomes a selectable node alongside its enclosing OffsetOfExpr.
- FindTarget::allTargetDecls: resolve OffsetOfNode (Field kind) to its
FieldDecl, and drop the OffsetOfExpr fallback so non-component
selections do not guess a field target.
- ExplicitReferenceCollector: emit one ReferenceLoc per component via a
new VisitOffsetOfNode hook, replacing the manual component loop in
refInStmt.
Tests:
- TargetDeclTest.OffsetOf: precise resolution for outer/inner/base/
identifier components, macro form, array index expressions, and
non-component selections.
- Hover.All and Hover.OffsetOfBuiltin: field cases for nested offsetof,
and expression hover on the builtin token.
- LocateSymbol.All: simple, outer, inner, macro, inherited-field, and
builtin-token cases.
- AllRefsInFoo: existing offsetof cases continue to pass via the new
per-component VisitOffsetOfNode path.
Context:
https://github.com/llvm/llvm-project/pull/194122https://github.com/llvm/llvm-project/pull/192953