summaryrefslogtreecommitdiff
path: root/clang-tools-extra/test/clang-move
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2017-01-17 10:08:11 +0000
committerHaojian Wu <hokein@google.com>2017-01-17 10:08:11 +0000
commit4e0f2ca658d8ca6e535156fabceb4183d41f6afc (patch)
tree4fbb2422b15694ee57b72e37167eb93d407f1979 /clang-tools-extra/test/clang-move
parent9fa67108a59637de196d1dd545b240ba986735d0 (diff)
[clang-move] Ignore using decls which are defined in macros.
Summary: Also ignore helpers which are defined in macro. Currently clang-move doesn't handle macro well enough, especiall for complex macros. This patch will ignore declarations in macros to make the behavior of clang-move more correct. Reviewers: ioeric Reviewed By: ioeric Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28774
Diffstat (limited to 'clang-tools-extra/test/clang-move')
-rw-r--r--clang-tools-extra/test/clang-move/Inputs/macro_helper_test.cpp13
-rw-r--r--clang-tools-extra/test/clang-move/Inputs/macro_helper_test.h2
-rw-r--r--clang-tools-extra/test/clang-move/no-move-macro-helpers.cpp43
3 files changed, 58 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-move/Inputs/macro_helper_test.cpp b/clang-tools-extra/test/clang-move/Inputs/macro_helper_test.cpp
new file mode 100644
index 00000000000..c2c1e1e1aae
--- /dev/null
+++ b/clang-tools-extra/test/clang-move/Inputs/macro_helper_test.cpp
@@ -0,0 +1,13 @@
+#include "macro_helper_test.h"
+
+#define DEFINE(name) \
+ namespace ns { \
+ static const bool t1 = false; \
+ bool t2_##name = t1; \
+ bool t3_##name = t1; \
+ } \
+ using ns::t2_##name;
+
+DEFINE(test)
+
+void f1() {}
diff --git a/clang-tools-extra/test/clang-move/Inputs/macro_helper_test.h b/clang-tools-extra/test/clang-move/Inputs/macro_helper_test.h
new file mode 100644
index 00000000000..0ddfaae3c2f
--- /dev/null
+++ b/clang-tools-extra/test/clang-move/Inputs/macro_helper_test.h
@@ -0,0 +1,2 @@
+class A {};
+void f1();
diff --git a/clang-tools-extra/test/clang-move/no-move-macro-helpers.cpp b/clang-tools-extra/test/clang-move/no-move-macro-helpers.cpp
new file mode 100644
index 00000000000..d0db5a97970
--- /dev/null
+++ b/clang-tools-extra/test/clang-move/no-move-macro-helpers.cpp
@@ -0,0 +1,43 @@
+// RUN: mkdir -p %T/no-move-macro-helper
+// RUN: cp %S/Inputs/macro_helper_test.h %T/no-move-macro-helper/macro_helper_test.h
+// RUN: cp %S/Inputs/macro_helper_test.cpp %T/no-move-macro-helper/macro_helper_test.cpp
+// RUN: cd %T/no-move-macro-helper
+//
+// -----------------------------------------------------------------------------
+// Test no moving helpers in macro.
+// -----------------------------------------------------------------------------
+// RUN: clang-move -names="A" -new_cc=%T/no-move-macro-helper/new_test.cpp -new_header=%T/no-move-macro-helper/new_test.h -old_cc=%T/no-move-macro-helper/macro_helper_test.cpp -old_header=%T/no-move-macro-helper/macro_helper_test.h %T/no-move-macro-helper/macro_helper_test.cpp -- -std=c++11
+// RUN: FileCheck -input-file=%T/no-move-macro-helper/new_test.h -check-prefix=CHECK-NEW-TEST-CASE1-H %s
+// RUN: FileCheck -input-file=%T/no-move-macro-helper/new_test.cpp -check-prefix=CHECK-NEW-TEST-CASE1-CPP %s
+// RUN: FileCheck -input-file=%T/no-move-macro-helper/macro_helper_test.h -check-prefix=CHECK-OLD-TEST-CASE1-H %s
+// RUN: FileCheck -input-file=%T/no-move-macro-helper/macro_helper_test.cpp -check-prefix=CHECK-OLD-TEST-CASE1-CPP %s
+
+// CHECK-NEW-TEST-CASE1-H: class A {};
+
+// CHECK-OLD-TEST-CASE1-H-NOT: class A {};
+
+// CHECK-OLD-TEST-CASE1-CPP: DEFINE(test)
+
+// CHECK-NEW-TEST-CASE1-CPP-NOT: DEFINE(test)
+
+
+// -----------------------------------------------------------------------------
+// Test moving all.
+// -----------------------------------------------------------------------------
+// RUN: cp %S/Inputs/macro_helper_test.h %T/no-move-macro-helper/macro_helper_test.h
+// RUN: cp %S/Inputs/macro_helper_test.cpp %T/no-move-macro-helper/macro_helper_test.cpp
+// RUN: clang-move -names="A, f1" -new_cc=%T/no-move-macro-helper/new_test.cpp -new_header=%T/no-move-macro-helper/new_test.h -old_cc=%T/no-move-macro-helper/macro_helper_test.cpp -old_header=%T/no-move-macro-helper/macro_helper_test.h %T/no-move-macro-helper/macro_helper_test.cpp -- -std=c++11
+//
+// RUN: FileCheck -input-file=%T/no-move-macro-helper/new_test.h -check-prefix=CHECK-NEW-TEST-CASE2-H %s
+// RUN: FileCheck -input-file=%T/no-move-macro-helper/new_test.cpp -check-prefix=CHECK-NEW-TEST-CASE2-CPP %s
+// RUN: FileCheck -input-file=%T/no-move-macro-helper/macro_helper_test.h -allow-empty -check-prefix=CHECK-EMPTY %s
+// RUN: FileCheck -input-file=%T/no-move-macro-helper/macro_helper_test.cpp -allow-empty -check-prefix=CHECK-EMPTY %s
+
+// CHECK-NEW-TEST-CASE2-H: class A {};
+// CHECK-NEW-TEST-CASE2-H-NEXT:void f1();
+
+
+// CHECK-NEW-TEST-CASE2-CPP: DEFINE(test)
+// CHECK-NEW-TEST-CASE2-CPP: void f1() {}
+
+// CHECK-EMPTY: {{^}}{{$}}