[all-commits] [llvm/llvm-project] bcc5d9: [clangd] Resolve __builtin_offsetof designator com...

Jakob Linke via All-commits all-commits at lists.llvm.org
Tue Apr 28 21:39:41 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bcc5d96cccaed8a6c9f42f0c751f129ac4c4cbe8
      https://github.com/llvm/llvm-project/commit/bcc5d96cccaed8a6c9f42f0c751f129ac4c4cbe8
  Author: Jakob Linke <jakob at linke.cx>
  Date:   2026-04-29 (Wed, 29 Apr 2026)

  Changed paths:
    M clang-tools-extra/clangd/FindTarget.cpp
    M clang-tools-extra/clangd/Selection.cpp
    M clang-tools-extra/clangd/unittests/FindTargetTests.cpp
    M clang-tools-extra/clangd/unittests/HoverTests.cpp
    M clang-tools-extra/clangd/unittests/XRefsTests.cpp

  Log Message:
  -----------
  [clangd] Resolve __builtin_offsetof designator components precisely (#194407)

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/194122
https://github.com/llvm/llvm-project/pull/192953



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list