Index: clang-tools-extra/trunk/test/clang-rename/ClassAsTemplateArgument.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/ClassAsTemplateArgument.cpp +++ clang-tools-extra/trunk/test/clang-rename/ClassAsTemplateArgument.cpp @@ -0,0 +1,21 @@ +class Foo /* Test 1 */ {}; // CHECK: class Bar /* Test 1 */ {}; + +template +void func() {} + +template +class Baz {}; + +int main() { + func(); // CHECK: func(); + Baz /* Test 2 */ obj; // CHECK: Baz /* 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.*' Index: clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp +++ clang-tools-extra/trunk/test/clang-rename/ClassFindByName.cpp @@ -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: clang-tools-extra/trunk/test/clang-rename/ClassSimpleRenaming.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/ClassSimpleRenaming.cpp +++ clang-tools-extra/trunk/test/clang-rename/ClassSimpleRenaming.cpp @@ -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' to get the correct offset of Cla when changing -// this file. +// To find offsets after modifying the file, use: +// grep -Ubo 'Foo.*' Index: clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp +++ clang-tools-extra/trunk/test/clang-rename/ClassTestMulti.cpp @@ -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.*' Index: clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp +++ clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByName.cpp @@ -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: clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByNameYAML.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByNameYAML.cpp +++ clang-tools-extra/trunk/test/clang-rename/ClassTestMultiByNameYAML.cpp @@ -3,5 +3,8 @@ 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: clang-tools-extra/trunk/test/clang-rename/ComplexFunctionOverride.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/ComplexFunctionOverride.cpp +++ clang-tools-extra/trunk/test/clang-rename/ComplexFunctionOverride.cpp @@ -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.*' Index: clang-tools-extra/trunk/test/clang-rename/ComplicatedClassType.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/ComplicatedClassType.cpp +++ clang-tools-extra/trunk/test/clang-rename/ComplicatedClassType.cpp @@ -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 @@ return this->x < rhs.x; } + int getValue() const { + return 0; + } + private: int x; }; @@ -27,5 +31,33 @@ 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(C)->getValue(); // CHECK: const_cast(C)->getValue(); + Foo foo; // CHECK: Bar foo; + const Baz &BazReference = foo; + const Baz *BazPointer = &foo; + dynamic_cast(BazReference).getValue(); /* Test 3 */ // CHECK: dynamic_cast(BazReference).getValue(); + dynamic_cast(BazPointer)->getValue(); /* Test 4 */ // CHECK: dynamic_cast(BazPointer)->getValue(); + reinterpret_cast(BazPointer)->getValue(); /* Test 5 */ // CHECK: reinterpret_cast(BazPointer)->getValue(); + static_cast(BazReference).getValue(); /* Test 6 */ // CHECK: static_cast(BazReference).getValue(); + static_cast(BazPointer)->getValue(); /* Test 7 */ // CHECK: static_cast(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.*' Index: clang-tools-extra/trunk/test/clang-rename/Ctor.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/Ctor.cpp +++ clang-tools-extra/trunk/test/clang-rename/Ctor.cpp @@ -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.*' Index: clang-tools-extra/trunk/test/clang-rename/CtorInitializer.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/CtorInitializer.cpp +++ clang-tools-extra/trunk/test/clang-rename/CtorInitializer.cpp @@ -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' to get the correct offset of foo when changing -// this file. +// To find offsets after modifying the file, use: +// grep -Ubo 'Foo.*' Index: clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp +++ clang-tools-extra/trunk/test/clang-rename/DeclRefExpr.cpp @@ -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' 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.*' Index: clang-tools-extra/trunk/test/clang-rename/FunctionMacro.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/FunctionMacro.cpp +++ clang-tools-extra/trunk/test/clang-rename/FunctionMacro.cpp @@ -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;' 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.*' Index: clang-tools-extra/trunk/test/clang-rename/FunctionOverride.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/FunctionOverride.cpp +++ clang-tools-extra/trunk/test/clang-rename/FunctionOverride.cpp @@ -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' to get the correct offset of Foo when changing -// this file. +// To find offsets after modifying the file, use: +// grep -Ubo 'foo.*' Index: clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp +++ clang-tools-extra/trunk/test/clang-rename/FunctionWithClassFindByName.cpp @@ -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 @@ return 0; } +// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp +++ clang-tools-extra/trunk/test/clang-rename/MemberExprMacro.cpp @@ -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 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' 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.*' Index: clang-tools-extra/trunk/test/clang-rename/Namespace.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/Namespace.cpp +++ clang-tools-extra/trunk/test/clang-rename/Namespace.cpp @@ -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;' 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.*' Index: clang-tools-extra/trunk/test/clang-rename/TemplateClassInstantiation.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/TemplateClassInstantiation.cpp +++ clang-tools-extra/trunk/test/clang-rename/TemplateClassInstantiation.cpp @@ -1,5 +1,5 @@ template -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 @@ template void func() { - Foo obj; // CHECK: Bar obj; + Foo obj; /* Test 2 */ // CHECK: Bar obj; obj.member = T(); - Foo::foo(); // CHECK: Bar::foo(); + Foo::foo(); // CHECK: Bar::foo(); } int main() { - Foo i; // CHECK: Bar i; + Foo i; /* Test 3 */ // CHECK: Bar i; i.member = 0; - Foo::foo(0); // CHECK: Bar::foo(0); + Foo::foo(0); // CHECK: Bar::foo(0); - Foo b; // CHECK: Bar b; + Foo b; // CHECK: Bar b; b.member = false; - Foo::foo(false); // CHECK: Bar::foo(false); + Foo::foo(false); // CHECK: Bar::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 - -// 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 +// 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 + +// To find offsets after modifying the file, use: +// grep -Ubo 'Foo.*' Index: clang-tools-extra/trunk/test/clang-rename/TemplateTypename.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/TemplateTypename.cpp +++ clang-tools-extra/trunk/test/clang-rename/TemplateTypename.cpp @@ -1,12 +1,24 @@ -// Currently unsupported test. -// RUN: cat %s > %t.cpp -// FIXME: clang-rename should be able to rename template parameters correctly. - -template -T foo(T arg, T& ref, T* ptr) { - T value; +template // CHECK: template +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(number); + value = (T)number; // CHECK: value = (U)number; + value = static_cast(number); // CHECK: value = static_cast(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.*' Index: clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp +++ clang-tools-extra/trunk/test/clang-rename/UserDefinedConversion.cpp @@ -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(boo); // CHECK: Bar foo = static_cast(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.*' Index: clang-tools-extra/trunk/test/clang-rename/Variable.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/Variable.cpp +++ clang-tools-extra/trunk/test/clang-rename/Variable.cpp @@ -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' 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.*' Index: clang-tools-extra/trunk/test/clang-rename/VariableMacro.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-rename/VariableMacro.cpp +++ clang-tools-extra/trunk/test/clang-rename/VariableMacro.cpp @@ -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;' 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.*'