[PATCH] D111039: [clangd] Include refs of base method in refs for derived method.

Utkarsh Saxena via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 5 01:13:31 PDT 2021


usaxena95 updated this revision to Diff 377111.
usaxena95 marked 3 inline comments as done.
usaxena95 added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111039

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp


Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -1780,11 +1780,12 @@
         AllOf(RangeIs(R), AttrsAre(ReferencesResult::Declaration |
                                    ReferencesResult::Definition |
                                    ReferencesResult::Override)));
-  EXPECT_THAT(
-      findReferences(AST, T.point(), 0, UseIndex ? TU.index().get() : nullptr)
-          .References,
-      UnorderedElementsAreArray(ExpectedLocations))
-      << Test;
+  for (const auto &P : T.points())
+    EXPECT_THAT(findReferences(AST, P, 0, UseIndex ? TU.index().get() : nullptr)
+                    .References,
+                UnorderedElementsAreArray(ExpectedLocations))
+        << "Failed for Refs at " << P << "\n"
+        << Test;
 }
 
 TEST(FindReferences, WithinAST) {
@@ -1961,7 +1962,7 @@
       R"cpp(
         class Base {
         public:
-          virtual void $decl[[f^unc]]() = 0;
+          virtu^al void $decl[[f^unc]]() ^= ^0;
         };
         class Derived : public Base {
         public:
@@ -1990,13 +1991,13 @@
         };
         class Derived : public Base {
         public:
-          void $decl[[fu^nc]]() override;
+          void $decl[[fu^nc]]() over^ride;
         };
         void test(BaseBase* BB, Base* B, Derived* D) {
           // refs to overridden methods in complete type hierarchy are reported.
           BB->[[func]]();
           B->[[func]]();
-          D->[[func]]();
+          D->[[fu^nc]]();
         })cpp";
   checkFindRefs(Test, /*UseIndex=*/true);
 }
Index: clang-tools-extra/clangd/XRefs.cpp
===================================================================
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1392,10 +1392,8 @@
         // references to all overridden methods in complete type hierarchy.
         if (const auto *CMD = llvm::dyn_cast<CXXMethodDecl>(ND)) {
           if (CMD->isVirtual())
-            if (IdentifierAtCursor && SM.getSpellingLoc(CMD->getLocation()) ==
-                                          IdentifierAtCursor->location()) {
-              if (auto ID = getSymbolID(CMD))
-                OverriddenBy.Subjects.insert(ID);
+            if (auto ID = getSymbolID(CMD)) {
+              OverriddenBy.Subjects.insert(ID);
               getOverriddenMethods(CMD, OverriddenMethods);
             }
         }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111039.377111.patch
Type: text/x-patch
Size: 2531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211005/16dd437a/attachment-0001.bin>


More information about the cfe-commits mailing list