-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[clang][Sema] Handle dependent qualifier in HeuristicResolver::resolveDeclRefExpr() #124515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-clang Author: Nathan Ridge (HighCommander4) ChangesFull diff: https://github.com/llvm/llvm-project/pull/124515.diff 2 Files Affected:
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>
|
|
(This is something I noticed while working on the improvements discussed here. Sending out separately to keep things small and easy to review.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/42/builds/2985 Here is the relevant piece of the build log for the reference |
No description provided.