This revision was automatically updated to reflect the committed changes. Closed by commit rL284221: [clang-move] Matching static class member more correctly. (authored by hokein).
Changed prior to commit: https://reviews.llvm.org/D25598?vs=74633&id=74650#toc Repository: rL LLVM https://reviews.llvm.org/D25598 Files: clang-tools-extra/trunk/clang-move/ClangMove.cpp clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp clang-tools-extra/trunk/test/clang-move/Inputs/test.h clang-tools-extra/trunk/test/clang-move/move-class.cpp Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp =================================================================== --- clang-tools-extra/trunk/clang-move/ClangMove.cpp +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp @@ -24,6 +24,11 @@ namespace move { namespace { +// FIXME: Move to ASTMatchers. +AST_MATCHER(VarDecl, isStaticDataMember) { + return Node.isStaticDataMember(); +} + AST_MATCHER_P(Decl, hasOutermostEnclosingClass, ast_matchers::internal::Matcher<Decl>, InnerMatcher) { const auto* Context = Node.getDeclContext(); @@ -365,7 +370,8 @@ this); // Match static member variable definition of the moved class. - Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition()) + Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition(), + isStaticDataMember()) .bind("class_static_var_decl"), this); Index: clang-tools-extra/trunk/test/clang-move/Inputs/test.h =================================================================== --- clang-tools-extra/trunk/test/clang-move/Inputs/test.h +++ clang-tools-extra/trunk/test/clang-move/Inputs/test.h @@ -2,5 +2,6 @@ class Foo { public: int f(); + int f2(int a, int b); }; } // namespace a Index: clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp +++ clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp @@ -5,4 +5,7 @@ int Foo::f() { return 0; } +int Foo::f2(int a, int b) { + return a + b; +} } // namespace a Index: clang-tools-extra/trunk/test/clang-move/move-class.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-move/move-class.cpp +++ clang-tools-extra/trunk/test/clang-move/move-class.cpp @@ -25,13 +25,15 @@ // CHECK-NEW-TEST-H: class Foo { // CHECK-NEW-TEST-H: public: // CHECK-NEW-TEST-H: int f(); +// CHECK-NEW-TEST-H: int f2(int a, int b); // CHECK-NEW-TEST-H: }; // CHECK-NEW-TEST-H: } // namespace a // // CHECK-NEW-TEST-CPP: #include "{{.*}}new_test.h" // CHECK-NEW-TEST-CPP: #include "test2.h" // CHECK-NEW-TEST-CPP: namespace a { // CHECK-NEW-TEST-CPP: int Foo::f() { return 0; } +// CHECK-NEW-TEST-CPP: int Foo::f2(int a, int b) { return a + b; } // CHECK-NEW-TEST-CPP: } // namespace a // // CHECK-OLD-TEST-CPP: #include "test.h"
Index: clang-tools-extra/trunk/clang-move/ClangMove.cpp =================================================================== --- clang-tools-extra/trunk/clang-move/ClangMove.cpp +++ clang-tools-extra/trunk/clang-move/ClangMove.cpp @@ -24,6 +24,11 @@ namespace move { namespace { +// FIXME: Move to ASTMatchers. +AST_MATCHER(VarDecl, isStaticDataMember) { + return Node.isStaticDataMember(); +} + AST_MATCHER_P(Decl, hasOutermostEnclosingClass, ast_matchers::internal::Matcher<Decl>, InnerMatcher) { const auto* Context = Node.getDeclContext(); @@ -365,7 +370,8 @@ this); // Match static member variable definition of the moved class. - Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition()) + Finder->addMatcher(varDecl(InMovedClass, InOldCC, isDefinition(), + isStaticDataMember()) .bind("class_static_var_decl"), this); Index: clang-tools-extra/trunk/test/clang-move/Inputs/test.h =================================================================== --- clang-tools-extra/trunk/test/clang-move/Inputs/test.h +++ clang-tools-extra/trunk/test/clang-move/Inputs/test.h @@ -2,5 +2,6 @@ class Foo { public: int f(); + int f2(int a, int b); }; } // namespace a Index: clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp +++ clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp @@ -5,4 +5,7 @@ int Foo::f() { return 0; } +int Foo::f2(int a, int b) { + return a + b; +} } // namespace a Index: clang-tools-extra/trunk/test/clang-move/move-class.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-move/move-class.cpp +++ clang-tools-extra/trunk/test/clang-move/move-class.cpp @@ -25,13 +25,15 @@ // CHECK-NEW-TEST-H: class Foo { // CHECK-NEW-TEST-H: public: // CHECK-NEW-TEST-H: int f(); +// CHECK-NEW-TEST-H: int f2(int a, int b); // CHECK-NEW-TEST-H: }; // CHECK-NEW-TEST-H: } // namespace a // // CHECK-NEW-TEST-CPP: #include "{{.*}}new_test.h" // CHECK-NEW-TEST-CPP: #include "test2.h" // CHECK-NEW-TEST-CPP: namespace a { // CHECK-NEW-TEST-CPP: int Foo::f() { return 0; } +// CHECK-NEW-TEST-CPP: int Foo::f2(int a, int b) { return a + b; } // CHECK-NEW-TEST-CPP: } // namespace a // // CHECK-OLD-TEST-CPP: #include "test.h"
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits