Author: Kadir Cetinkaya Date: 2020-08-05T17:38:17+02:00 New Revision: 011732852c2c1ca1015fac1bed831308dc521583
URL: https://github.com/llvm/llvm-project/commit/011732852c2c1ca1015fac1bed831308dc521583 DIFF: https://github.com/llvm/llvm-project/commit/011732852c2c1ca1015fac1bed831308dc521583.diff LOG: [clangd] Fix a crash in DefineInline Differential Revision: https://reviews.llvm.org/D85291 Added: Modified: clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp clang-tools-extra/clangd/unittests/TweakTests.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp index e28a2c46c374..698d2a406811 100644 --- a/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp +++ b/clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp @@ -339,7 +339,7 @@ renameParameters(const FunctionDecl *Dest, const FunctionDecl *Source) { // 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 diff --git a/clang-tools-extra/clangd/unittests/TweakTests.cpp b/clang-tools-extra/clangd/unittests/TweakTests.cpp index 319d9e088c2d..791965160055 100644 --- a/clang-tools-extra/clangd/unittests/TweakTests.cpp +++ b/clang-tools-extra/clangd/unittests/TweakTests.cpp @@ -1093,6 +1093,11 @@ TEST_F(DefineInlineTest, TemplateSpec) { 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) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits