kadircet created this revision. kadircet added a reviewer: hokein. Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous. Herald added a project: clang. kadircet requested review of this revision. Herald added subscribers: MaskRay, ilya-biryukov.
Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D85291 Files: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp clang-tools-extra/clangd/unittests/TweakTests.cpp Index: clang-tools-extra/clangd/unittests/TweakTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/TweakTests.cpp +++ clang-tools-extra/clangd/unittests/TweakTests.cpp @@ -1093,6 +1093,11 @@ template<> void f^oo<int>() { bar(); })cpp"); + EXPECT_UNAVAILABLE(R"cpp( + namespace bar { + template <typename T> void f^oo() {} + template void foo<int>(); + })cpp"); } TEST_F(DefineInlineTest, CheckForCanonDecl) { Index: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp =================================================================== --- clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp +++ clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp @@ -339,7 +339,7 @@ // specialization. const FunctionDecl *findTarget(const FunctionDecl *FD) { auto CanonDecl = FD->getCanonicalDecl(); - if (!FD->isFunctionTemplateSpecialization()) + if (!FD->isFunctionTemplateSpecialization() || CanonDecl == FD) return CanonDecl; // For specializations CanonicalDecl is the TemplatedDecl, which is not the // target we want to inline into. Instead we traverse previous decls to find
Index: clang-tools-extra/clangd/unittests/TweakTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/TweakTests.cpp +++ clang-tools-extra/clangd/unittests/TweakTests.cpp @@ -1093,6 +1093,11 @@ template<> void f^oo<int>() { bar(); })cpp"); + EXPECT_UNAVAILABLE(R"cpp( + namespace bar { + template <typename T> void f^oo() {} + template void foo<int>(); + })cpp"); } TEST_F(DefineInlineTest, CheckForCanonDecl) { Index: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp =================================================================== --- clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp +++ clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp @@ -339,7 +339,7 @@ // specialization. const FunctionDecl *findTarget(const FunctionDecl *FD) { auto CanonDecl = FD->getCanonicalDecl(); - if (!FD->isFunctionTemplateSpecialization()) + if (!FD->isFunctionTemplateSpecialization() || CanonDecl == FD) return CanonDecl; // For specializations CanonicalDecl is the TemplatedDecl, which is not the // target we want to inline into. Instead we traverse previous decls to find
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits