summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2016-10-14 10:07:58 +0000
committerHaojian Wu <hokein@google.com>2016-10-14 10:07:58 +0000
commit7bd492c53a6cafcefaa968fdc1f18416b58cb17c (patch)
treef6b83d9665ff26cf86bf830d90a3d5a9f89aff23
parent86e72d98dd4e5f7c60cf4e52b885b2980ebc0c5e (diff)
downloadbcm5719-llvm-7bd492c53a6cafcefaa968fdc1f18416b58cb17c.tar.gz
bcm5719-llvm-7bd492c53a6cafcefaa968fdc1f18416b58cb17c.zip
[clang-move] Matching static class member more correctly.
Reviewers: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25598 llvm-svn: 284221
-rw-r--r--clang-tools-extra/clang-move/ClangMove.cpp8
-rw-r--r--clang-tools-extra/test/clang-move/Inputs/test.cpp3
-rw-r--r--clang-tools-extra/test/clang-move/Inputs/test.h1
-rw-r--r--clang-tools-extra/test/clang-move/move-class.cpp2
4 files changed, 13 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-move/ClangMove.cpp b/clang-tools-extra/clang-move/ClangMove.cpp
index a741f559ece..af1711ce5e2 100644
--- a/clang-tools-extra/clang-move/ClangMove.cpp
+++ b/clang-tools-extra/clang-move/ClangMove.cpp
@@ -24,6 +24,11 @@ namespace clang {
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 @@ void ClangMoveTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
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);
diff --git a/clang-tools-extra/test/clang-move/Inputs/test.cpp b/clang-tools-extra/test/clang-move/Inputs/test.cpp
index 65997abbdb7..fa777f01b95 100644
--- a/clang-tools-extra/test/clang-move/Inputs/test.cpp
+++ b/clang-tools-extra/test/clang-move/Inputs/test.cpp
@@ -5,4 +5,7 @@ namespace a {
int Foo::f() {
return 0;
}
+int Foo::f2(int a, int b) {
+ return a + b;
+}
} // namespace a
diff --git a/clang-tools-extra/test/clang-move/Inputs/test.h b/clang-tools-extra/test/clang-move/Inputs/test.h
index 8ff3316f021..9d0073a0d15 100644
--- a/clang-tools-extra/test/clang-move/Inputs/test.h
+++ b/clang-tools-extra/test/clang-move/Inputs/test.h
@@ -2,5 +2,6 @@ namespace a {
class Foo {
public:
int f();
+ int f2(int a, int b);
};
} // namespace a
diff --git a/clang-tools-extra/test/clang-move/move-class.cpp b/clang-tools-extra/test/clang-move/move-class.cpp
index 56aad1b92dc..cfe0d0fbd37 100644
--- a/clang-tools-extra/test/clang-move/move-class.cpp
+++ b/clang-tools-extra/test/clang-move/move-class.cpp
@@ -25,6 +25,7 @@
// 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
//
@@ -32,6 +33,7 @@
// 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"
OpenPOWER on IntegriCloud