hokein created this revision.
hokein added a reviewer: ioeric.
hokein added a subscriber: cfe-commits.

https://reviews.llvm.org/D25598

Files:
  clang-move/ClangMove.cpp
  test/clang-move/Inputs/test.cpp
  test/clang-move/Inputs/test.h
  test/clang-move/move-class.cpp


Index: test/clang-move/move-class.cpp
===================================================================
--- test/clang-move/move-class.cpp
+++ 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: test/clang-move/Inputs/test.h
===================================================================
--- test/clang-move/Inputs/test.h
+++ test/clang-move/Inputs/test.h
@@ -2,5 +2,6 @@
 class Foo {
 public:
   int f();
+  int f2(int a, int b);
 };
 } // namespace a
Index: test/clang-move/Inputs/test.cpp
===================================================================
--- test/clang-move/Inputs/test.cpp
+++ 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-move/ClangMove.cpp
===================================================================
--- clang-move/ClangMove.cpp
+++ 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: test/clang-move/move-class.cpp
===================================================================
--- test/clang-move/move-class.cpp
+++ 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: test/clang-move/Inputs/test.h
===================================================================
--- test/clang-move/Inputs/test.h
+++ test/clang-move/Inputs/test.h
@@ -2,5 +2,6 @@
 class Foo {
 public:
   int f();
+  int f2(int a, int b);
 };
 } // namespace a
Index: test/clang-move/Inputs/test.cpp
===================================================================
--- test/clang-move/Inputs/test.cpp
+++ 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-move/ClangMove.cpp
===================================================================
--- clang-move/ClangMove.cpp
+++ 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);
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to