llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clangd Author: Nathan Ridge (HighCommander4) <details> <summary>Changes</summary> 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 --- Full diff: https://github.com/llvm/llvm-project/pull/183242.diff 2 Files Affected: - (modified) clang-tools-extra/clangd/Selection.cpp (+4) - (modified) clang-tools-extra/clangd/unittests/XRefsTests.cpp (+10) ``````````diff 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); `````````` </details> https://github.com/llvm/llvm-project/pull/183242 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
