This revision was automatically updated to reflect the committed changes. Closed by commit rG0e545816a9e5: [include-cleaner] Handle dependent type members in AST. (authored by VitaNuo).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D139409/new/ https://reviews.llvm.org/D139409 Files: clang-tools-extra/include-cleaner/lib/WalkAST.cpp clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp =================================================================== --- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp +++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp @@ -229,6 +229,13 @@ namespace ns { template<typename> struct Foo { int a; }; } using ns::$explicit^Foo;)cpp", "void k(Foo<int> b) { b.^a; }"); + // Test the dependent-type case (CXXDependentScopeMemberExpr) + testWalk("template<typename T> struct $explicit^Base { void method(); };", + "template<typename T> void k(Base<T> t) { t.^method(); }"); + testWalk("template<typename T> struct $explicit^Base { void method(); };", + "template<typename T> void k(Base<T>& t) { t.^method(); }"); + testWalk("template<typename T> struct $explicit^Base { void method(); };", + "template<typename T> void k(Base<T>* t) { t->^method(); }"); } TEST(WalkAST, ConstructExprs) { Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp =================================================================== --- clang-tools-extra/include-cleaner/lib/WalkAST.cpp +++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp @@ -84,6 +84,10 @@ 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(),
Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp =================================================================== --- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp +++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp @@ -229,6 +229,13 @@ namespace ns { template<typename> struct Foo { int a; }; } using ns::$explicit^Foo;)cpp", "void k(Foo<int> b) { b.^a; }"); + // Test the dependent-type case (CXXDependentScopeMemberExpr) + testWalk("template<typename T> struct $explicit^Base { void method(); };", + "template<typename T> void k(Base<T> t) { t.^method(); }"); + testWalk("template<typename T> struct $explicit^Base { void method(); };", + "template<typename T> void k(Base<T>& t) { t.^method(); }"); + testWalk("template<typename T> struct $explicit^Base { void method(); };", + "template<typename T> void k(Base<T>* t) { t->^method(); }"); } TEST(WalkAST, ConstructExprs) { Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp =================================================================== --- clang-tools-extra/include-cleaner/lib/WalkAST.cpp +++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp @@ -84,6 +84,10 @@ 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(),
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits