https://github.com/HighCommander4 created https://github.com/llvm/llvm-project/pull/183242
This is another type loc that overlaps the name of the declarations whose type it is, and so needs special handling to allow the declaration itself to be targeted. Fixes https://github.com/clangd/clangd/issues/2608 >From 8fe911bbff6a932d826b6d3cc1d669e7c6b51710 Mon Sep 17 00:00:00 2001 From: Nathan Ridge <[email protected]> Date: Wed, 25 Feb 2026 00:52:05 -0500 Subject: [PATCH] [clangd] Handle MemberPointerTypeLoc in SelectionTree This is another type loc that overlaps the name of the declarations whose type it is, and so needs special handling to allow the declaration itself to be targeted. Fixes https://github.com/clangd/clangd/issues/2608 --- clang-tools-extra/clangd/Selection.cpp | 4 ++++ clang-tools-extra/clangd/unittests/XRefsTests.cpp | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/clang-tools-extra/clangd/Selection.cpp b/clang-tools-extra/clangd/Selection.cpp index faa00d20497fa..8b2c290309f23 100644 --- a/clang-tools-extra/clangd/Selection.cpp +++ b/clang-tools-extra/clangd/Selection.cpp @@ -954,6 +954,10 @@ class SelectionVisitor : public RecursiveASTVisitor<SelectionVisitor> { claimRange(PTL.getStarLoc(), Result); return; } + if (auto MPTL = TL->getAs<MemberPointerTypeLoc>()) { + claimRange(MPTL.getLocalSourceRange(), Result); + return; + } if (auto FTL = TL->getAs<FunctionTypeLoc>()) { claimRange(SourceRange(FTL.getLParenLoc(), FTL.getEndLoc()), Result); return; diff --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp b/clang-tools-extra/clangd/unittests/XRefsTests.cpp index 4106c6cf7b2d0..796ffd8acce81 100644 --- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp +++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp @@ -2329,6 +2329,16 @@ TEST(FindReferences, WithinAST) { [$(Bar)[[F^oo]]...$(Bar)[[Fo^o]] + 1] = 0, [$(Bar)[[^Foo]] + 2] = 1 }; + )cpp", + // Field of pointer-to-member type + R"cpp( + struct S { void foo(); }; + struct A { + void (S::*$def(A)[[fi^eld]])(); + }; + void bar(A& a, S& s) { + (s.*(a.$(bar)[[field]]))(); + } )cpp"}; for (const char *Test : Tests) checkFindRefs(Test); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
