Index: test/clang-rename/ClassAsTemplateArgument.cpp =================================================================== --- test/clang-rename/ClassAsTemplateArgument.cpp +++ test/clang-rename/ClassAsTemplateArgument.cpp @@ -1,7 +1,3 @@ -// 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 {}; // CHECK: class Bar {}; template @@ -16,5 +12,5 @@ return 0; } -// Use grep -FUbo 'Foo' to get the correct offset of Foo when changing -// this file. +// RUN: clang-rename -offset=7 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=175 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/ClassAsTemplateArgumentFindByTemplateArgument.cpp =================================================================== --- test/clang-rename/ClassAsTemplateArgumentFindByTemplateArgument.cpp +++ /dev/null @@ -1,20 +0,0 @@ -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=304 -new-name=Bar %t.cpp -i -- -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s - -class Foo {}; // CHECK: class Bar {}; - -template -void func() {} - -template -class Baz {}; - -int main() { - func(); // CHECK: func(); - Baz obj; // CHECK: Baz obj; - return 0; -} - -// Use grep -FUbo 'Foo' to get the correct offset of Cla when changing -// this file. Index: test/clang-rename/ClassFindByName.cpp =================================================================== --- test/clang-rename/ClassFindByName.cpp +++ test/clang-rename/ClassFindByName.cpp @@ -1,11 +1,9 @@ -// 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; } + +// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/ClassNameInFunctionDefinition.cpp =================================================================== --- test/clang-rename/ClassNameInFunctionDefinition.cpp +++ test/clang-rename/ClassNameInFunctionDefinition.cpp @@ -1,10 +1,8 @@ -// 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 { // CHECK: class Bar { public: void foo(int x); }; void Foo::foo(int x) {} // CHECK: void Bar::foo(int x) {} + +// RUN: clang-rename -offset=7 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/ClassSimpleRenaming.cpp =================================================================== --- test/clang-rename/ClassSimpleRenaming.cpp +++ test/clang-rename/ClassSimpleRenaming.cpp @@ -1,7 +1,3 @@ -// 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 {}; // CHECK: class Bar int main() { @@ -9,5 +5,6 @@ return 0; } -// Use grep -FUbo 'Foo' to get the correct offset of Cla when changing +// RUN: clang-rename -offset=7 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// Use grep -Ubo 'Foo' to get the correct offset of Cla when changing // this file. Index: test/clang-rename/ClassTestMulti.cpp =================================================================== --- test/clang-rename/ClassTestMulti.cpp +++ test/clang-rename/ClassTestMulti.cpp @@ -1,8 +1,7 @@ -// 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 Foo2 { // CHECK: class Bar2 }; + +// RUN: clang-rename rename-all -offset=6 -new-name=Bar1 -offset=44 -new-name=Bar2 %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/ClassTestMultiByName.cpp =================================================================== --- test/clang-rename/ClassTestMultiByName.cpp +++ test/clang-rename/ClassTestMultiByName.cpp @@ -1,8 +1,7 @@ -// 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 }; + +// RUN: clang-rename rename-all -old-name=Foo1 -new-name=Bar1 -old-name=Foo2 -new-name=Bar2 %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/ComplexFunctionOverride.cpp =================================================================== --- test/clang-rename/ComplexFunctionOverride.cpp +++ test/clang-rename/ComplexFunctionOverride.cpp @@ -1,7 +1,3 @@ -// 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(); }; @@ -21,3 +17,9 @@ struct E : D { void foo() override; // CHECK: void bar() override; }; + +// RUN: clang-rename -offset=26 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=91 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=165 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=239 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=313 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/ComplicatedClassType.cpp =================================================================== --- test/clang-rename/ComplicatedClassType.cpp +++ test/clang-rename/ComplicatedClassType.cpp @@ -1,7 +1,3 @@ -// 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; @@ -29,3 +25,6 @@ } return 0; } + +// RUN: clang-rename -offset=30 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=90 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/ConstCastExpr.cpp =================================================================== --- test/clang-rename/ConstCastExpr.cpp +++ test/clang-rename/ConstCastExpr.cpp @@ -1,7 +1,3 @@ -// 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 { // CHECK: class Bar { public: int getValue() { @@ -14,5 +10,4 @@ const_cast(C)->getValue(); // CHECK: const_cast(C)->getValue(); } -// Use grep -FUbo 'Cla' to get the correct offset of foo when changing -// this file. +// RUN: clang-rename -offset=6 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/ConstructExpr.cpp =================================================================== --- test/clang-rename/ConstructExpr.cpp +++ test/clang-rename/ConstructExpr.cpp @@ -1,12 +1,7 @@ -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=136 -new-name=Boo %t.cpp -i -- -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s - -class Foo {}; // CHECK: class Boo {}; +class Foo {}; // CHECK: class Bar {}; int main() { - Foo *C = new Foo(); // CHECK: Boo *C = new Boo(); + Foo *C = new Foo(); // CHECK: Bar *C = new Bar(); } -// Use grep -FUbo 'Boo' to get the correct offset of foo when changing -// this file. +// RUN: clang-rename -offset=6 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/Ctor.cpp =================================================================== --- /dev/null +++ test/clang-rename/Ctor.cpp @@ -0,0 +1,9 @@ +class Foo { // CHECK: class Bar { +public: + Foo(); // CHECK: Bar(); +}; + +Foo::Foo() {} // CHECK: Bar::Bar() {} + +// RUN: clang-rename -offset=6 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=84 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/CtorFindByDeclaration.cpp =================================================================== --- test/clang-rename/CtorFindByDeclaration.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=174 -new-name=Bar %t.cpp -i -- -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s - -class Foo { // CHECK: class Bar -public: - Foo(); // CHECK: Bar(); -}; - -Foo::Foo() {} // CHECK: Bar::Bar() - -// Use grep -FUbo 'C' to get the correct offset of foo when changing -// this file. Index: test/clang-rename/CtorFindByDefinition.cpp =================================================================== --- test/clang-rename/CtorFindByDefinition.cpp +++ /dev/null @@ -1,13 +0,0 @@ -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=212 -new-name=Bar %t.cpp -i -- -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s - -class Foo { // CHECK: class Bar -public: - Foo(); // CHECK: Bar(); -}; - -Foo::Foo() {} // CHECK: Bar::Bar() - -// Use grep -FUbo 'C' to get the correct offset of foo when changing -// this file. Index: test/clang-rename/CtorInitializer.cpp =================================================================== --- test/clang-rename/CtorInitializer.cpp +++ test/clang-rename/CtorInitializer.cpp @@ -1,7 +1,3 @@ -// 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 { @@ -12,5 +8,4 @@ Qux::Qux() : Foo() {} // CHECK: Qux::Qux() : Bar() {} -// Use grep -FUbo 'Foo' to get the correct offset of foo when changing -// this file. +// RUN: clang-rename -offset=33 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/DeclRefExpr.cpp =================================================================== --- test/clang-rename/DeclRefExpr.cpp +++ test/clang-rename/DeclRefExpr.cpp @@ -1,20 +1,16 @@ -// 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; // CHECK: static int Bar; }; int foo(int x) { return 0; } #define MACRO(a) foo(a) int main() { - C::Foo = 1; // CHECK: C::Bar + C::Foo = 1; // CHECK: C::Bar MACRO(C::Foo); // CHECK: C::Bar - int y = C::Foo; // CHECK: C::Bar + int y = C::Foo; // CHECK: C::Bar } -// Use grep -FUbo 'X' to get the correct offset of foo when changing -// this file. +// RUN: clang-rename -offset=31 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=140 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/Dtor.cpp =================================================================== --- /dev/null +++ test/clang-rename/Dtor.cpp @@ -0,0 +1,10 @@ +class Foo { // CHECK: class Bar { +public: + ~Foo(); // CHECK: ~Bar(); +}; + +Foo::~Foo() { // CHECK: Bar::~Bar() +} + +// RUN: clang-rename -offset=45 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=82 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/DtorDeclaration.cpp =================================================================== --- test/clang-rename/DtorDeclaration.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=175 -new-name=Bar %t.cpp -i -- -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s - -class Foo { // CHECK: class Bar { -public: - ~Foo(); // CHECK: ~Bar(); -}; - -Foo::~Foo() { // CHECK: Bar::~Bar() -} - -// Use grep -FUbo 'Bar' to get the correct offset of foo when changing -// this file. Index: test/clang-rename/DtorDefinition.cpp =================================================================== --- test/clang-rename/DtorDefinition.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=219 -new-name=Bar %t.cpp -i -- -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s - -class Foo { // CHECK: class Bar { -public: - ~Foo(); // CHECK: ~Bar(); -}; - -Foo::~Foo() {} // CHECK: Bar::~Bar() - - -// Use grep -FUbo 'Foo' to get the correct offset of foo when changing -// this file. Index: test/clang-rename/DynamicCastExpr.cpp =================================================================== --- test/clang-rename/DynamicCastExpr.cpp +++ test/clang-rename/DynamicCastExpr.cpp @@ -1,7 +1,3 @@ -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=195 -new-name=Bar %t.cpp -i -- -frtti -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s - class Baz { virtual int getValue() const = 0; }; @@ -14,7 +10,7 @@ }; int main() { - Foo foo; // FIXME: Bar foo; <- this one fails + Foo foo; // FIXME: Bar foo; const Baz &Reference = foo; const Baz *Pointer = &foo; @@ -22,5 +18,5 @@ dynamic_cast(Pointer)->getValue(); // CHECK: dynamic_cast(Pointer)->getValue(); } -// Use grep -FUbo 'Foo' to get the correct offset of foo when changing -// this file. +// RUN: clang-rename -offset=58 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=208 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/Field.cpp =================================================================== --- test/clang-rename/Field.cpp +++ test/clang-rename/Field.cpp @@ -1,7 +1,3 @@ -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=148 -new-name=Bar %t.cpp -i -- -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s - class Baz { int Foo; // CHECK: Bar; public: @@ -10,5 +6,5 @@ Baz::Baz() : Foo(0) {} // CHECK: Baz::Baz() : Bar(0) {} -// Use grep -FUbo 'Foo' to get the correct offset of foo when changing -// this file. +// RUN: clang-rename -offset=18 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=85 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/FunctionMacro.cpp =================================================================== --- test/clang-rename/FunctionMacro.cpp +++ test/clang-rename/FunctionMacro.cpp @@ -1,7 +1,3 @@ -// 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() { @@ -17,5 +13,4 @@ boo(moo()); } -// Use grep -FUbo 'foo;' to get the correct offset of foo when changing -// this file. +// RUN: clang-rename -offset=58 -new-name=macro_function %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/FunctionOverride.cpp =================================================================== --- test/clang-rename/FunctionOverride.cpp +++ test/clang-rename/FunctionOverride.cpp @@ -1,10 +1,7 @@ -// 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(); }; // 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(); }; -// Use grep -FUbo 'Foo' to get the correct offset of Foo when changing -// this file. +// RUN: clang-rename -offset=23 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=105 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=187 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/FunctionWithClassFindByName.cpp =================================================================== --- test/clang-rename/FunctionWithClassFindByName.cpp +++ 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: test/clang-rename/MemberExprMacro.cpp =================================================================== --- test/clang-rename/MemberExprMacro.cpp +++ test/clang-rename/MemberExprMacro.cpp @@ -1,7 +1,3 @@ -// 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; @@ -17,5 +13,5 @@ int y = baz.Foo; // CHECK: int y = baz.Bar; } -// Use grep -FUbo 'Foo' to get the correct offset of foo when changing -// this file. +// RUN: clang-rename -offset=26 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=147 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/Namespace.cpp =================================================================== --- test/clang-rename/Namespace.cpp +++ test/clang-rename/Namespace.cpp @@ -1,14 +1,9 @@ -// 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 { // CHECK: namespace clang { 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. +// RUN: clang-rename -offset=10 -new-name=clang %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/NoNewName.cpp =================================================================== --- test/clang-rename/NoNewName.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// Check for an error while -new-name argument has not been passed to -// clang-rename. -// RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s -// CHECK: clang-rename: for the -new-name option: must be specified Index: test/clang-rename/ReinterpretCastExpr.cpp =================================================================== --- test/clang-rename/ReinterpretCastExpr.cpp +++ test/clang-rename/ReinterpretCastExpr.cpp @@ -1,7 +1,4 @@ -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=133 -new-name=X %t.cpp -i -- -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s -class Cla { +class Foo { public: int getValue() const { return 0; @@ -9,9 +6,10 @@ }; int main() { - void *C = new Cla(); - reinterpret_cast(C)->getValue(); // CHECK: reinterpret_cast + void *Pointer = new Foo(); + reinterpret_cast(Pointer)->getValue(); // CHECK: reinterpret_cast } -// Use grep -FUbo 'Cla' to get the correct offset of foo when changing -// this file. +// RUN: clang-rename -offset=6 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=102 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=134 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/StaticCastExpr.cpp =================================================================== --- test/clang-rename/StaticCastExpr.cpp +++ test/clang-rename/StaticCastExpr.cpp @@ -1,7 +1,3 @@ -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=152 -new-name=Bar %t.cpp -i -- -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s - class Baz { }; @@ -13,13 +9,13 @@ }; int main() { - Foo foo; // FIXME: Bar foo; + Foo foo; // CHECK: Bar foo; const Baz &Reference = foo; const Baz *Pointer = &foo; - static_cast(Reference).getValue(); // CHECK: static_cast(Reference).getValue(); static_cast(Pointer)->getValue(); // CHECK: static_cast(Pointer)->getValue(); } -// Use grep -FUbo 'Foo' to get the correct offset of foo when changing -// this file. +// RUN: clang-rename -offset=22 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=317 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=425 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/TemplateClassInstantiation.cpp =================================================================== --- test/clang-rename/TemplateClassInstantiation.cpp +++ test/clang-rename/TemplateClassInstantiation.cpp @@ -31,14 +31,6 @@ 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 +// RUN: clang-rename -offset=29 -new-name=Bar %s -- -fno-delayed-template-parsing | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=311 -new-name=Bar %s -- -fno-delayed-template-parsing | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=445 -new-name=Bar %s -- -fno-delayed-template-parsing | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/TemplateFunction.cpp =================================================================== --- /dev/null +++ test/clang-rename/TemplateFunction.cpp @@ -0,0 +1,13 @@ +template +T foo(T value) { // CHECK: T bar(T value) { + return value; +} + +int main() { + foo(false); // CHECK: bar(false); + foo(0); // CHECK: bar(0); + return 0; +} + +// RUN: clang-rename -offset=24 -new-name=bar %s -- -fno-delayed-template-parsing | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=104 -new-name=bar %s -- -fno-delayed-template-parsing | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/TemplateFunctionFindByDeclaration.cpp =================================================================== --- test/clang-rename/TemplateFunctionFindByDeclaration.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=154 -new-name=bar %t.cpp -i -- -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s - -template -T foo(T value) { // CHECK: T bar(T value) { - return value; -} - -int main() { - foo(false); // CHECK: bar(false); - foo(0); // CHECK: bar(0); - return 0; -} - -// Use grep -FUbo 'foo' to get the correct offset of foo when changing -// this file. Index: test/clang-rename/TemplateFunctionFindByUse.cpp =================================================================== --- test/clang-rename/TemplateFunctionFindByUse.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=233 -new-name=bar %t.cpp -i -- -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s - -template -T foo(T value) { // CHECK: T bar(T value) { - return value; -} - -int main() { - foo(false); // CHECK: bar(false); - foo(0); // CHECK: bar(0); - return 0; -} Index: test/clang-rename/TemplateTypename.cpp =================================================================== --- test/clang-rename/TemplateTypename.cpp +++ test/clang-rename/TemplateTypename.cpp @@ -1,12 +1,17 @@ -// 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* ptr) { // CHECK: U foo(U arg, U& ref, U* 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; +}; + +// RUN: clang-rename -offset=19 -new-name=U %s -- -fno-delayed-template-parsing | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=99 -new-name=U %s -- -fno-delayed-template-parsing | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/TemplateTypenameFindByTemplateParam.cpp =================================================================== --- test/clang-rename/TemplateTypenameFindByTemplateParam.cpp +++ /dev/null @@ -1,18 +0,0 @@ -template // CHECK: template -class Foo { -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(number); // CHECK: value = static_cast(number); - return value; -} - -static void foo(T value) {} // CHECK: static void foo(U value) {} - -T member; // CHECK: U member; -}; - -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=19 -new-name=U %t.cpp -i -- -fno-delayed-template-parsing -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s Index: test/clang-rename/TemplateTypenameFindByTypeInside.cpp =================================================================== --- test/clang-rename/TemplateTypenameFindByTypeInside.cpp +++ /dev/null @@ -1,18 +0,0 @@ -template // CHECK: template -class Foo { -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(number); // CHECK: value = static_cast(number); - return value; -} - -static void foo(T value) {} // CHECK: static void foo(U value) {} - -T member; // CHECK: U member; -}; - -// RUN: cat %s > %t.cpp -// RUN: clang-rename -offset=99 -new-name=U %t.cpp -i -- -fno-delayed-template-parsing -// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s Index: test/clang-rename/UserDefinedConversion.cpp =================================================================== --- test/clang-rename/UserDefinedConversion.cpp +++ test/clang-rename/UserDefinedConversion.cpp @@ -1,13 +1,21 @@ -// 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 { // 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() const { // CHECK: operator Bar() 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; +} + +// RUN: clang-rename -offset=7 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=156 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/UserDefinedConversionFindByTypeDeclaration.cpp =================================================================== --- test/clang-rename/UserDefinedConversionFindByTypeDeclaration.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// 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 { // CHECK: class Bar { -// ^ offset must be here -public: - Foo() {} // CHECK: Bar() {} -}; - -class Baz { -public: - operator Foo() const { // CHECK: operator Bar() 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; -} - -// Use grep -FUbo 'Foo' to get the correct offset of Cla when changing -// this file. Index: test/clang-rename/Variable.cpp =================================================================== --- test/clang-rename/Variable.cpp +++ test/clang-rename/Variable.cpp @@ -1,7 +1,3 @@ -// 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; } @@ -23,5 +19,7 @@ Foo = b.Foo; // Foo = b.Foo; } -// Use grep -FUbo 'Foo' to get the correct offset of foo when changing -// this file. +// RUN: clang-rename -offset=18 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=164 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=487 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=535 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s Index: test/clang-rename/VariableMacro.cpp =================================================================== --- test/clang-rename/VariableMacro.cpp +++ test/clang-rename/VariableMacro.cpp @@ -1,18 +1,15 @@ -// 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; // CHECK: int Bar; + Foo = 42; // CHECK: Bar = 42; + Baz -= 0; + foo(Foo); // CHECK: foo(Bar); + foo(Baz); } -// Use grep -FUbo 'foo;' to get the correct offset of foo when changing -// this file. +// RUN: clang-rename -offset=88 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=117 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s +// RUN: clang-rename -offset=167 -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s