omtcyfz updated this revision to Diff 66801.
omtcyfz marked an inline comment as done.

https://reviews.llvm.org/D23158

Files:
  clang-rename/USRFindingAction.cpp
  clang-rename/tool/ClangRename.cpp
  test/clang-rename/ClassAsTemplateArgument.cpp
  test/clang-rename/ClassAsTemplateArgumentFindByClass.cpp
  test/clang-rename/ClassAsTemplateArgumentFindByTemplateArgument.cpp
  test/clang-rename/ConstCastExpr.cpp
  test/clang-rename/FunctionWithClassFindByName.cpp
  test/clang-rename/TemplateFunction.cpp
  test/clang-rename/TemplateFunctionFindByDeclaration.cpp
  test/clang-rename/TemplateFunctionFindByUse.cpp
  test/clang-rename/TemplateTypename.cpp
  test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
  test/clang-rename/TemplateTypenameFindByTypeInside.cpp
  test/clang-rename/UserDefinedConversion.cpp
  test/clang-rename/UserDefinedConversionFindByTypeDeclaration.cpp

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<Foo>(boo);  // CHECK: Bar foo = static_cast<Bar>(boo);
-  return 0;
-}
-
-// Use grep -FUbo 'Foo' <file> to get the correct offset of Cla when changing
-// this file.
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<Foo>(boo);  // CHECK: Bar foo = static_cast<Bar>(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/TemplateTypenameFindByTypeInside.cpp
===================================================================
--- test/clang-rename/TemplateTypenameFindByTypeInside.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-template <typename T>             // CHECK: template <typename U>
-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<T>(number); // CHECK: value = static_cast<U>(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/TemplateTypenameFindByTemplateParam.cpp
===================================================================
--- test/clang-rename/TemplateTypenameFindByTemplateParam.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-template <typename T>             // CHECK: template <typename U>
-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<T>(number); // CHECK: value = static_cast<U>(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/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 <typename T>
-T foo(T arg, T& ref, T* ptr) {
-  T value;
+template <typename T>             // CHECK: template <typename U>
+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<T>(number);
+  value = (T)number;              // CHECK: value = (U)number;
+  value = static_cast<T>(number); // CHECK: value = static_cast<U>(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/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 <typename T>
-T foo(T value) {    // CHECK: T bar(T value) {
-  return value;
-}
-
-int main() {
-  foo<bool>(false); // CHECK: bar<bool>(false);
-  foo<int>(0);      // CHECK: bar<int>(0);
-  return 0;
-}
-
-// Use grep -FUbo 'foo' <file> to get the correct offset of foo when changing
-// this file.
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 <typename T>
 T foo(T value) {    // CHECK: T bar(T value) {
   return value;
@@ -12,3 +8,7 @@
   foo<int>(0);      // CHECK: bar<int>(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/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/ConstCastExpr.cpp
===================================================================
--- test/clang-rename/ConstCastExpr.cpp
+++ test/clang-rename/ConstCastExpr.cpp
@@ -14,5 +14,5 @@
   const_cast<Foo *>(C)->getValue(); // CHECK: const_cast<Bar *>(C)->getValue();
 }
 
-// Use grep -FUbo 'Cla' <file> to get the correct offset of foo when changing
+// Use grep -FUbo 'Foo' <file> to get the correct offset of foo when changing
 // this file.
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 <typename T>
-void func() {}
-
-template <typename T>
-class Baz {};
-
-int main() {
-  func<Foo>();  // CHECK: func<Bar>();
-  Baz<Foo> obj; // CHECK: Baz<Bar> obj;
-  return 0;
-}
-
-// Use grep -FUbo 'Foo' <file> to get the correct offset of Cla when changing
-// this file.
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 <typename T>
@@ -16,5 +12,6 @@
   return 0;
 }
 
-// Use grep -FUbo 'Foo' <file> 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: 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 <cstdlib>
 #include <string>
 #include <system_error>
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 <algorithm>
-#include <set>
 #include <string>
+#include <set>
 #include <vector>
 
 using namespace llvm;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to