[clang-tools-extra] r284221 - [clang-move] Matching static class member more correctly.
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 14 03:07:58 PDT 2016
Author: hokein
Date: Fri Oct 14 05:07:58 2016
New Revision: 284221
URL: http://llvm.org/viewvc/llvm-project?rev=284221&view=rev
Log:
[clang-move] Matching static class member more correctly.
Reviewers: ioeric
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25598
Modified:
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
Modified: clang-tools-extra/trunk/clang-move/ClangMove.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-move/ClangMove.cpp?rev=284221&r1=284220&r2=284221&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-move/ClangMove.cpp (original)
+++ clang-tools-extra/trunk/clang-move/ClangMove.cpp Fri Oct 14 05:07:58 2016
@@ -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
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);
Modified: clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp?rev=284221&r1=284220&r2=284221&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp (original)
+++ clang-tools-extra/trunk/test/clang-move/Inputs/test.cpp Fri Oct 14 05:07:58 2016
@@ -5,4 +5,7 @@ namespace a {
int Foo::f() {
return 0;
}
+int Foo::f2(int a, int b) {
+ return a + b;
+}
} // namespace a
Modified: clang-tools-extra/trunk/test/clang-move/Inputs/test.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/Inputs/test.h?rev=284221&r1=284220&r2=284221&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-move/Inputs/test.h (original)
+++ clang-tools-extra/trunk/test/clang-move/Inputs/test.h Fri Oct 14 05:07:58 2016
@@ -2,5 +2,6 @@ namespace a {
class Foo {
public:
int f();
+ int f2(int a, int b);
};
} // namespace a
Modified: clang-tools-extra/trunk/test/clang-move/move-class.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-class.cpp?rev=284221&r1=284220&r2=284221&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-move/move-class.cpp (original)
+++ clang-tools-extra/trunk/test/clang-move/move-class.cpp Fri Oct 14 05:07:58 2016
@@ -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"
More information about the cfe-commits
mailing list