summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/cpp11-migrate
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/test/cpp11-migrate')
-rw-r--r--clang-tools-extra/test/cpp11-migrate/HeaderReplacements/Inputs/no_yaml.h8
-rw-r--r--clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common.h.yaml (renamed from clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main_expected.yaml)8
-rw-r--r--clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common_expected.yaml20
-rw-r--r--clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main.cpp56
-rw-r--r--clang-tools-extra/test/cpp11-migrate/HeaderReplacements/no_yaml.cpp24
5 files changed, 39 insertions, 77 deletions
diff --git a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/Inputs/no_yaml.h b/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/Inputs/no_yaml.h
deleted file mode 100644
index 8e09412c452..00000000000
--- a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/Inputs/no_yaml.h
+++ /dev/null
@@ -1,8 +0,0 @@
-void update(int (&arr)[10]) {
- int val = 1;
- for (unsigned i = 0; i < sizeof(arr)/sizeof(int); ++i) {
- arr[i] = val++;
- // CHECK: for (auto & elem : arr) {
- // CHECK-NEXT: elem = val++;
- }
-}
diff --git a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main_expected.yaml b/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common.h.yaml
index 8702bc17245..4b1258cae4a 100644
--- a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main_expected.yaml
+++ b/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common.h.yaml
@@ -2,11 +2,11 @@
MainSourceFile: "$(path)/main.cpp"
Replacements:
- FilePath: "$(path)/common.h"
- Offset: 506
- Length: 2
- ReplacementText: "elem"
- - FilePath: "$(path)/common.h"
Offset: 432
Length: 61
ReplacementText: "(auto & elem : C)"
+ - FilePath: "$(path)/common.h"
+ Offset: 506
+ Length: 2
+ ReplacementText: "elem"
...
diff --git a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common_expected.yaml b/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common_expected.yaml
deleted file mode 100644
index 67eb1fb9104..00000000000
--- a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/common_expected.yaml
+++ /dev/null
@@ -1,20 +0,0 @@
----
-MainSourceFile: "$(path)/common.cpp"
-Replacements:
- - FilePath: "$(path)/common.h"
- Offset: 506
- Length: 2
- ReplacementText: "elem"
- - FilePath: "$(path)/common.h"
- Offset: 432
- Length: 61
- ReplacementText: "(auto & elem : C)"
- - FilePath: "$(path)/common.cpp"
- Offset: 289
- Length: 2
- ReplacementText: "elem"
- - FilePath: "$(path)/common.cpp"
- Offset: 206
- Length: 63
- ReplacementText: "(auto & elem : C1)"
-...
diff --git a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main.cpp b/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main.cpp
index 54cbc92728e..d59417cf0d6 100644
--- a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main.cpp
+++ b/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/main.cpp
@@ -1,30 +1,44 @@
// The following block tests the following:
-// - Only 1 file is generated per translation unit
+// - Only 1 file is generated per translation unit and header file
// - Replacements are written in YAML that matches the expected YAML file
-// The test is run in %T/SerializeTest so it's easy to create a clean test
-// directory.
+// RUN: rm -rf %t/Test
+// RUN: mkdir -p %t/Test
+// RUN: cp %S/main.cpp %S/common.cpp %S/common.h %t/Test
+// RUN: cpp11-migrate -loop-convert -headers -yaml-only -include=%t/Test %t/Test/main.cpp %t/Test/common.cpp --
+// Check that only 1 file is generated per translation unit and header file.
+// RUN: ls -1 %t/Test | FileCheck %s --check-prefix=MAIN_CPP
+// RUN: ls -1 %t/Test | FileCheck %s --check-prefix=COMMON_CPP
+// RUN: cp %S/common.h.yaml %t/Test/main.cpp_common.h.yaml
+// We need to put the build path to the expected YAML file to diff against the generated one.
+// RUN: sed -e 's#$(path)#%/t/Test#g' %S/common.h.yaml > %t/Test/main.cpp_common.h.yaml
+// RUN: sed -i -e 's#\\#/#g' %t/Test/main.cpp_common.h_*.yaml
+// RUN: diff -b %t/Test/main.cpp_common.h.yaml %t/Test/main.cpp_common.h_*.yaml
+// RUN: sed -e 's#$(path)#%/t/Test#g' -e 's#main.cpp"#common.cpp"#g' %S/common.h.yaml > %t/Test/common.cpp_common.h.yaml
+// RUN: sed -i -e 's#\\#/#g' %t/Test/common.cpp_common.h_*.yaml
+// RUN: diff -b %t/Test/common.cpp_common.h.yaml %t/Test/common.cpp_common.h_*.yaml
//
-// RUN: rm -rf %T/SerializeTest
-// RUN: mkdir -p %T/SerializeTest
-// RUN: cp %S/main.cpp %S/common.cpp %S/common.h %T/SerializeTest
-// RUN: cpp11-migrate -loop-convert -headers -serialize-replacements -include=%T/SerializeTest %T/SerializeTest/main.cpp %T/SerializeTest/common.cpp --
-// Check that only 1 file is generated per translation unit
-// RUN: ls -1 %T/SerializeTest | FileCheck %s --check-prefix=MAIN_CPP
-// RUN: ls -1 %T/SerializeTest | FileCheck %s --check-prefix=COMMON_CPP
+// The following block tests the following:
+// - YAML files are written only when -headers is used
+// RUN: rm -rf %t/Test
+// RUN: mkdir -p %t/Test
+// RUN: cp %S/main.cpp %S/common.cpp %S/common.h %t/Test
+// RUN: cpp11-migrate -loop-convert -headers -yaml-only -include=%t/Test %t/Test/main.cpp --
+// RUN: cpp11-migrate -loop-convert %t/Test/common.cpp --
+// Check that only one YAML file is generated from main.cpp and common.h and not from common.cpp and common.h since -header is not specified
+// RUN: ls -1 %t/Test | FileCheck %s --check-prefix=MAIN_CPP
+// RUN: ls -1 %t/Test | FileCheck %s --check-prefix=NO_COMMON
// We need to put the build path to the expected YAML file to diff against the generated one.
-// RUN: sed -e 's#$(path)#%/T/SerializeTest#g' %S/main_expected.yaml > %T/SerializeTest/main_expected.yaml
-// RUN: sed -i -e 's#\\#/#g' %T/SerializeTest/main.cpp_*.yaml
-// RUN: diff -b %T/SerializeTest/main_expected.yaml %T/SerializeTest/main.cpp_*.yaml
-// RUN: sed -e 's#$(path)#%/T/SerializeTest#g' %S/common_expected.yaml > %T/SerializeTest/common_expected.yaml
-// RUN: sed -i -e 's#\\#/#g' %T/SerializeTest/common.cpp_*.yaml
-// RUN: diff -b %T/SerializeTest/common_expected.yaml %T/SerializeTest/common.cpp_*.yaml
+// RUN: sed -e 's#$(path)#%/t/Test#g' %S/common.h.yaml > %t/Test/main.cpp_common.h.yaml
+// RUN: sed -i -e 's#\\#/#g' %t/Test/main.cpp_common.h_*.yaml
+// RUN: diff -b %t/Test/main.cpp_common.h.yaml %t/Test/main.cpp_common.h_*.yaml
+//
+// MAIN_CPP: {{^main.cpp_common.h_.*.yaml$}}
+// MAIN_CPP-NOT: {{main.cpp_common.h_.*.yaml}}
//
-// The following are for FileCheck when used on output of 'ls'. See above.
-// MAIN_CPP: {{^main.cpp_.*.yaml$}}
-// MAIN_CPP-NOT: {{main.cpp_.*.yaml}}
+// COMMON_CPP: {{^common.cpp_common.h_.*.yaml$}}
+// COMMON_CPP-NOT: {{common.cpp_common.h_.*.yaml}}
//
-// COMMON_CPP: {{^common.cpp_.*.yaml$}}
-// COMMON_CPP-NOT: {{common.cpp_.*.yaml}}
+// NO_COMMON-NOT: {{common.cpp_common.h_.*.yaml}}
#include "common.h"
diff --git a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/no_yaml.cpp b/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/no_yaml.cpp
deleted file mode 100644
index 880cc1f5a70..00000000000
--- a/clang-tools-extra/test/cpp11-migrate/HeaderReplacements/no_yaml.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-// Ensure that if -serialize-replacements is not provided, no serialized
-// replacement files should be generated and the changes are made directly.
-//
-// RUN: mkdir -p %T/Inputs
-// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
-// RUN: grep -Ev "// *[A-Z-]+:" %S/Inputs/no_yaml.h > %T/Inputs/no_yaml.h
-// RUN: cpp11-migrate -loop-convert %t.cpp -headers -include=%T/Inputs -- -I %T/Inputs/no_yaml.h
-// RUN: FileCheck --input-file=%t.cpp %s
-// RUN: FileCheck --input-file=%T/Inputs/no_yaml.h %S/Inputs/no_yaml.h
-// RUN: ls -1 %T | FileCheck %s --check-prefix=NO_YAML
-//
-// NO_YAML-NOT: {{no_yaml.cpp_.*.yaml}}
-#include "Inputs/no_yaml.h"
-
-void func() {
- int arr[10];
- for (unsigned i = 0; i < sizeof(arr)/sizeof(int); ++i) {
- arr[i] = 0;
- // CHECK: for (auto & elem : arr) {
- // CHECK-NEXT: elem = 0;
- }
-
- update(arr);
-}
OpenPOWER on IntegriCloud