diff --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp b/clang-tools-extra/clangd/unittests/RenameTests.cpp index daf63d25ed7f4..876262a463a53 100644 --- a/clang-tools-extra/clangd/unittests/RenameTests.cpp +++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp @@ -141,6 +141,12 @@ TEST(RenameTest, WithinFileRename) { ~[[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 @@ TEST(RenameTest, WithinFileRename) { template [[F^oo]](T t); }; + + template + [[F^oo]]::[[Fo^o]]() {} )cpp", // Class in template argument. @@ -199,6 +208,30 @@ TEST(RenameTest, WithinFileRename) { } )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 @@ TEST(RenameTest, WithinFileRename) { } )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 @@ TEST(RenameTest, WithinFileRename) { } )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 @@ TEST(RenameTest, WithinFileRename) { 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) {