Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang-rename] merge tests when possible
The only difference between some tests is -offset passed to clang-rename. It makes sense to merge them into a single file and add multiple tool invocations. Reviewers: alexfh Differential Revision: https://reviews.llvm.org/D23158 llvm-svn: 278221
- Loading branch information
1 parent
e171ea8
commit 77f522c
Showing
21 changed files
with
292 additions
and
160 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
clang-tools-extra/test/clang-rename/ClassAsTemplateArgument.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class Foo /* Test 1 */ {}; // CHECK: class Bar /* Test 1 */ {}; | ||
|
||
template <typename T> | ||
void func() {} | ||
|
||
template <typename T> | ||
class Baz {}; | ||
|
||
int main() { | ||
func<Foo>(); // CHECK: func<Bar>(); | ||
Baz<Foo> /* Test 2 */ obj; // CHECK: Baz<Bar> /* Test 2 */ obj; | ||
return 0; | ||
} | ||
|
||
// Test 1. | ||
// RUN: clang-rename -offset=7 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
// Test 2. | ||
// RUN: clang-rename -offset=215 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
|
||
// To find offsets after modifying the file, use: | ||
// grep -Ubo 'Foo.*' <file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
// RUN: cat %s > %t.cpp | ||
// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %t.cpp -i -- | ||
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s | ||
|
||
class Foo { // CHECK: class Bar | ||
class Foo { // CHECK: class Bar { | ||
}; | ||
|
||
int main() { | ||
Foo *Pointer = 0; // CHECK: Bar *Pointer = 0; | ||
return 0; | ||
} | ||
|
||
// Test 1. | ||
// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s |
21 changes: 11 additions & 10 deletions
21
clang-tools-extra/test/clang-rename/ClassSimpleRenaming.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
// RUN: cat %s > %t.cpp | ||
// RUN: clang-rename -offset=136 -new-name=Bar %t.cpp -i -- | ||
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s | ||
class Foo /* Test 1 */ { // CHECK: class Bar /* Test 1 */ { | ||
public: | ||
void foo(int x); | ||
}; | ||
|
||
class Foo {}; // CHECK: class Bar | ||
void Foo::foo(int x) /* Test 2 */ {} // CHECK: void Bar::foo(int x) /* Test 2 */ {} | ||
|
||
int main() { | ||
Foo *Pointer = 0; // CHECK: Bar *Pointer = 0; | ||
return 0; | ||
} | ||
// Test 1. | ||
// RUN: clang-rename -offset=6 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
// Test 2. | ||
// RUN: clang-rename -offset=109 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
|
||
// Use grep -FUbo 'Foo' <file> to get the correct offset of Cla when changing | ||
// this file. | ||
// To find offsets after modifying the file, use: | ||
// grep -Ubo 'Foo.*' <file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
// RUN: cat %s > %t.cpp | ||
// RUN: clang-rename rename-all -offset=174 -new-name=Bar1 -offset=212 -new-name=Bar2 %t.cpp -i -- | ||
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s | ||
class Foo1 { // CHECK: class Bar1 | ||
class Foo1 /* Offset 1 */ { // CHECK: class Bar1 /* Offset 1 */ { | ||
}; | ||
|
||
class Foo2 { // CHECK: class Bar2 | ||
class Foo2 /* Offset 2 */ { // CHECK: class Bar2 /* Offset 2 */ { | ||
}; | ||
|
||
// Test 1. | ||
// RUN: clang-rename rename-all -offset=6 -new-name=Bar1 -offset=76 -new-name=Bar2 %s -- | sed 's,//.*,,' | FileCheck %s | ||
|
||
// To find offsets after modifying the file, use: | ||
// grep -Ubo 'Foo.*' <file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
// RUN: cat %s > %t.cpp | ||
// RUN: clang-rename rename-all -old-name=Foo1 -new-name=Bar1 -old-name=Foo2 -new-name=Bar2 %t.cpp -i -- | ||
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s | ||
class Foo1 { // CHECK: class Bar1 | ||
}; | ||
|
||
class Foo2 { // CHECK: class Bar2 | ||
}; | ||
|
||
// Test 1. | ||
// RUN: clang-rename rename-all -old-name=Foo1 -new-name=Bar1 -old-name=Foo2 -new-name=Bar2 %s -- | sed 's,//.*,,' | FileCheck %s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 33 additions & 9 deletions
42
clang-tools-extra/test/clang-rename/ComplexFunctionOverride.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,47 @@ | ||
// RUN: cat %s > %t.cpp | ||
// RUN: clang-rename -offset=307 -new-name=bar %t.cpp -i -- -std=c++11 | ||
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s | ||
|
||
struct A { | ||
virtual void foo(); // CHECK: virtual void bar(); | ||
virtual void foo() {} /* Test 1 */ // CHECK: virtual void bar() {} | ||
}; | ||
|
||
struct B : A { | ||
void foo() override; // CHECK: void bar() override; | ||
void foo() override {} /* Test 2 */ // CHECK: void bar() override {} | ||
}; | ||
|
||
struct C : B { | ||
void foo() override; // CHECK: void bar() override; | ||
void foo() override {} /* Test 3 */ // CHECK: void bar() override {} | ||
}; | ||
|
||
struct D : B { | ||
void foo() override; // CHECK: void bar() override; | ||
void foo() override {} /* Test 4 */ // CHECK: void bar() override {} | ||
}; | ||
|
||
struct E : D { | ||
void foo() override; // CHECK: void bar() override; | ||
void foo() override {} /* Test 5 */ // CHECK: void bar() override {} | ||
}; | ||
|
||
int main() { | ||
A a; | ||
a.foo(); // CHECK: a.bar(); | ||
B b; | ||
b.foo(); // CHECK: b.bar(); | ||
C c; | ||
c.foo(); // CHECK: c.bar(); | ||
D d; | ||
d.foo(); // CHECK: d.bar(); | ||
E e; | ||
e.foo(); // CHECK: e.bar(); | ||
return 0; | ||
} | ||
|
||
// Test 1. | ||
// RUN: clang-rename -offset=26 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
// Test 2. | ||
// RUN: clang-rename -offset=109 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
// Test 3. | ||
// RUN: clang-rename -offset=201 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
// Test 4. | ||
// RUN: clang-rename -offset=293 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
// Test 5. | ||
// RUN: clang-rename -offset=385 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
|
||
// To find offsets after modifying the file, use: | ||
// grep -Ubo 'foo.*' <file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Foo { // CHECK: class Bar { | ||
public: | ||
Foo(); /* Test 1 */ // CHECK: Bar(); | ||
}; | ||
|
||
Foo::Foo() /* Test 2 */ {} // CHECK: Bar::Bar() /* Test 2 */ {} | ||
|
||
// Test 1. | ||
// RUN: clang-rename -offset=62 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
// Test 2. | ||
// RUN: clang-rename -offset=116 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
|
||
// To find offsets after modifying the file, use: | ||
// grep -Ubo 'Foo.*' <file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
// RUN: cat %s > %t.cpp | ||
// RUN: clang-rename -offset=163 -new-name=Bar %t.cpp -i -- | ||
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s | ||
|
||
class Baz {}; | ||
|
||
class Qux { | ||
Baz Foo; // CHECK: Baz Bar; | ||
Baz Foo; /* Test 1 */ // CHECK: Baz Bar; | ||
public: | ||
Qux(); | ||
}; | ||
|
||
Qux::Qux() : Foo() {} // CHECK: Qux::Qux() : Bar() {} | ||
Qux::Qux() : Foo() /* Test 2 */ {} // CHECK: Qux::Qux() : Bar() /* Test 2 */ {} | ||
|
||
// Test 1. | ||
// RUN: clang-rename -offset=33 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
// Test 2. | ||
// RUN: clang-rename -offset=118 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
|
||
// Use grep -FUbo 'Foo' <file> to get the correct offset of foo when changing | ||
// this file. | ||
// To find offsets after modifying the file, use: | ||
// grep -Ubo 'Foo.*' <file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
// RUN: cat %s > %t.cpp | ||
// RUN: clang-rename -offset=161 -new-name=Bar %t.cpp -i -- | ||
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s | ||
|
||
class C { | ||
public: | ||
static int Foo; // CHECK: static int Bar; | ||
static int Foo; /* Test 1 */ // CHECK: static int Bar; | ||
}; | ||
|
||
int foo(int x) { return 0; } | ||
#define MACRO(a) foo(a) | ||
|
||
int main() { | ||
C::Foo = 1; // CHECK: C::Bar | ||
MACRO(C::Foo); // CHECK: C::Bar | ||
int y = C::Foo; // CHECK: C::Bar | ||
C::Foo = 1; /* Test 2 */ // CHECK: C::Bar = 1; | ||
MACRO(C::Foo); // CHECK: MACRO(C::Bar); | ||
int y = C::Foo; /* Test 3 */ // CHECK: int y = C::Bar; | ||
return 0; | ||
} | ||
|
||
// Use grep -FUbo 'X' <file> to get the correct offset of foo when changing | ||
// this file. | ||
// Test 1. | ||
// RUN: clang-rename -offset=31 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
// Test 2. | ||
// RUN: clang-rename -offset=152 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
// Test 3. | ||
// RUN: clang-rename -offset=271 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
|
||
// To find offsets after modifying the file, use: | ||
// grep -Ubo 'Foo.*' <file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
// RUN: cat %s > %t.cpp | ||
// RUN: clang-rename -offset=199 -new-name=macro_function %t.cpp -i -- | ||
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s | ||
#define moo foo // CHECK: #define moo macro_function | ||
|
||
#define moo foo // CHECK: #define moo macro_function | ||
|
||
int foo() { // CHECK: int macro_function() { | ||
int foo() /* Test 1 */ { // CHECK: int macro_function() /* Test 1 */ { | ||
return 42; | ||
} | ||
|
||
void boo(int value) {} | ||
|
||
void qoo() { | ||
foo(); // CHECK: macro_function(); | ||
boo(foo()); // CHECK: boo(macro_function()); | ||
foo(); // CHECK: macro_function(); | ||
boo(foo()); // CHECK: boo(macro_function()); | ||
moo(); | ||
boo(moo()); | ||
} | ||
|
||
// Use grep -FUbo 'foo;' <file> to get the correct offset of foo when changing | ||
// this file. | ||
// Test 1. | ||
// RUN: clang-rename -offset=68 -new-name=macro_function %s -- | sed 's,//.*,,' | FileCheck %s | ||
|
||
// To find offsets after modifying the file, use: | ||
// grep -Ubo 'foo.*' <file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
// RUN: cat %s > %t.cpp | ||
// RUN: clang-rename -offset=318 -new-name=bar %t.cpp -i -- | ||
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s | ||
class A { virtual void foo(); /* Test 1 */ }; // CHECK: class A { virtual void bar(); | ||
class B : public A { void foo(); /* Test 2 */ }; // CHECK: class B : public A { void bar(); | ||
class C : public B { void foo(); /* Test 3 */ }; // CHECK: class C : public B { void bar(); | ||
|
||
class A { virtual void foo(); }; // CHECK: class A { virtual void bar(); }; | ||
class B : public A { void foo(); }; // CHECK: class B : public A { void bar(); }; | ||
class C : public B { void foo(); }; // CHECK: class C : public B { void bar(); }; | ||
// Test 1. | ||
// RUN: clang-rename -offset=23 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
// Test 2. | ||
// RUN: clang-rename -offset=116 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
// Test 3. | ||
// RUN: clang-rename -offset=209 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
|
||
// Use grep -FUbo 'Foo' <file> to get the correct offset of Foo when changing | ||
// this file. | ||
// To find offsets after modifying the file, use: | ||
// grep -Ubo 'foo.*' <file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
// RUN: cat %s > %t.cpp | ||
// RUN: clang-rename -offset=156 -new-name=Bar %t.cpp -i -- | ||
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s | ||
|
||
class Baz { | ||
public: | ||
int Foo; // CHECK: int Bar; | ||
int Foo; /* Test 1 */ // CHECK: int Bar; | ||
}; | ||
|
||
int qux(int x) { return 0; } | ||
#define MACRO(a) qux(a) | ||
|
||
int main() { | ||
Baz baz; | ||
baz.Foo = 1; // CHECK: baz.Bar = 1; | ||
MACRO(baz.Foo); // CHECK: MACRO(baz.Bar); | ||
int y = baz.Foo; // CHECK: int y = baz.Bar; | ||
baz.Foo = 1; /* Test 2 */ // CHECK: baz.Bar = 1; | ||
MACRO(baz.Foo); // CHECK: MACRO(baz.Bar); | ||
int y = baz.Foo; // CHECK: int y = baz.Bar; | ||
} | ||
|
||
// Use grep -FUbo 'Foo' <file> to get the correct offset of foo when changing | ||
// this file. | ||
// Test 1. | ||
// RUN: clang-rename -offset=26 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
// Test 2. | ||
// RUN: clang-rename -offset=155 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s | ||
|
||
// To find offsets after modifying the file, use: | ||
// grep -Ubo 'Foo.*' <file> |
Oops, something went wrong.