diff options
author | Haojian Wu <hokein@google.com> | 2016-11-16 13:05:19 +0000 |
---|---|---|
committer | Haojian Wu <hokein@google.com> | 2016-11-16 13:05:19 +0000 |
commit | de8cfac5f5f55dbcba933b5e116ea01afabd2b63 (patch) | |
tree | 7efef5d4bb083bed3e3f050b1fc432a06fa1172d /clang-tools-extra/test/clang-move | |
parent | 74f49baccca44dc44a973ad212e6ec57e8a870f2 (diff) |
[clang-move] Support moving function.
Reviewers: ioeric
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D26665
Diffstat (limited to 'clang-tools-extra/test/clang-move')
3 files changed, 86 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-move/Inputs/function_test.cpp b/clang-tools-extra/test/clang-move/Inputs/function_test.cpp new file mode 100644 index 00000000000..5e86f5904a5 --- /dev/null +++ b/clang-tools-extra/test/clang-move/Inputs/function_test.cpp @@ -0,0 +1,5 @@ +#include "function_test.h" + +void f() {} + +void A::f() {} diff --git a/clang-tools-extra/test/clang-move/Inputs/function_test.h b/clang-tools-extra/test/clang-move/Inputs/function_test.h new file mode 100644 index 00000000000..810f803b6e8 --- /dev/null +++ b/clang-tools-extra/test/clang-move/Inputs/function_test.h @@ -0,0 +1,14 @@ +void f(); + +inline int g() { return 0; } + +template<typename T> +void h(T t) {} + +template<> +void h(int t) {} + +class A { + public: + void f(); +}; diff --git a/clang-tools-extra/test/clang-move/move-function.cpp b/clang-tools-extra/test/clang-move/move-function.cpp new file mode 100644 index 00000000000..ceda2d5a0fc --- /dev/null +++ b/clang-tools-extra/test/clang-move/move-function.cpp @@ -0,0 +1,67 @@ +// RUN: mkdir -p %T/move-function +// RUN: cp %S/Inputs/function_test* %T/move-function +// RUN: cd %T/move-function +// RUN: clang-move -names="g" -new_header=%T/move-function/new_function_test.h -old_header=../move-function/function_test.h %T/move-function/function_test.cpp -- +// RUN: FileCheck -input-file=%T/move-function/new_function_test.h -check-prefix=CHECK-NEW-TEST-H-CASE1 %s +// +// CHECK-NEW-TEST-H-CASE1: #ifndef {{.*}}NEW_FUNCTION_TEST_H +// CHECK-NEW-TEST-H-CASE1: #define {{.*}}NEW_FUNCTION_TEST_H +// CHECK-NEW-TEST-H-CASE1: {{[[:space:]]+}} +// CHECK-NEW-TEST-H-CASE1: inline int g() { return 0; } +// CHECK-NEW-TEST-H-CASE1: {{[[:space:]]+}} +// CHECK-NEW-TEST-H-CASE1: #endif // {{.*}}NEW_FUNCTION_TEST_H +// +// RUN: cp %S/Inputs/function_test* %T/move-function +// RUN: clang-move -names="h" -new_header=%T/move-function/new_function_test.h -old_header=../move-function/function_test.h %T/move-function/function_test.cpp -- +// RUN: FileCheck -input-file=%T/move-function/new_function_test.h -check-prefix=CHECK-NEW-TEST-H-CASE2 %s +// +// CHECK-NEW-TEST-H-CASE2: #ifndef {{.*}}NEW_FUNCTION_TEST_H +// CHECK-NEW-TEST-H-CASE2: #define {{.*}}NEW_FUNCTION_TEST_H +// CHECK-NEW-TEST-H-CASE2: {{[[:space:]]+}} +// CHECK-NEW-TEST-H-CASE2: template <typename T> void h(T t) {} +// CHECK-NEW-TEST-H-CASE2: {{[[:space:]]+}} +// CHECK-NEW-TEST-H-CASE2: template <> void h(int t) {} +// CHECK-NEW-TEST-H-CASE2: {{[[:space:]]+}} +// CHECK-NEW-TEST-H-CASE2: #endif // {{.*}}NEW_FUNCTION_TEST_H +// +// RUN: cp %S/Inputs/function_test* %T/move-function +// RUN: clang-move -names="f" -new_header=%T/move-function/new_function_test.h -new_cc=%T/move-function/new_function_test.cpp -old_header=../move-function/function_test.h -old_cc=../move-function/function_test.cpp %T/move-function/function_test.cpp -- +// RUN: FileCheck -input-file=%T/move-function/new_function_test.h -check-prefix=CHECK-NEW-TEST-H-CASE3 %s +// RUN: FileCheck -input-file=%T/move-function/new_function_test.cpp -check-prefix=CHECK-NEW-TEST-CPP-CASE3 %s +// +// CHECK-NEW-TEST-H-CASE3: #ifndef {{.*}}NEW_FUNCTION_TEST_H +// CHECK-NEW-TEST-H-CASE3: #define {{.*}}NEW_FUNCTION_TEST_H +// CHECK-NEW-TEST-H-CASE3: {{[[:space:]]+}} +// CHECK-NEW-TEST-H-CASE3: void f(); +// CHECK-NEW-TEST-H-CASE3: {{[[:space:]]+}} +// CHECK-NEW-TEST-H-CASE3: #endif // {{.*}}NEW_FUNCTION_TEST_H +// CHECK-NEW-TEST-CPP-CASE3: #include "{{.*}}new_function_test.h" +// CHECK-NEW-TEST-CPP-CASE3: {{[[:space:]]+}} +// CHECK-NEW-TEST-CPP-CASE3: void f() {} +// +// RUN: cp %S/Inputs/function_test* %T/move-function +// RUN: clang-move -names="A::f" -new_header=%T/move-function/new_function_test.h -new_cc=%T/move-function/new_function_test.cpp -old_header=../move-function/function_test.h -old_cc=../move-function/function_test.cpp %T/move-function/function_test.cpp -dump_result -- | FileCheck %s -check-prefix=CHECK-EMPTY +// +// CHECK-EMPTY: [{{[[:space:]]*}}] +// +// RUN: cp %S/Inputs/function_test* %T/move-function +// RUN: clang-move -names="f,A" -new_header=%T/move-function/new_function_test.h -new_cc=%T/move-function/new_function_test.cpp -old_header=../move-function/function_test.h -old_cc=../move-function/function_test.cpp %T/move-function/function_test.cpp -- +// RUN: FileCheck -input-file=%T/move-function/new_function_test.h -check-prefix=CHECK-NEW-TEST-H-CASE4 %s +// RUN: FileCheck -input-file=%T/move-function/new_function_test.cpp -check-prefix=CHECK-NEW-TEST-CPP-CASE4 %s + +// CHECK-NEW-TEST-H-CASE4: #ifndef {{.*}}NEW_FUNCTION_TEST_H +// CHECK-NEW-TEST-H-CASE4: #define {{.*}}NEW_FUNCTION_TEST_H +// CHECK-NEW-TEST-H-CASE4: {{[[:space:]]+}} +// CHECK-NEW-TEST-H-CASE4: void f(); +// CHECK-NEW-TEST-H-CASE4: {{[[:space:]]+}} +// CHECK-NEW-TEST-H-CASE4: class A { +// CHECK-NEW-TEST-H-CASE4: public: +// CHECK-NEW-TEST-H-CASE4: void f(); +// CHECK-NEW-TEST-H-CASE4: }; +// CHECK-NEW-TEST-H-CASE4: {{[[:space:]]+}} +// CHECK-NEW-TEST-H-CASE4: #endif // {{.*}}NEW_FUNCTION_TEST_H +// CHECK-NEW-TEST-CPP-CASE4: #include "{{.*}}new_function_test.h" +// CHECK-NEW-TEST-CPP-CASE4: {{[[:space:]]+}} +// CHECK-NEW-TEST-CPP-CASE4: void f() {} +// CHECK-NEW-TEST-CPP-CASE4: {{[[:space:]]+}} +// CHECK-NEW-TEST-CPP-CASE4: void A::f() {} |