[PATCH] D104376: [clangd] Correct SelectionTree behavior around anonymous field access.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 17 09:18:52 PDT 2021


sammccall added inline comments.


================
Comment at: clang-tools-extra/clangd/Selection.cpp:71
+  // so we reduce its range to match the CXXConstructExpr.
+  // (It's not clear that changing the clang AST would be correct in general).
+  if (const auto *ME = N.get<MemberExpr>()) {
----------------
hokein wrote:
> I still think it is worth to explore this direction (will take a look on this if I have time), but also ok with the current approach. 
SG, this isn't urgent so I'll leave this open while out on vacation. I agree it's suspect/suggestive that we need to override the AST source range in exactly one case.

My concern was conceptual: in `A().b` if you want to describe where the anon field ref happens, I'd pick `.` or `b` so placing those outside the range is suspect. Conversely a range of `A()` seems weird because that's a perfectly valid expression with no dereferencing.

OTOH if you squint I guess this looks a bit like an implicit cast from the `A` to the anon member. So maybe it's fine and just a question of mental model.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104376/new/

https://reviews.llvm.org/D104376



More information about the cfe-commits mailing list