Index: clang-rename/USRFindingAction.cpp =================================================================== --- clang-rename/USRFindingAction.cpp +++ clang-rename/USRFindingAction.cpp @@ -29,8 +29,8 @@ #include "clang/Tooling/Refactoring.h" #include "clang/Tooling/Tooling.h" #include -#include #include +#include #include using namespace llvm; Index: clang-rename/tool/ClangRename.cpp =================================================================== --- clang-rename/tool/ClangRename.cpp +++ clang-rename/tool/ClangRename.cpp @@ -13,8 +13,8 @@ /// //===----------------------------------------------------------------------===// -#include "../RenamingAction.h" #include "../USRFindingAction.h" +#include "../RenamingAction.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticOptions.h" #include "clang/Basic/FileManager.h" @@ -31,8 +31,8 @@ #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileSystem.h" -#include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/YAMLTraits.h" #include #include #include 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,6 @@ 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/ConstCastExpr.cpp =================================================================== --- test/clang-rename/ConstCastExpr.cpp +++ test/clang-rename/ConstCastExpr.cpp @@ -14,5 +14,5 @@ const_cast(C)->getValue(); // CHECK: const_cast(C)->getValue(); } -// Use grep -FUbo 'Cla' to get the correct offset of foo when changing +// Use grep -FUbo 'Foo' to get the correct offset of foo when changing // this file. Index: test/clang-rename/FunctionWithClassFindByName.cpp =================================================================== --- test/clang-rename/FunctionWithClassFindByName.cpp +++ test/clang-rename/FunctionWithClassFindByName.cpp @@ -12,4 +12,3 @@ Foo *Pointer = 0; // CHECK: Bar *Pointer = 0; return 0; } - Index: test/clang-rename/TemplateFunction.cpp =================================================================== --- test/clang-rename/TemplateFunction.cpp +++ test/clang-rename/TemplateFunction.cpp @@ -1,7 +1,3 @@ -// 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; @@ -12,3 +8,7 @@ foo(0); // CHECK: bar(0); return 0; } + +// RUN: clang-rename -offset=24 -new-name=bar %s -- | sed 's,//.*,,' | FileCheck %s + +// RUN: clang-rename -offset=104 -new-name=bar %s -- | 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/TemplateTypename.cpp =================================================================== --- test/clang-rename/TemplateTypename.cpp +++ test/clang-rename/TemplateTypename.cpp @@ -1,12 +1,18 @@ -// 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 -- | sed 's,//.*,,' | FileCheck %s + +// RUN: clang-rename -offset=99 -new-name=U %s -- | 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,22 @@ -// 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.