[clang] [Clang][ASTMatcher] Add a matcher for the name of a DependentScopeDeclRefExpr (PR #121656)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 4 17:55:01 PST 2025


================
@@ -2235,6 +2235,21 @@ TEST_P(ASTMatchersTest, ArgumentCountIs_CXXConstructExpr) {
                  Constructor1Arg));
 }
 
+TEST_P(ASTMatchersTest, hasDependentName_DependentScopeDeclRefExpr) {
+  if (!GetParam().isCXX() || GetParam().hasDelayedTemplateParsing()) {
+    // FIXME: Fix this test to work with delayed template parsing.
+    return;
+  }
+
+  EXPECT_TRUE(matches("template <class T> class X : T { void f() { T::v; } };",
+                      dependentScopeDeclRefExpr(hasDependentName("v"))));
+
+  EXPECT_TRUE(
----------------
HighCommander4 wrote:

It would be nice to have a test case where the dependent name refers to a function (specifically a static member function, since I think that will get a `DependentScopeDeclRefExpr` rather than a `CXXDepdendentScopeMemberExpr`).

Come to think of it, this applies for the test for `dependentScopeDeclRefExpr` itself.

https://github.com/llvm/llvm-project/pull/121656


More information about the cfe-commits mailing list