[PATCH] D22102: [clang-rename] extend testset
Kirill Bobyrev via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 7 11:41:07 PDT 2016
omtcyf0 created this revision.
omtcyf0 added reviewers: alexfh, klimek, bkramer, ioeric.
omtcyf0 added a subscriber: cfe-commits.
This patch introduces few additional tests including one case the tool does not handle yet, which should be fixed in the future.
http://reviews.llvm.org/D22102
Files:
test/clang-rename/FunctionMacro.cpp
test/clang-rename/Namespace.cpp
test/clang-rename/TemplateTypename.cpp
test/clang-rename/VariableMacro.cpp
Index: test/clang-rename/VariableMacro.cpp
===================================================================
--- /dev/null
+++ test/clang-rename/VariableMacro.cpp
@@ -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.
Index: test/clang-rename/TemplateTypename.cpp
===================================================================
--- /dev/null
+++ test/clang-rename/TemplateTypename.cpp
@@ -0,0 +1,16 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename -offset=152 -new-name=U %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+// XFAIL: *
+
+template <typename T>
+T foo(T arg, T& ref, T* ptr) { // CHECK: U foo(U arg, U& ref, U* ptr) {
+ T value; // CHECK: U value;
+ int number = 42;
+ value = (T)number; // CHECK: value = (U)number;
+ value = static_cast<T>(number); // CHECK: value = static_cast<U>(number);
+ return value;
+}
+
+// Use grep -FUbo 'foo;' <file> to get the correct offset of foo when changing
+// this file.
Index: test/clang-rename/Namespace.cpp
===================================================================
--- /dev/null
+++ test/clang-rename/Namespace.cpp
@@ -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.
Index: test/clang-rename/FunctionMacro.cpp
===================================================================
--- /dev/null
+++ test/clang-rename/FunctionMacro.cpp
@@ -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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22102.63103.patch
Type: text/x-patch
Size: 2606 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160707/bf69b688/attachment-0001.bin>
More information about the cfe-commits
mailing list