diff --git a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp index 789c10bdd4822..e4eef228b6b99 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp @@ -467,18 +467,9 @@ class DefineOutline : public Tweak { } } - // For function templates, the same limitations as for class templates - // apply. - if (const TemplateParameterList *Params = - MD->getDescribedTemplateParams()) { - // FIXME: Is this really needed? It inhibits application on - // e.g. std::enable_if. - for (NamedDecl *P : *Params) { - if (!P->getIdentifier()) - return false; - } + // Function templates must be defined in the same file. + if (MD->getDescribedTemplate()) SameFile = true; - } // The refactoring is meaningless for unnamed classes and namespaces, // unless we're outlining in the same file diff --git a/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp b/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp index d2d2ae9e7bb61..b5f09f9b14604 100644 --- a/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp +++ b/clang-tools-extra/clangd/unittests/tweaks/DefineOutlineTests.cpp @@ -118,12 +118,6 @@ TEST_F(DefineOutlineTest, TriggersOnFunctionDecl) { template <> void fo^o() {} )cpp"); - // Not available on member function templates with unnamed template - // parameters. - EXPECT_UNAVAILABLE(R"cpp( - struct Foo { template void ba^r() {} }; - )cpp"); - // Not available on methods of unnamed classes. EXPECT_UNAVAILABLE(R"cpp( struct Foo { @@ -410,14 +404,14 @@ inline typename O1::template O2::E O1::template O2 { R"cpp( struct Foo { - template + template T ^bar() { return {}; } };)cpp", R"cpp( struct Foo { - template + template T bar() ; - };template + };template inline T Foo::bar() { return {}; } )cpp", ""}, @@ -426,13 +420,13 @@ inline T Foo::bar() { return {}; } { R"cpp( template struct Foo { - template T ^bar(const T& t, const U& u) { return {}; } + template T ^bar(const T& t, const U& u) { return {}; } };)cpp", R"cpp( template struct Foo { - template T bar(const T& t, const U& u) ; + template T bar(const T& t, const U& u) ; };template -template +template inline T Foo::bar(const T& t, const U& u) { return {}; } )cpp", ""},