[PATCH] D91337: [clangd] Add missing tests to rename feature

2020-11-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa1152482826c: [clangd] Add missing tests to rename feature 
(authored by kbobyrev).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91337/new/

https://reviews.llvm.org/D91337

Files:
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -141,6 +141,12 @@
   ~[[F^oo]]();
   void f([[F^oo]] x);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
+
+template
+[[F^oo]]::~[[Fo^o]]() {}
   )cpp",
 
   // Template class constructor.
@@ -152,6 +158,9 @@
   template
   [[F^oo]](T t);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
   )cpp",
 
   // Class in template argument.
@@ -199,6 +208,30 @@
 }
   )cpp",
 
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
   // Template class (partial) specializations.
   R"cpp(
 template 
@@ -272,6 +305,80 @@
 }
   )cpp",
 
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template 
+void [[f^oo]](T t);
+
+template <>
+void [[f^oo]](int a);
+
+void test() {
+  [[f^oo]](1);
+}
+  )cpp",
+
+  // Variable template.
+  R"cpp(
+template 
+bool [[F^oo]] = true;
+
+// Explicit template specialization
+template <>
+bool [[F^oo]] = false;
+
+// Partial template specialization
+template 
+bool [[F^oo]] = false;
+
+void foo() {
+  // Ref to the explicit template specialization
+  [[F^oo]];
+  // Ref to the primary template.
+  [[F^oo]];
+}
+  )cpp",
+
   // Complicated class type.
   R"cpp(
  // Forward declaration.
@@ -307,6 +414,19 @@
 }
   )cpp",
 
+  // Static class member.
+  R"cpp(
+struct Foo {
+  static Foo *[[Static^Member]];
+};
+
+Foo* Foo::[[Static^Member]] = nullptr;
+
+void foo() {
+  Foo* Pointer = Foo::[[Static^Member]];
+}
+  )cpp",
+
   // Reference in lambda parameters.
   R"cpp(
 template 
@@ -588,6 +708,26 @@
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // User defined conversion.
+  R"cpp(
+class [[F^oo]] {
+public:
+  [[F^oo]]() {}
+};
+
+class Baz {
+public:
+  operator [[F^oo]]() {
+return [[F^oo]]();
+  }
+};
+
+int main() {
+  Baz boo;
+  [[F^oo]] foo = static_cast<[[F^oo]]>(boo);
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91337: [clangd] Add missing tests to rename feature

2020-11-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 305070.
kbobyrev added a comment.

Move the rest of templated cases to appropriate location.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91337/new/

https://reviews.llvm.org/D91337

Files:
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -141,6 +141,12 @@
   ~[[F^oo]]();
   void f([[F^oo]] x);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
+
+template
+[[F^oo]]::~[[Fo^o]]() {}
   )cpp",
 
   // Template class constructor.
@@ -152,6 +158,9 @@
   template
   [[F^oo]](T t);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
   )cpp",
 
   // Class in template argument.
@@ -199,6 +208,30 @@
 }
   )cpp",
 
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
   // Template class (partial) specializations.
   R"cpp(
 template 
@@ -272,6 +305,80 @@
 }
   )cpp",
 
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template 
+void [[f^oo]](T t);
+
+template <>
+void [[f^oo]](int a);
+
+void test() {
+  [[f^oo]](1);
+}
+  )cpp",
+
+  // Variable template.
+  R"cpp(
+template 
+bool [[F^oo]] = true;
+
+// Explicit template specialization
+template <>
+bool [[F^oo]] = false;
+
+// Partial template specialization
+template 
+bool [[F^oo]] = false;
+
+void foo() {
+  // Ref to the explicit template specialization
+  [[F^oo]];
+  // Ref to the primary template.
+  [[F^oo]];
+}
+  )cpp",
+
   // Complicated class type.
   R"cpp(
  // Forward declaration.
@@ -307,6 +414,19 @@
 }
   )cpp",
 
