diff --git a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp index 639add8f5c4beb..cf2373d43389d2 100644 --- a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp +++ b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp @@ -84,6 +84,10 @@ class ASTWalker : public RecursiveASTVisitor { report(E->getMemberLoc(), getMemberProvider(Type)); return true; } + bool VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E) { + report(E->getMemberLoc(), getMemberProvider(E->getBaseType())); + return true; + } bool VisitCXXConstructExpr(CXXConstructExpr *E) { report(E->getLocation(), E->getConstructor(), diff --git a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp index cb41ebb35cd588..2a2fbc438ab9b5 100644 --- a/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp +++ b/clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp @@ -229,6 +229,13 @@ TEST(WalkAST, MemberExprs) { namespace ns { template struct Foo { int a; }; } using ns::$explicit^Foo;)cpp", "void k(Foo b) { b.^a; }"); + // Test the dependent-type case (CXXDependentScopeMemberExpr) + testWalk("template struct $explicit^Base { void method(); };", + "template void k(Base t) { t.^method(); }"); + testWalk("template struct $explicit^Base { void method(); };", + "template void k(Base& t) { t.^method(); }"); + testWalk("template struct $explicit^Base { void method(); };", + "template void k(Base* t) { t->^method(); }"); } TEST(WalkAST, ConstructExprs) {