Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Thiis patch introduces few additional tests including one case the tool does not handle yet, which should be fixed in the future. Differential Revision: https://reviews.llvm.org/D22102 llvm-svn: 275545
- Loading branch information
1 parent
4abe5d6
commit 713bdc0
Showing
5 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
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 @@ | ||
// 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 | ||
|
||
int foo() { // CHECK: int macro_function() { | ||
return 42; | ||
} | ||
|
||
void boo(int value) {} | ||
|
||
void qoo() { | ||
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. |
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 @@ | ||
// RUN: cat %s > %t.cpp | ||
// RUN: clang-rename -offset=143 -new-name=llvm %t.cpp -i -- | ||
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s | ||
|
||
namespace foo { // CHECK: namespace llvm { | ||
int x; | ||
} | ||
|
||
void boo() { | ||
foo::x = 42; // CHECK: llvm::x = 42; | ||
} | ||
|
||
// Use grep -FUbo 'foo;' <file> to get the correct offset of foo when changing | ||
// this 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Currently unsupported test. | ||
// FIXME: clang-rename should be able to rename template parameters correctly. | ||
|
||
template <typename T> | ||
T foo(T arg, T& ref, T* ptr) { | ||
T value; | ||
int number = 42; | ||
value = (T)number; | ||
value = static_cast<T>(number); | ||
return value; | ||
} |
12 changes: 12 additions & 0 deletions
12
clang-tools-extra/test/clang-rename/UserDefinedConversion.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,12 @@ | ||
// Currently unsupported test. | ||
// FIXME: clang-rename should handle conversions from a class type to another | ||
// type. | ||
|
||
class Foo {}; // CHECK: class Bar {}; | ||
|
||
class Baz { // CHECK: class Bar { | ||
operator Foo() const { // CHECK: operator Bar() const { | ||
Foo foo; // CHECK: Bar foo; | ||
return foo; | ||
} | ||
}; |
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,18 @@ | ||
// RUN: cat %s > %t.cpp | ||
// RUN: clang-rename -offset=208 -new-name=Z %t.cpp -i -- | ||
// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s | ||
|
||
#define Y X // CHECK: #define Y Z | ||
|
||
void foo(int value) {} | ||
|
||
void macro() { | ||
int X; // CHECK: int Z; | ||
X = 42; // CHECK: Z = 42; | ||
Y -= 0; | ||
foo(X); // CHECK: foo(Z); | ||
foo(Y); | ||
} | ||
|
||
// Use grep -FUbo 'foo;' <file> to get the correct offset of foo when changing | ||
// this file. |