https://github.com/HighCommander4 created https://github.com/llvm/llvm-project/pull/124515
None >From fa75210dc704848727f0822e84d1c3e6c8f0738f Mon Sep 17 00:00:00 2001 From: Nathan Ridge <zeratul...@hotmail.com> Date: Mon, 27 Jan 2025 02:14:13 -0500 Subject: [PATCH] [clang][Sema] Handle dependent qualifier in HeuristicResolver::resolveDeclRefExpr() --- clang/lib/Sema/HeuristicResolver.cpp | 5 +++-- .../unittests/Sema/HeuristicResolverTest.cpp | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/HeuristicResolver.cpp b/clang/lib/Sema/HeuristicResolver.cpp index e893afed71d268..87c7274e7aefa6 100644 --- a/clang/lib/Sema/HeuristicResolver.cpp +++ b/clang/lib/Sema/HeuristicResolver.cpp @@ -262,8 +262,9 @@ std::vector<const NamedDecl *> HeuristicResolverImpl::resolveMemberExpr( std::vector<const NamedDecl *> HeuristicResolverImpl::resolveDeclRefExpr(const DependentScopeDeclRefExpr *RE) { - return resolveDependentMember(QualType(RE->getQualifier()->getAsType(), 0), - RE->getDeclName(), StaticFilter); + return resolveDependentMember( + resolveNestedNameSpecifierToType(RE->getQualifier()), RE->getDeclName(), + StaticFilter); } std::vector<const NamedDecl *> diff --git a/clang/unittests/Sema/HeuristicResolverTest.cpp b/clang/unittests/Sema/HeuristicResolverTest.cpp index 2b775b11719ea7..e5cd1254d75422 100644 --- a/clang/unittests/Sema/HeuristicResolverTest.cpp +++ b/clang/unittests/Sema/HeuristicResolverTest.cpp @@ -385,6 +385,27 @@ TEST(HeuristicResolver, DeclRefExpr_RespectScope) { dependentScopeDeclRefExpr(hasDependentName("getPointer")).bind("input")); } +TEST(HeuristicResolver, DeclRefExpr_Nested) { + std::string Code = R"cpp( + struct S { + static int Waldo; + }; + template <typename T> + struct Meta { + using Type = S; + }; + template <typename T> + void foo() { + Meta<T>::Type::Waldo; + } + )cpp"; + // Test resolution of "Waldo" in "Meta<T>::Type::Waldo". + expectResolution( + Code, &HeuristicResolver::resolveDeclRefExpr, + dependentScopeDeclRefExpr(hasDependentName("Waldo")).bind("input"), + varDecl(hasName("Waldo")).bind("output")); +} + TEST(HeuristicResolver, DependentNameType) { std::string Code = R"cpp( template <typename> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits