[clang-rename] merge tests when possible
authorKirill Bobyrev <omtcyfz@gmail.com>
Wed, 10 Aug 2016 13:28:30 +0000 (13:28 +0000)
committerKirill Bobyrev <omtcyfz@gmail.com>
Wed, 10 Aug 2016 13:28:30 +0000 (13:28 +0000)
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

21 files changed:
clang-tools-extra/test/clang-rename/ClassAsTemplateArgument.cpp [new file with mode: 0644]
clang-tools-extra/test/clang-rename/ClassFindByName.cpp
clang-tools-extra/test/clang-rename/ClassSimpleRenaming.cpp
clang-tools-extra/test/clang-rename/ClassTestMulti.cpp
clang-tools-extra/test/clang-rename/ClassTestMultiByName.cpp
clang-tools-extra/test/clang-rename/ClassTestMultiByNameYAML.cpp
clang-tools-extra/test/clang-rename/ComplexFunctionOverride.cpp
clang-tools-extra/test/clang-rename/ComplicatedClassType.cpp
clang-tools-extra/test/clang-rename/Ctor.cpp [new file with mode: 0644]
clang-tools-extra/test/clang-rename/CtorInitializer.cpp
clang-tools-extra/test/clang-rename/DeclRefExpr.cpp
clang-tools-extra/test/clang-rename/FunctionMacro.cpp
clang-tools-extra/test/clang-rename/FunctionOverride.cpp
clang-tools-extra/test/clang-rename/FunctionWithClassFindByName.cpp
clang-tools-extra/test/clang-rename/MemberExprMacro.cpp
clang-tools-extra/test/clang-rename/Namespace.cpp
clang-tools-extra/test/clang-rename/TemplateClassInstantiation.cpp
clang-tools-extra/test/clang-rename/TemplateTypename.cpp
clang-tools-extra/test/clang-rename/UserDefinedConversion.cpp
clang-tools-extra/test/clang-rename/Variable.cpp
clang-tools-extra/test/clang-rename/VariableMacro.cpp

diff --git a/clang-tools-extra/test/clang-rename/ClassAsTemplateArgument.cpp b/clang-tools-extra/test/clang-rename/ClassAsTemplateArgument.cpp
new file mode 100644 (file)
index 0000000..2e09a5b
--- /dev/null
@@ -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>
index 8f68034..42b4299 100644 (file)
@@ -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
index 72710d0..086f557 100644 (file)
@@ -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>
index 21e702d..22911df 100644 (file)
@@ -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>
index 1968f67..9052750 100644 (file)
@@ -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
index f0d51cd..ecf506f 100644 (file)
@@ -3,5 +3,8 @@ class Foo1 { // CHECK: class Bar1
 
 class Foo2 { // CHECK: class Bar2
 };
+
+// Test 1.
 // RUN: clang-rename rename-all -input %S/Inputs/ClassTestMultiByNameYAMLRenameAll.yaml %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 2.
 // RUN: clang-rename rename-all -input %S/Inputs/ClassTestMultiByNameYAMLRenameAt.yaml %s -- | sed 's,//.*,,' | FileCheck %s
index 4994e89..ccf3a20 100644 (file)
@@ -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>
index 6e888bd..6cca0a5 100644 (file)
@@ -1,11 +1,11 @@
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=220 -new-name=Bar %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
-
 // Forward declaration.
-class Foo;                            // CHECK: class Bar;
+class Foo; /* Test 1 */               // CHECK: class Bar; /* Test 1 */
+
+class Baz {
+  virtual int getValue() const = 0;
+};
 
-class Foo {                           // CHECK: class Bar {
+class Foo : public Baz  { /* Test 2 */// CHECK: class Bar : public Baz {
 public:
   Foo(int value = 0) : x(value) {}    // CHECK: Bar(int value = 0) : x(value) {}
 
@@ -18,6 +18,10 @@ public:
     return this->x < rhs.x;
   }
 
+  int getValue() const {
+    return 0;
+  }
+
 private:
   int x;
 };
@@ -27,5 +31,33 @@ int main() {
   Foo Variable = Foo(10);             // CHECK: Bar Variable = Bar(10);
   for (Foo it; it < Variable; it++) { // CHECK: for (Bar it; it < Variable; it++) {
   }
+  const Foo *C = new Foo();           // CHECK: const Bar *C = new Bar();
+  const_cast<Foo *>(C)->getValue();   // CHECK: const_cast<Bar *>(C)->getValue();
+  Foo foo;                            // CHECK: Bar foo;
+  const Baz &BazReference = foo;
+  const Baz *BazPointer = &foo;
+  dynamic_cast<const Foo &>(BazReference).getValue();     /* Test 3 */ // CHECK: dynamic_cast<const Bar &>(BazReference).getValue();
+  dynamic_cast<const Foo *>(BazPointer)->getValue();      /* Test 4 */ // CHECK: dynamic_cast<const Bar *>(BazPointer)->getValue();
+  reinterpret_cast<const Foo *>(BazPointer)->getValue();  /* Test 5 */ // CHECK: reinterpret_cast<const Bar *>(BazPointer)->getValue();
+  static_cast<const Foo &>(BazReference).getValue();      /* Test 6 */ // CHECK: static_cast<const Bar &>(BazReference).getValue();
+  static_cast<const Foo *>(BazPointer)->getValue();       /* Test 7 */ // CHECK: static_cast<const Bar *>(BazPointer)->getValue();
   return 0;
 }
+
+// Test 1.
+// RUN: clang-rename -offset=30 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 2.
+// RUN: clang-rename -offset=155 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=1133 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 4.
+// RUN: clang-rename -offset=1266 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 5.
+// RUN: clang-rename -offset=1402 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 6.
+// RUN: clang-rename -offset=1533 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 7.
+// RUN: clang-rename -offset=1665 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+
+// To find offsets after modifying the file, use:
+//   grep -Ubo 'Foo.*' <file>
diff --git a/clang-tools-extra/test/clang-rename/Ctor.cpp b/clang-tools-extra/test/clang-rename/Ctor.cpp
new file mode 100644 (file)
index 0000000..9908a41
--- /dev/null
@@ -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>
index 1fa1665..fed4f5b 100644 (file)
@@ -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>
index 2059ff0..6462862 100644 (file)
@@ -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>
index 1cdac27..6e87026 100644 (file)
@@ -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>
index 476a6ba..adfeb73 100644 (file)
@@ -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>
index 6546f79..d197ca1 100644 (file)
@@ -1,7 +1,3 @@
-// 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
-
 void foo() {
 }
 
@@ -13,3 +9,4 @@ int main() {
   return 0;
 }
 
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
index 24ba05f..56cd8d9 100644 (file)
@@ -1,10 +1,6 @@
-// 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; }
@@ -12,10 +8,15 @@ int qux(int x) { return 0; }
 
 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>
index 5eea4a6..ec9630f 100644 (file)
@@ -1,14 +1,13 @@
-// 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 {
+namespace gcc /* Test 1 */ {  // CHECK: namespace clang /* Test 1 */ {
   int x;
 }
 
 void boo() {
-  foo::x = 42;  // CHECK: llvm::x = 42;
+  gcc::x = 42;                // CHECK: clang::x = 42;
 }
 
-// Use grep -FUbo 'foo;' <file> to get the correct offset of foo when changing
-// this file.
+// Test 1.
+// RUN: clang-rename -offset=10 -new-name=clang %s -- | sed 's,//.*,,' | FileCheck %s
+
+// To find offsets after modifying the file, use:
+//   grep -Ubo 'Foo.*' <file>
index 453db5d..493d095 100644 (file)
@@ -1,5 +1,5 @@
 template <typename T>
-class Foo {               // CHECK: class Bar {
+class Foo { /* Test 1 */   // CHECK: class Bar { /* Test 1 */
 public:
   T foo(T arg, T& ref, T* ptr) {
     T value;
@@ -14,31 +14,29 @@ public:
 
 template <typename T>
 void func() {
-  Foo<T> obj;             // CHECK: Bar<T> obj;
+  Foo<T> obj; /* Test 2 */  // CHECK: Bar<T> obj;
   obj.member = T();
-  Foo<T>::foo();          // CHECK: Bar<T>::foo();
+  Foo<T>::foo();            // CHECK: Bar<T>::foo();
 }
 
 int main() {
-  Foo<int> i;             // CHECK: Bar<int> i;
+  Foo<int> i; /* Test 3 */  // CHECK: Bar<int> i;
   i.member = 0;
-  Foo<int>::foo(0);       // CHECK: Bar<int>::foo(0);
+  Foo<int>::foo(0);         // CHECK: Bar<int>::foo(0);
 
-  Foo<bool> b;            // CHECK: Bar<bool> b;
+  Foo<bool> b;              // CHECK: Bar<bool> b;
   b.member = false;
-  Foo<bool>::foo(false);  // CHECK: Bar<bool>::foo(false);
+  Foo<bool>::foo(false);    // CHECK: Bar<bool>::foo(false);
 
   return 0;
 }
 
-// RUN: cat %s > %t-0.cpp
-// RUN: clang-rename -offset=29 -new-name=Bar %t-0.cpp -i -- -fno-delayed-template-parsing
-// RUN: sed 's,//.*,,' %t-0.cpp | FileCheck %s
+// Test 1.
+// RUN: clang-rename -offset=29 -new-name=Bar %s -- -fno-delayed-template-parsing | sed 's,//.*,,' | FileCheck %s
+// Test 2.
+// RUN: clang-rename -offset=324 -new-name=Bar %s -- -fno-delayed-template-parsing | sed 's,//.*,,' | FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=463 -new-name=Bar %s -- -fno-delayed-template-parsing | sed 's,//.*,,' | FileCheck %s
 
-// RUN: cat %s > %t-1.cpp
-// RUN: clang-rename -offset=311 -new-name=Bar %t-1.cpp -i -- -fno-delayed-template-parsing
-// RUN: sed 's,//.*,,' %t-1.cpp | FileCheck %s
-
-// RUN: cat %s > %t-2.cpp
-// RUN: clang-rename -offset=445 -new-name=Bar %t-2.cpp -i -- -fno-delayed-template-parsing
-// RUN: sed 's,//.*,,' %t-2.cpp | FileCheck %s
+// To find offsets after modifying the file, use:
+//   grep -Ubo 'Foo.*' <file>
index 0641a05..559ec1f 100644 (file)
@@ -1,12 +1,24 @@
-// Currently unsupported test.
-// RUN: cat %s > %t.cpp
-// FIXME: clang-rename should be able to rename template parameters correctly.
-
-template <typename T>
-T foo(T arg, T& ref, T* ptr) {
-  T value;
+template <typename T /* Test 1 */>              // CHECK: template <typename U /* Test 1 */>
+class Foo {
+T foo(T arg, T& ref, T* /* Test 2 */ ptr) {     // CHECK: U foo(U arg, U& ref, U* /* Test 2 */ ptr) {
+  T value;                                      // CHECK: U value;
   int number = 42;
-  value = (T)number;
-  value = static_cast<T>(number);
+  value = (T)number;                            // CHECK: value = (U)number;
+  value = static_cast<T /* Test 3 */>(number);  // CHECK: value = static_cast<U /* Test 3 */>(number);
   return value;
 }
+
+static void foo(T value) {}                     // CHECK: static void foo(U value) {}
+
+T member;                                       // CHECK: U member;
+};
+
+// Test 1.
+// RUN: clang-rename -offset=19 -new-name=U %s -- -fno-delayed-template-parsing | sed 's,//.*,,' | FileCheck %s
+// Test 2.
+// RUN: clang-rename -offset=126 -new-name=U %s -- -fno-delayed-template-parsing | sed 's,//.*,,' | FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=392 -new-name=U %s -- -fno-delayed-template-parsing | sed 's,//.*,,' | FileCheck %s
+
+// To find offsets after modifying the file, use:
+//   grep -Ubo 'T.*' <file>
index 13bac33..60f251a 100644 (file)
@@ -1,13 +1,26 @@
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=205 -new-name=Bar %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
-
-class Foo {};             // CHECK: class Bar {};
+class Foo {       /* Test 1 */          // CHECK: class Bar {
+public:
+  Foo() {}                              // CHECK: Bar() {}
+};
 
 class Baz {
-  operator Foo() const {  // CHECK: operator Bar() const {
-// offset  ^
-    Foo foo;              // CHECK: Bar foo;
+public:
+  operator Foo()  /* Test 2 */ const {  // CHECK: operator Bar()  /* Test 2 */ const {
+    Foo foo;                            // CHECK: Bar foo;
     return foo;
   }
 };
+
+int main() {
+  Baz boo;
+  Foo foo = static_cast<Foo>(boo);      // CHECK: Bar foo = static_cast<Bar>(boo);
+  return 0;
+}
+
+// Test 1.
+// RUN: clang-rename -offset=7 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 2.
+// RUN: clang-rename -offset=164 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+
+// To find offsets after modifying the file, use:
+//   grep -Ubo 'Foo.*' <file>
index 02935bd..992c96b 100644 (file)
@@ -1,27 +1,32 @@
-// RUN: cat %s > %t.cpp
-// RUN: clang-rename -offset=148 -new-name=Bar %t.cpp -i --
-// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
-
 namespace A {
-int Foo;                // CHECK: int Bar;
+int Foo;          /* Test 1 */        // CHECK: int Bar;
 }
-int Foo;                // CHECK: int Foo;
-int Qux = Foo;          // CHECK: int Qux = Foo;
-int Baz = A::Foo;       // CHECK: Baz = A::Bar;
+int Foo;                              // CHECK: int Foo;
+int Qux = Foo;                        // CHECK: int Qux = Foo;
+int Baz = A::Foo; /* Test 2 */        // CHECK: Baz = A::Bar;
 void fun() {
   struct {
-    int Foo;            // CHECK: int Foo;
+    int Foo;                          // CHECK: int Foo;
   } b = {100};
-  int Foo = 100;        // CHECK: int Foo = 100;
-  Baz = Foo;            // CHECK: Baz = Foo;
+  int Foo = 100;                      // CHECK: int Foo = 100;
+  Baz = Foo;                          // CHECK: Baz = Foo;
   {
-    extern int Foo;     // CHECK: extern int Foo;
-    Baz = Foo;          // CHECK: Baz = Foo;
-    Foo = A::Foo + Baz; // CHECK: Foo = A::Bar + Baz;
-    A::Foo = b.Foo;     // CHECK: A::Bar = b.Foo;
+    extern int Foo;                   // CHECK: extern int Foo;
+    Baz = Foo;                        // CHECK: Baz = Foo;
+    Foo = A::Foo /* Test 3 */ + Baz;  // CHECK: Foo = A::Bar /* Test 3 */ + Baz;
+    A::Foo /* Test 4 */ = b.Foo;      // CHECK: A::Bar /* Test 4 */ = b.Foo;
   }
-  Foo = b.Foo;          // Foo = b.Foo;
+  Foo = b.Foo;                        // Foo = b.Foo;
 }
 
-// Use grep -FUbo 'Foo' <file> to get the correct offset of foo when changing
-// this file.
+// Test 1.
+// RUN: clang-rename -offset=18 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 2.
+// RUN: clang-rename -offset=206 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=613 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 4.
+// RUN: clang-rename -offset=688 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+
+// To find offsets after modifying the file, use:
+//   grep -Ubo 'Foo.*' <file>
index 2a0cd87..622e825 100644 (file)
@@ -1,18 +1,21 @@
-// 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
+#define Baz Foo // CHECK: #define Baz Bar
 
 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);
+  int Foo;  /* Test 1 */  // CHECK: int Bar;
+  Foo = 42; /* Test 2 */  // CHECK: Bar = 42;
+  Baz -= 0;
+  foo(Foo); /* Test 3 */  // CHECK: foo(Bar);
+  foo(Baz);
 }
 
-// Use grep -FUbo 'foo;' <file> to get the correct offset of foo when changing
-// this file.
+// Test 1.
+// RUN: clang-rename -offset=88 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 2.
+// RUN: clang-rename -offset=129 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+// Test 3.
+// RUN: clang-rename -offset=191 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
+
+// To find offsets after modifying the file, use:
+//   grep -Ubo 'Foo.*' <file>