nridge updated this revision to Diff 293047. nridge added a comment. Take a different fix approach, as suggested in the issue discussion
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D87225/new/ https://reviews.llvm.org/D87225 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 @@ -1582,6 +1582,13 @@ f.[[^~]]Foo(); } )cpp", + R"cpp(// Renaming alias + template <typename> class Vector {}; + using [[^X]] = Vector<int>; + [[X]] x1; + Vector<int> x2; + Vector<double> y; + )cpp", }; for (const char *Test : Tests) { Annotations T(Test); Index: clang-tools-extra/clangd/XRefs.cpp =================================================================== --- clang-tools-extra/clangd/XRefs.cpp +++ clang-tools-extra/clangd/XRefs.cpp @@ -1140,11 +1140,18 @@ } else { // Handle references to Decls. - // We also show references to the targets of using-decls, so we include - // DeclRelation::Underlying. - DeclRelationSet Relations = DeclRelation::TemplatePattern | - DeclRelation::Alias | DeclRelation::Underlying; + DeclRelationSet Relations = + DeclRelation::TemplatePattern | DeclRelation::Alias; auto Decls = getDeclAtPosition(AST, *CurLoc, Relations); + // If the results include a *non-renaming* alias, get its + // underlying decls as well. (See similar logic in locateASTReferent()). + for (const NamedDecl *D : Decls) { + if (llvm::isa<UsingDecl>(D) || llvm::isa<UnresolvedUsingValueDecl>(D)) { + Decls = getDeclAtPosition(AST, *CurLoc, + Relations | DeclRelation::Underlying); + break; + } + } // We traverse the AST to find references in the main file. auto MainFileRefs = findRefs(Decls, AST);
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/XRefsTests.cpp +++ clang-tools-extra/clangd/unittests/XRefsTests.cpp @@ -1582,6 +1582,13 @@ f.[[^~]]Foo(); } )cpp", + R"cpp(// Renaming alias + template <typename> class Vector {}; + using [[^X]] = Vector<int>; + [[X]] x1; + Vector<int> x2; + Vector<double> y; + )cpp", }; for (const char *Test : Tests) { Annotations T(Test); Index: clang-tools-extra/clangd/XRefs.cpp =================================================================== --- clang-tools-extra/clangd/XRefs.cpp +++ clang-tools-extra/clangd/XRefs.cpp @@ -1140,11 +1140,18 @@ } else { // Handle references to Decls. - // We also show references to the targets of using-decls, so we include - // DeclRelation::Underlying. - DeclRelationSet Relations = DeclRelation::TemplatePattern | - DeclRelation::Alias | DeclRelation::Underlying; + DeclRelationSet Relations = + DeclRelation::TemplatePattern | DeclRelation::Alias; auto Decls = getDeclAtPosition(AST, *CurLoc, Relations); + // If the results include a *non-renaming* alias, get its + // underlying decls as well. (See similar logic in locateASTReferent()). + for (const NamedDecl *D : Decls) { + if (llvm::isa<UsingDecl>(D) || llvm::isa<UnresolvedUsingValueDecl>(D)) { + Decls = getDeclAtPosition(AST, *CurLoc, + Relations | DeclRelation::Underlying); + break; + } + } // We traverse the AST to find references in the main file. auto MainFileRefs = findRefs(Decls, AST);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits