Skip to content

Commit

Permalink
[clangd] Fix a crash in DefineInline
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D85291
  • Loading branch information
kadircet committed Aug 5, 2020
1 parent 271d9c5 commit 0117328
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions clang-tools-extra/clangd/unittests/TweakTests.cpp
Expand Up @@ -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) {
Expand Down

0 comments on commit 0117328

Please sign in to comment.