+  // Static class member.
+  R"cpp(
+struct Foo {
+  static Foo *[[Static^Member]];
+};
+
+Foo* Foo::[[Static^Member]] = nullptr;
+
+void foo() {
+  Foo* Pointer = Foo::[[Static^Member]];
+}
+  )cpp",
+
   // Reference in lambda parameters.
   R"cpp(
 template 
@@ -588,6 +708,26 @@
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // User defined conversion.
+  R"cpp(
+class [[F^oo]] {
+public:
+  [[F^oo]]() {}
+};
+
+class Baz {
+public:
+  operator [[F^oo]]() {
+return [[F^oo]]();
+  }
+};
+
+int main() {
+  Baz boo;
+  [[F^oo]] foo = static_cast<[[F^oo]]>(boo);
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91337: [clangd] Add missing tests to rename feature

2020-11-13 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:618
+
+  // Templated method instantiation.
+  R"cpp(

hokein wrote:
> nit: we have groups of templates on ~Line  215 already,  I'd suggest to move 
> these template-related cases to there.
this looks like still undone. 

I would move this section (from Line638-Line710) to Line307.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91337/new/

https://reviews.llvm.org/D91337

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91337: [clangd] Add missing tests to rename feature

2020-11-13 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev updated this revision to Diff 305047.
kbobyrev marked 4 inline comments as done.
kbobyrev added a comment.

Address the comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91337/new/

https://reviews.llvm.org/D91337

Files:
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -141,6 +141,12 @@
   ~[[F^oo]]();
   void f([[F^oo]] x);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
+
+template
+[[F^oo]]::~[[Fo^o]]() {}
   )cpp",
 
   // Template class constructor.
@@ -152,6 +158,9 @@
   template
   [[F^oo]](T t);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
   )cpp",
 
   // Class in template argument.
@@ -199,6 +208,30 @@
 }
   )cpp",
 
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
   // Template class (partial) specializations.
   R"cpp(
 template 
@@ -307,6 +340,19 @@
 }
   )cpp",
 
+  // Static class member.
+  R"cpp(
+struct Foo {
+  static Foo *[[Static^Member]];
+};
+
+Foo* Foo::[[Static^Member]] = nullptr;
+
+void foo() {
+  Foo* Pointer = Foo::[[Static^Member]];
+}
+  )cpp",
+
   // Reference in lambda parameters.
   R"cpp(
 template 
@@ -588,6 +634,100 @@
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template 
+void [[f^oo]](T t);
+
+template <>
+void [[f^oo]](int a);
+
+void test() {
+  [[f^oo]](1);
+}
+  )cpp",
+
+  // Variable template.
+  R"cpp(
+template 
+bool [[F^oo]] = true;
+
+// Explicit template specialization
+template <>
+bool [[F^oo]] = false;
+
+// Partial template specialization
+template 
+bool [[F^oo]] = false;
+
+void foo() {
+  // Ref to the explicit template specialization
+  [[F^oo]];
+  // Ref to the primary template.
+  [[F^oo]];
+}
+  )cpp",
+
+  // User defined conversion.
+  R"cpp(
+class [[F^oo]] {
+public:
+  [[F^oo]]() {}
+};
+
+class Baz {
+public:
+  operator [[F^oo]]() {
+return [[F^oo]]();
+  }
+};
+
+int main() {
+  Baz boo;
+  [[F^oo]] foo = static_cast<[[F^oo]]>(boo);
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91337: [clangd] Add missing tests to rename feature

2020-11-12 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:203
 };
+struct D : B {
+  void [[f^oo]]() override {}

hmm, I'm not sure this is needed, I think it is identical with `C`.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:618
+
+  // Templated method instantiation.
+  R"cpp(

nit: we have groups of templates on ~Line  215 already,  I'd suggest to move 
these template-related cases to there.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:684
+
+  R"cpp(
+template 

nit: add a comment, this is variable template.



Comment at: clang-tools-extra/clangd/unittests/RenameTests.cpp:703
+  )cpp",
+  R"cpp(
+template 

this test case is about function templates, move to Line 683.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D91337/new/

https://reviews.llvm.org/D91337

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91337: [clangd] Add missing tests to rename feature

2020-11-12 Thread Kirill Bobyrev via Phabricator via cfe-commits
kbobyrev created this revision.
kbobyrev added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman.
Herald added a project: clang.
kbobyrev requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

This adds a couple of missed tests from existing clang-rename ones and
introduces several new ones (e.g. static class member). This patch is required
to ensure feature parity for migration off Clang-Rename API D71880 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91337

Files:
  clang-tools-extra/clangd/unittests/RenameTests.cpp

Index: clang-tools-extra/clangd/unittests/RenameTests.cpp
===
--- clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -141,6 +141,12 @@
   ~[[F^oo]]();
   void f([[F^oo]] x);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
+
+template
+[[F^oo]]::~[[Fo^o]]() {}
   )cpp",
 
   // Template class constructor.
@@ -152,6 +158,9 @@
   template
   [[F^oo]](T t);
 };
+
+template
+[[F^oo]]::[[Fo^o]]() {}
   )cpp",
 
   // Class in template argument.
@@ -191,11 +200,15 @@
 struct C : B {
   void [[f^oo]]() override {}
 };
+struct D : B {
+  void [[f^oo]]() override {}
+};
 
 void func() {
   A().[[f^oo]]();
   B().[[f^oo]]();
   C().[[f^oo]]();
+  D().[[f^oo]]();
 }
   )cpp",
 
@@ -307,6 +320,19 @@
 }
   )cpp",
 
+  // Static class member.
+  R"cpp(
+struct Foo {
+  static Foo *[[Static^Member]];
+};
+
+Foo* Foo::[[Static^Member]] = nullptr;
+
+void foo() {
+  Foo* Pointer = Foo::[[Static^Member]];
+}
+  )cpp",
+
   // Reference in lambda parameters.
   R"cpp(
 template 
@@ -588,6 +614,123 @@
   ns::[[Old^Alias]] Bar;
 }
   )cpp",
+
+  // Templated method instantiation.
+  R"cpp(
+template
+class Foo {
+public:
+  static T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo::[[f^oo]]();
+}
+  )cpp",
+  R"cpp(
+template
+class Foo {
+public:
+  T [[f^oo]]() {}
+};
+
+void bar() {
+  Foo().[[f^oo]]();
+}
+  )cpp",
+
+  // Templated class specialization.
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+
+template
+class [[Foo^]];
+  )cpp",
+  R"cpp(
+template
+class [[Foo^]];
+
+template
+class [[Foo^]] {};
+  )cpp",
+
+  // Function template specialization.
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]() {};
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]() {};
+
+template
+U [[foo^]]();
+  )cpp",
+  R"cpp(
+template
+U [[foo^]]();
+
+template
+U [[foo^]]();
+  )cpp",
+
+  R"cpp(
+template 
+bool [[F^oo]] = true;
+
+// Explicit template specialization
+template <>
+bool [[F^oo]] = false;
+
+// Partial template specialization
+template 
+bool [[F^oo]] = false;
+
+void foo() {
+  // Ref to the explicit template specialization
+  [[F^oo]];
+  // Ref to the primary template.
+  [[F^oo]];
+}
+  )cpp",
+  R"cpp(
+template 
+void [[f^oo]](T t);
+
+template <>
+void [[f^oo]](int a);
+
+void test() {
+  [[f^oo]](1);
+}
+  )cpp",
+
+  // User defined conversion.
+  R"cpp(
+class [[F^oo]] {
+public:
+  [[F^oo]]() {}
+};
+
+class Baz {
+public:
+  operator [[F^oo]]() {
+return [[F^oo]]();
+  }
+};
+
+int main() {
+  Baz boo;
+  [[F^oo]] foo = static_cast<[[F^oo]]>(boo);
+}
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits