https://github.com/HighCommander4 updated https://github.com/llvm/llvm-project/pull/132576
>From ac3780d5f747c8c063119a028a4735c725198003 Mon Sep 17 00:00:00 2001 From: Nathan Ridge <zeratul...@hotmail.com> Date: Sat, 22 Mar 2025 20:54:02 -0400 Subject: [PATCH] [clang][HeuristicResolver] Apply default argument heuristic in resolveDeclRefExpr as well --- .../clangd/unittests/XRefsTests.cpp | 2 +- clang/lib/Sema/HeuristicResolver.cpp | 6 +++--- clang/unittests/Sema/HeuristicResolverTest.cpp | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/clangd/unittests/XRefsTests.cpp b/clang-tools-extra/clangd/unittests/XRefsTests.cpp index e12d7691c58fb..693e965e78a96 100644 --- a/clang-tools-extra/clangd/unittests/XRefsTests.cpp +++ b/clang-tools-extra/clangd/unittests/XRefsTests.cpp @@ -1091,7 +1091,7 @@ TEST(LocateSymbol, All) { )objc", R"cpp( struct PointerIntPairInfo { - static void *getPointer(void *Value); + static void *$decl[[getPointer]](void *Value); }; template <typename Info = PointerIntPairInfo> struct PointerIntPair { diff --git a/clang/lib/Sema/HeuristicResolver.cpp b/clang/lib/Sema/HeuristicResolver.cpp index eb9b9c86661b4..0c67f1f2a3878 100644 --- a/clang/lib/Sema/HeuristicResolver.cpp +++ b/clang/lib/Sema/HeuristicResolver.cpp @@ -315,9 +315,9 @@ std::vector<const NamedDecl *> HeuristicResolverImpl::resolveMemberExpr( std::vector<const NamedDecl *> HeuristicResolverImpl::resolveDeclRefExpr(const DependentScopeDeclRefExpr *RE) { - return resolveDependentMember( - resolveNestedNameSpecifierToType(RE->getQualifier()), RE->getDeclName(), - StaticFilter); + QualType Qualifier = resolveNestedNameSpecifierToType(RE->getQualifier()); + Qualifier = simplifyType(Qualifier, nullptr, /*UnwrapPointer=*/false); + return resolveDependentMember(Qualifier, RE->getDeclName(), StaticFilter); } std::vector<const NamedDecl *> diff --git a/clang/unittests/Sema/HeuristicResolverTest.cpp b/clang/unittests/Sema/HeuristicResolverTest.cpp index f7eb4b23c2ab0..3ed6bba790be3 100644 --- a/clang/unittests/Sema/HeuristicResolverTest.cpp +++ b/clang/unittests/Sema/HeuristicResolverTest.cpp @@ -463,6 +463,23 @@ TEST(HeuristicResolver, DeclRefExpr_StaticMethod) { cxxMethodDecl(hasName("bar")).bind("output")); } +TEST(HeuristicResolver, DeclRefExpr_DefaultTemplateArgument) { + std::string Code = R"cpp( + struct Default { + static void foo(); + }; + template <typename T = Default> + void bar() { + T::foo(); + } + )cpp"; + // Test resolution of "foo" in "T::foo()". + expectResolution( + Code, &HeuristicResolver::resolveDeclRefExpr, + dependentScopeDeclRefExpr(hasDependentName("foo")).bind("input"), + cxxMethodDecl(hasName("foo")).bind("output")); +} + TEST(HeuristicResolver, DeclRefExpr_StaticOverloads) { std::string Code = R"cpp( template <typename T> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits